import React, {useState, useEffect} from "react"; import { PencilSquare } from "react-bootstrap-icons"; import { useNavigate, useParams } from "react-router-dom"; import { AuthService, CustomerService } from "../../services"; import { Spinner, Breadcrumb, BreadcrumbItem, Tabs, Tab } from "react-bootstrap"; import { CUSTOMER_JOIN_REASON_TEXT, CUSTOMER_DISCHARGE_REASON_TEXT } from "../../shared"; const ViewCustomer = () => { const navigate = useNavigate(); const urlParams = useParams(); const [currentCustomer, setCurrentCustomer] = useState(undefined); const [currentAvatar, setCurrentAvatar] = useState(undefined); const redirectTo = () => { navigate(`/customers/list`) } const goToEdit = (id) => { navigate(`/customers/edit/${id}`) } useEffect(() => { if (!AuthService.canViewCustomers()) { window.alert('You haven\'t login yet OR this user does not have access to this page. Please change an admin account to login.') AuthService.logout(); navigate(`/login`); } if (!currentCustomer) { CustomerService.getCustomer(urlParams.id).then((data) => { setCurrentCustomer(data.data); }) } }, []); useEffect(() => { if (currentCustomer?.id ) { CustomerService.getAvatar(currentCustomer?.id).then((data) => { setCurrentAvatar(data.data); }) } }, [currentCustomer]); return ( <>
General Customer Information View Customer Details

View Customer Information

Personal Details
Name
{currentCustomer?.name}
First Name
{currentCustomer?.firstname}
{/*
Middle Name
setMiddlename(e.target.value)}/>
*/}
Last Name
{currentCustomer?.lastname}
Preferred Name/Chinese Name
{currentCustomer?.name_cn}
Admission Date
{currentCustomer?.admission_date}
Discharge Date
{currentCustomer?.discharge_date}
Birth Date
{currentCustomer?.birth_date}
Customer Type
{currentCustomer?.type}
Gender
{currentCustomer?.gender}
Language Spoken
{currentCustomer?.language}
Height
{currentCustomer?.height}
Weight
{currentCustomer?.weight}
Contact Information
Primary Phone Number
{currentCustomer?.phone}
Secondary Phone Number
{currentCustomer?.home_phone}
{/*
Other Phone Number
setMobilePhone(e.target.value)}/>
*/}
Personal Email
{currentCustomer?.email}
{/* We will do Address and Emergency later */}
Home Addresses
{[1, 2, 3, 4, 5].map((index) => { const streetAddress = index === 1 ? currentCustomer?.street_address_1 : index === 2 ? currentCustomer?.street_address_2 : index === 3 ? currentCustomer?.street_address_3 : index === 4 ? currentCustomer?.street_address_4 : currentCustomer?.street_address_5; const city = index === 1 ? currentCustomer?.city1 : index === 2 ? currentCustomer?.city2 : index === 3 ? currentCustomer?.city3 : index === 4 ? currentCustomer?.city4 : currentCustomer?.city5; const state = index === 1 ? currentCustomer?.state1 : index === 2 ? currentCustomer?.state2 : index === 3 ? currentCustomer?.state3 : index === 4 ? currentCustomer?.state4 : currentCustomer?.state5; const zipCode = index === 1 ? currentCustomer?.zip_code1 : index === 2 ? currentCustomer?.zip_code2 : index === 3 ? currentCustomer?.zip_code3 : index === 4 ? currentCustomer?.zip_code4 : currentCustomer?.zip_code5; const address = index === 1 ? currentCustomer?.address1 : index === 2 ? currentCustomer?.address2 : index === 3 ? currentCustomer?.address3 : index === 4 ? currentCustomer?.address4 : currentCustomer?.address5; // Show address if any of the new fields or old address field has data if (streetAddress || city || state || zipCode || address) { return ( <>
Address {index}
{streetAddress && (
Street Address
{streetAddress}
)} {city && (
City
{city}
)} {state && (
State
{state}
)} {zipCode && (
Zip Code
{zipCode}
)} {address && !streetAddress && !city && !state && !zipCode && (
Address
{address}
)}
); } return null; })}
Emergency Contact Information
{[1, 2].map((index) => { const name = index === 1 ? currentCustomer?.emergency_contact_name : currentCustomer?.emergency_contact2_name; const phone = index === 1 ? currentCustomer?.emergency_contact_phone : currentCustomer?.emergency_contact2_phone; const relationship = index === 1 ? currentCustomer?.emergency_contact_relationship : currentCustomer?.emergency_contact2_relationship; const emergencyContact = index === 1 ? currentCustomer?.emergency_contact : currentCustomer?.emergency_contact2; // Show emergency contact if any of the new fields or old emergency contact field has data if (name || phone || relationship || emergencyContact) { return ( <>
{index === 1 ? 'Primary Emergency Contact' : 'Emergency Contact 2'}
{name && (
Name
{name}
)} {phone && (
Phone
{phone}
)} {relationship && (
Relationship
{relationship}
)} {emergencyContact && !name && !phone && !relationship && (
Emergency Contact
{emergencyContact}
)}
); } return null; })}
Service Information
Text Message Enabled
{currentCustomer?.text_msg_enabled ? 'Yes': 'No'}
Table Id
{currentCustomer?.table_id}
Seating
{currentCustomer?.seating}
Pickup Status
{currentCustomer?.pickup_status}
General Health Information
Eyes-on
{currentCustomer?.disability ? 'Yes' : 'No'}
Special Needs
{currentCustomer?.special_needs}
Health Condition
{currentCustomer?.health_condition}
Allergy Information
{currentCustomer?.allergy_info}
Service Requirements
{currentCustomer?.service_requirement}
Payment Due Date
{currentCustomer?.payment_due_date}
Payment Status
{currentCustomer?.payment_status}
Join Reason
{currentCustomer?.join_reason ? CUSTOMER_JOIN_REASON_TEXT[currentCustomer.join_reason] : ''}
Discharge Reason
{currentCustomer?.discharge_reason ? CUSTOMER_DISCHARGE_REASON_TEXT[currentCustomer.discharge_reason] : ''}
Additional Information
Profile Picture
{currentAvatar && }
Note
{currentCustomer?.note || currentCustomer?.private_note}
Personal Details
Primary Care Provider
{currentCustomer?.care_provider}
Medicare Number
{currentCustomer?.medicare_number}
Medicaid Number
{currentCustomer?.medicaid_number}
Pharmacy
{currentCustomer?.pharmacy}
Pharmacy ID
{currentCustomer?.pharmacy_id}
{/*
{currentAvatar && }
Emergency Contact:{currentCustomer?.emergency_contact}
Mobile Phone: {currentCustomer?.mobile_phone}
Username: {currentCustomer?.username}
Address 1: {currentCustomer?.address1}
Address 2: {currentCustomer?.address2}
Address 3: {currentCustomer?.address3}
Address 4: {currentCustomer?.address4}
Address 5: {currentCustomer?.address5}
Apartment: {currentCustomer?.apartment}
Pin:{currentCustomer?.pin}
Vehicle No: {currentCustomer?.vehicle_no}
Caller:{currentCustomer?.caller}
Placement:{currentCustomer?.placement}
Groups:{currentCustomer?.groups?.join(', ')}
Tags:{currentCustomer?.tags?.join(', ')}
Roles:{currentCustomer?.roles?.join(', ')}
*/} ); }; export default ViewCustomer;