diff --git a/src/components/DemographicInformationInput.tsx b/src/components/DemographicInformationInput.tsx
index f8d67320..c97a4aef 100644
--- a/src/components/DemographicInformationInput.tsx
+++ b/src/components/DemographicInformationInput.tsx
@@ -10,6 +10,8 @@ import axios from "axios";
import {toast} from "react-toastify";
import {KeyedMutator} from "swr";
import CountrySelect from "./Low/CountrySelect";
+import GenderInput from "@/components/High/GenderInput";
+import EmploymentStatusInput from "@/components/High/EmploymentStatusInput";
interface Props {
user: User;
@@ -92,73 +94,11 @@ export default function DemographicInformationInput({user, mutateUser}: Props) {
required
/>
)}
-
diff --git a/src/components/High/EmploymentStatusInput.tsx b/src/components/High/EmploymentStatusInput.tsx
new file mode 100644
index 00000000..85fb0229
--- /dev/null
+++ b/src/components/High/EmploymentStatusInput.tsx
@@ -0,0 +1,32 @@
+import {EmploymentStatus, EMPLOYMENT_STATUS} from "@/interfaces/user";
+import {RadioGroup} from "@headlessui/react";
+import clsx from "clsx";
+
+interface Props {
+ value?: EmploymentStatus;
+ onChange: (value?: EmploymentStatus) => void;
+}
+
+export default function EmploymentStatusInput({value, onChange}: Props) {
+ return (
+
+
+
+ {EMPLOYMENT_STATUS.map(({status, label}) => (
+
+ {({checked}) => (
+
+ {label}
+
+ )}
+
+ ))}
+
+
+ );
+}
diff --git a/src/components/High/GenderInput.tsx b/src/components/High/GenderInput.tsx
new file mode 100644
index 00000000..0848d1bb
--- /dev/null
+++ b/src/components/High/GenderInput.tsx
@@ -0,0 +1,54 @@
+import {Gender} from "@/interfaces/user";
+import {RadioGroup} from "@headlessui/react";
+import clsx from "clsx";
+
+interface Props {
+ value?: Gender;
+ onChange: (value?: Gender) => void;
+}
+
+export default function GenderInput({value, onChange}: Props) {
+ return (
+
+
+
+
+ {({checked}) => (
+
+ Male
+
+ )}
+
+
+ {({checked}) => (
+
+ Female
+
+ )}
+
+
+ {({checked}) => (
+
+ Other
+
+ )}
+
+
+
+ );
+}
diff --git a/src/pages/profile.tsx b/src/pages/profile.tsx
index d71c355b..a71af678 100644
--- a/src/pages/profile.tsx
+++ b/src/pages/profile.tsx
@@ -2,7 +2,7 @@
import Head from "next/head";
import {withIronSessionSsr} from "iron-session/next";
import {sessionOptions} from "@/lib/session";
-import {ChangeEvent, useEffect, useRef, useState} from "react";
+import {ChangeEvent, ReactNode, useEffect, useRef, useState} from "react";
import useUser from "@/hooks/useUser";
import {toast, ToastContainer} from "react-toastify";
import Layout from "@/components/High/Layout";
@@ -13,7 +13,7 @@ import axios from "axios";
import {ErrorMessage} from "@/constants/errors";
import {RadioGroup} from "@headlessui/react";
import clsx from "clsx";
-import {EmploymentStatus, EMPLOYMENT_STATUS, Gender, User} from "@/interfaces/user";
+import {CorporateUser, EmploymentStatus, EMPLOYMENT_STATUS, Gender, User} from "@/interfaces/user";
import CountrySelect from "@/components/Low/CountrySelect";
import {shouldRedirectHome} from "@/utils/navigation.disabled";
import moment from "moment";
@@ -21,6 +21,10 @@ import {BsCamera, BsCameraFill} from "react-icons/bs";
import {USER_TYPE_LABELS} from "@/resources/user";
import useGroups from "@/hooks/useGroups";
import useUsers from "@/hooks/useUsers";
+import {convertBase64} from "@/utils";
+import {Divider} from "primereact/divider";
+import GenderInput from "@/components/High/GenderInput";
+import EmploymentStatusInput from "@/components/High/EmploymentStatusInput";
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
const user = req.session.user;
@@ -74,7 +78,14 @@ function UserProfile({user, mutateUser}: Props) {
);
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 [corporateInformation, setCorporateInformation] = useState(user.type === "corporate" ? user.corporateInformation : undefined);
+ const [companyName, setCompanyName] = useState(
+ user.type === "agent"
+ ? user.agentInformation?.companyName
+ : user.type === "corporate"
+ ? user.corporateInformation?.companyInformation.name
+ : undefined,
+ );
const [commercialRegistration, setCommercialRegistration] = useState(
user.type === "agent" ? user.agentInformation?.commercialRegistration : undefined,
);
@@ -92,19 +103,6 @@ function UserProfile({user, mutateUser}: Props) {
if (today.add(7, "days").isAfter(momentDate)) return "!bg-mti-orange-ultralight border-mti-orange-light";
};
- const convertBase64 = (file: File) => {
- return new Promise((resolve, reject) => {
- const fileReader = new FileReader();
- fileReader.readAsDataURL(file);
- fileReader.onload = () => {
- resolve(fileReader.result);
- };
- fileReader.onerror = (error) => {
- reject(error);
- };
- });
- };
-
const uploadProfilePicture = async (event: ChangeEvent) => {
if (event.target.files && event.target.files[0]) {
const picture = event.target.files[0];
@@ -155,6 +153,7 @@ function UserProfile({user, mutateUser}: Props) {
gender,
passport_id,
},
+ ...(user.type === "corporate" ? {corporateInformation} : {}),
});
if (request.status === 200) {
toast.success("Your profile has been updated!");
@@ -167,6 +166,93 @@ function UserProfile({user, mutateUser}: Props) {
setIsLoading(false);
};
+ const DoubleColumnRow = ({children}: {children: ReactNode}) => {children}
;
+
+ const PasswordInput = () => (
+
+ setPassword(e)}
+ placeholder="Enter your password"
+ required
+ />
+ setNewPassword(e)}
+ placeholder="Enter your new password (optional)"
+ />
+
+ );
+
+ const NameInput = () => (
+ setName(e)} placeholder="Enter your name" defaultValue={name} required />
+ );
+
+ const AgentInformationInput = () => (
+
+ null}
+ placeholder="Enter corporate name"
+ defaultValue={companyName}
+ disabled
+ />
+ null}
+ placeholder="Enter commercial registration"
+ defaultValue={commercialRegistration}
+ disabled
+ />
+
+ );
+
+ const CountryInput = () => (
+
+
+
+
+ );
+
+ const PhoneInput = () => (
+ setPhone(e)}
+ placeholder="Enter phone number"
+ defaultValue={phone}
+ required
+ />
+ );
+
+ const ExpirationDate = () => (
+
+
+
+ {!user.subscriptionExpirationDate && "Unlimited"}
+ {user.subscriptionExpirationDate && moment(user.subscriptionExpirationDate).format("DD/MM/YYYY")}
+
+
+ );
+
return (
@@ -175,16 +261,26 @@ function UserProfile({user, mutateUser}: Props) {