diff --git a/src/components/DemographicInformationInput.tsx b/src/components/DemographicInformationInput.tsx index 2468178e..d92a9e82 100644 --- a/src/components/DemographicInformationInput.tsx +++ b/src/components/DemographicInformationInput.tsx @@ -19,6 +19,7 @@ interface Props { export default function DemographicInformationInput({user, mutateUser}: Props) { const [country, setCountry] = useState(); const [phone, setPhone] = useState(); + const [passport_id, setPassportID] = useState(); const [gender, setGender] = useState(); const [employment, setEmployment] = useState(); const [position, setPosition] = useState(); @@ -39,6 +40,7 @@ export default function DemographicInformationInput({user, mutateUser}: Props) { gender, employment: user.type === "corporate" ? undefined : employment, position: user.type === "corporate" ? position : undefined, + passport_id, }, agentInformation: user.type === "agent" ? {companyName, commercialRegistration} : undefined, }) @@ -72,11 +74,23 @@ export default function DemographicInformationInput({user, mutateUser}: Props) { /> )} -
- - +
+
+ + +
+ setPhone(e)} placeholder="Enter phone number" required />
- setPhone(e)} placeholder="Enter phone number" required /> + {user.type === "student" && ( + setPassportID(e)} + placeholder="Enter National ID or Passport number" + required + /> + )}
diff --git a/src/components/UserCard.tsx b/src/components/UserCard.tsx index c7b0422e..712a4d3b 100644 --- a/src/components/UserCard.tsx +++ b/src/components/UserCard.tsx @@ -41,23 +41,25 @@ interface Props { const USER_STATUS_OPTIONS = [ { - value: 'active', - label: 'Active', - }, { - value: 'disabled', - label: 'Disabled', - }, { - value: 'paymentDue', - label: 'Payment Due', - } + value: "active", + label: "Active", + }, + { + value: "disabled", + label: "Disabled", + }, + { + value: "paymentDue", + label: "Payment Due", + }, ]; const USER_TYPE_OPTIONS = Object.keys(USER_TYPE_LABELS).map((type) => ({ value: type, - label: USER_TYPE_LABELS[type as keyof typeof USER_TYPE_LABELS] + label: USER_TYPE_LABELS[type as keyof typeof USER_TYPE_LABELS], })); -const CURRENCIES_OPTIONS = CURRENCIES.map(({ label, currency}) => ({ value: currency, label })); +const CURRENCIES_OPTIONS = CURRENCIES.map(({label, currency}) => ({value: currency, label})); const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, onViewCorporate, disabled = false}: Props) => { const [expiryDate, setExpiryDate] = useState(user.subscriptionExpirationDate); @@ -65,6 +67,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, const [status, setStatus] = useState(user.status); const [referralAgentLabel, setReferralAgentLabel] = useState(); const [position, setPosition] = useState(user.type === "corporate" ? user.demographicInformation?.position : undefined); + const [passport_id, setPassportID] = useState(user.type === "student" ? user.demographicInformation?.passport_id : undefined); const [referralAgent, setReferralAgent] = useState(user.type === "corporate" ? user.corporateInformation?.referralAgent : undefined); const [companyName, setCompanyName] = useState( @@ -352,6 +355,19 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, />
+ {user.type === "student" && ( + null} + placeholder="Enter National ID or Passport number" + value={user.type === "student" ? user.demographicInformation?.passport_id : undefined} + disabled + required + /> + )} +
{user.type !== "corporate" && (
@@ -397,8 +413,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, + disabled={disabled}> {({checked}) => ( setExpiryDate(checked ? user.subscriptionExpirationDate || new Date() : null)} - disabled={disabled} - > + disabled={disabled}> Enabled
diff --git a/src/interfaces/user.ts b/src/interfaces/user.ts index c7b0efff..4a390a3f 100644 --- a/src/interfaces/user.ts +++ b/src/interfaces/user.ts @@ -77,6 +77,7 @@ export interface DemographicInformation { phone: string; gender: Gender; employment: EmploymentStatus; + passport_id?: string; } export interface DemographicCorporateInformation { diff --git a/src/pages/profile.tsx b/src/pages/profile.tsx index f81a0fc3..d71c355b 100644 --- a/src/pages/profile.tsx +++ b/src/pages/profile.tsx @@ -72,6 +72,7 @@ function UserProfile({user, mutateUser}: Props) { const [employment, setEmployment] = useState( user.type === "corporate" ? undefined : user.demographicInformation?.employment, ); + const [passport_id, setPassportID] = useState(user.type === "student" ? user.demographicInformation?.passport_id : undefined); const [position, setPosition] = useState(user.type === "corporate" ? user.demographicInformation?.position : undefined); const [companyName, setCompanyName] = useState(user.type === "agent" ? user.agentInformation?.companyName : undefined); const [commercialRegistration, setCommercialRegistration] = useState( @@ -152,6 +153,7 @@ function UserProfile({user, mutateUser}: Props) { employment: user?.type === "corporate" ? undefined : employment, position: user?.type === "corporate" ? position : undefined, gender, + passport_id, }, }); if (request.status === 200) { @@ -193,6 +195,17 @@ function UserProfile({user, mutateUser}: Props) { required />
+ {user.type === "student" && ( + setPassportID(e)} + placeholder="Enter National ID or Passport number" + value={passport_id} + required + /> + )}