Updated the profile of the Corporate user according to the client's instructions
This commit is contained in:
@@ -10,6 +10,8 @@ import axios from "axios";
|
|||||||
import {toast} from "react-toastify";
|
import {toast} from "react-toastify";
|
||||||
import {KeyedMutator} from "swr";
|
import {KeyedMutator} from "swr";
|
||||||
import CountrySelect from "./Low/CountrySelect";
|
import CountrySelect from "./Low/CountrySelect";
|
||||||
|
import GenderInput from "@/components/High/GenderInput";
|
||||||
|
import EmploymentStatusInput from "@/components/High/EmploymentStatusInput";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
user: User;
|
user: User;
|
||||||
@@ -92,73 +94,11 @@ export default function DemographicInformationInput({user, mutateUser}: Props) {
|
|||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="relative flex flex-col gap-3 w-full">
|
<GenderInput value={gender} onChange={setGender} />
|
||||||
<label className="font-normal text-base text-mti-gray-dim">Gender *</label>
|
|
||||||
<RadioGroup value={gender} onChange={setGender} className="flex flex-row justify-between">
|
|
||||||
<RadioGroup.Option value="male">
|
|
||||||
{({checked}) => (
|
|
||||||
<span
|
|
||||||
className={clsx(
|
|
||||||
"px-6 py-4 w-28 flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
|
||||||
"transition duration-300 ease-in-out",
|
|
||||||
!checked ? "bg-white border-mti-gray-platinum" : "bg-mti-purple-light border-mti-purple-dark text-white",
|
|
||||||
)}>
|
|
||||||
Male
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</RadioGroup.Option>
|
|
||||||
<RadioGroup.Option value="female">
|
|
||||||
{({checked}) => (
|
|
||||||
<span
|
|
||||||
className={clsx(
|
|
||||||
"px-6 py-4 w-28 flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
|
||||||
"transition duration-300 ease-in-out",
|
|
||||||
!checked ? "bg-white border-mti-gray-platinum" : "bg-mti-purple-light border-mti-purple-dark text-white",
|
|
||||||
)}>
|
|
||||||
Female
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</RadioGroup.Option>
|
|
||||||
<RadioGroup.Option value="other">
|
|
||||||
{({checked}) => (
|
|
||||||
<span
|
|
||||||
className={clsx(
|
|
||||||
"px-6 py-4 w-28 flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
|
||||||
"transition duration-300 ease-in-out",
|
|
||||||
!checked ? "bg-white border-mti-gray-platinum" : "bg-mti-purple-light border-mti-purple-dark text-white",
|
|
||||||
)}>
|
|
||||||
Other
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</RadioGroup.Option>
|
|
||||||
</RadioGroup>
|
|
||||||
</div>
|
|
||||||
{user.type === "corporate" && (
|
{user.type === "corporate" && (
|
||||||
<Input name="position" onChange={setPosition} type="text" label="Position" placeholder="CEO, Head of Marketing..." required />
|
<Input name="position" onChange={setPosition} type="text" label="Position" placeholder="CEO, Head of Marketing..." required />
|
||||||
)}
|
)}
|
||||||
{user.type !== "corporate" && (
|
{user.type !== "corporate" && <EmploymentStatusInput value={employment} onChange={setEmployment} />}
|
||||||
<div className="relative flex flex-col gap-3 w-full">
|
|
||||||
<label className="font-normal text-base text-mti-gray-dim">Employment Status *</label>
|
|
||||||
<RadioGroup value={employment} onChange={setEmployment} className="grid grid-cols-2 items-center gap-4 place-items-center">
|
|
||||||
{EMPLOYMENT_STATUS.map(({status, label}) => (
|
|
||||||
<RadioGroup.Option value={status} key={status}>
|
|
||||||
{({checked}) => (
|
|
||||||
<span
|
|
||||||
className={clsx(
|
|
||||||
"px-6 py-4 w-44 md:w-48 flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
|
||||||
"transition duration-300 ease-in-out",
|
|
||||||
!checked
|
|
||||||
? "bg-white border-mti-gray-platinum"
|
|
||||||
: "bg-mti-purple-light border-mti-purple-dark text-white",
|
|
||||||
)}>
|
|
||||||
{label}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</RadioGroup.Option>
|
|
||||||
))}
|
|
||||||
</RadioGroup>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div className="self-end flex justify-end w-full gap-8 absolute bottom-8 left-0 px-8">
|
<div className="self-end flex justify-end w-full gap-8 absolute bottom-8 left-0 px-8">
|
||||||
|
|||||||
32
src/components/High/EmploymentStatusInput.tsx
Normal file
32
src/components/High/EmploymentStatusInput.tsx
Normal file
@@ -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 (
|
||||||
|
<div className="relative flex flex-col gap-3 w-full">
|
||||||
|
<label className="font-normal text-base text-mti-gray-dim">Employment Status *</label>
|
||||||
|
<RadioGroup value={value} onChange={onChange} className="grid grid-cols-2 items-center gap-4 place-items-center">
|
||||||
|
{EMPLOYMENT_STATUS.map(({status, label}) => (
|
||||||
|
<RadioGroup.Option value={status} key={status}>
|
||||||
|
{({checked}) => (
|
||||||
|
<span
|
||||||
|
className={clsx(
|
||||||
|
"px-6 py-4 w-40 md:w-48 flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
||||||
|
"transition duration-300 ease-in-out",
|
||||||
|
!checked ? "bg-white border-mti-gray-platinum" : "bg-mti-purple-light border-mti-purple-dark text-white",
|
||||||
|
)}>
|
||||||
|
{label}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</RadioGroup.Option>
|
||||||
|
))}
|
||||||
|
</RadioGroup>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
54
src/components/High/GenderInput.tsx
Normal file
54
src/components/High/GenderInput.tsx
Normal file
@@ -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 (
|
||||||
|
<div className="relative flex flex-col gap-3 w-full">
|
||||||
|
<label className="font-normal text-base text-mti-gray-dim">Gender *</label>
|
||||||
|
<RadioGroup value={value} onChange={onChange} className="flex flex-row gap-4 justify-between">
|
||||||
|
<RadioGroup.Option value="male">
|
||||||
|
{({checked}) => (
|
||||||
|
<span
|
||||||
|
className={clsx(
|
||||||
|
"px-6 py-4 w-28 flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
||||||
|
"transition duration-300 ease-in-out",
|
||||||
|
!checked ? "bg-white border-mti-gray-platinum" : "bg-mti-purple-light border-mti-purple-dark text-white",
|
||||||
|
)}>
|
||||||
|
Male
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</RadioGroup.Option>
|
||||||
|
<RadioGroup.Option value="female">
|
||||||
|
{({checked}) => (
|
||||||
|
<span
|
||||||
|
className={clsx(
|
||||||
|
"px-6 py-4 w-28 flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
||||||
|
"transition duration-300 ease-in-out",
|
||||||
|
!checked ? "bg-white border-mti-gray-platinum" : "bg-mti-purple-light border-mti-purple-dark text-white",
|
||||||
|
)}>
|
||||||
|
Female
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</RadioGroup.Option>
|
||||||
|
<RadioGroup.Option value="other">
|
||||||
|
{({checked}) => (
|
||||||
|
<span
|
||||||
|
className={clsx(
|
||||||
|
"px-6 py-4 w-28 flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
||||||
|
"transition duration-300 ease-in-out",
|
||||||
|
!checked ? "bg-white border-mti-gray-platinum" : "bg-mti-purple-light border-mti-purple-dark text-white",
|
||||||
|
)}>
|
||||||
|
Other
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</RadioGroup.Option>
|
||||||
|
</RadioGroup>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import {withIronSessionSsr} from "iron-session/next";
|
import {withIronSessionSsr} from "iron-session/next";
|
||||||
import {sessionOptions} from "@/lib/session";
|
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 useUser from "@/hooks/useUser";
|
||||||
import {toast, ToastContainer} from "react-toastify";
|
import {toast, ToastContainer} from "react-toastify";
|
||||||
import Layout from "@/components/High/Layout";
|
import Layout from "@/components/High/Layout";
|
||||||
@@ -13,7 +13,7 @@ import axios from "axios";
|
|||||||
import {ErrorMessage} from "@/constants/errors";
|
import {ErrorMessage} from "@/constants/errors";
|
||||||
import {RadioGroup} from "@headlessui/react";
|
import {RadioGroup} from "@headlessui/react";
|
||||||
import clsx from "clsx";
|
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 CountrySelect from "@/components/Low/CountrySelect";
|
||||||
import {shouldRedirectHome} from "@/utils/navigation.disabled";
|
import {shouldRedirectHome} from "@/utils/navigation.disabled";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
@@ -21,6 +21,10 @@ import {BsCamera, BsCameraFill} from "react-icons/bs";
|
|||||||
import {USER_TYPE_LABELS} from "@/resources/user";
|
import {USER_TYPE_LABELS} from "@/resources/user";
|
||||||
import useGroups from "@/hooks/useGroups";
|
import useGroups from "@/hooks/useGroups";
|
||||||
import useUsers from "@/hooks/useUsers";
|
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}) => {
|
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||||
const user = req.session.user;
|
const user = req.session.user;
|
||||||
@@ -74,7 +78,14 @@ function UserProfile({user, mutateUser}: Props) {
|
|||||||
);
|
);
|
||||||
const [passport_id, setPassportID] = useState<string | undefined>(user.type === "student" ? user.demographicInformation?.passport_id : undefined);
|
const [passport_id, setPassportID] = useState<string | undefined>(user.type === "student" ? user.demographicInformation?.passport_id : undefined);
|
||||||
const [position, setPosition] = useState<string | undefined>(user.type === "corporate" ? user.demographicInformation?.position : undefined);
|
const [position, setPosition] = useState<string | undefined>(user.type === "corporate" ? user.demographicInformation?.position : undefined);
|
||||||
const [companyName, setCompanyName] = useState<string | undefined>(user.type === "agent" ? user.agentInformation?.companyName : undefined);
|
const [corporateInformation, setCorporateInformation] = useState(user.type === "corporate" ? user.corporateInformation : undefined);
|
||||||
|
const [companyName, setCompanyName] = useState<string | undefined>(
|
||||||
|
user.type === "agent"
|
||||||
|
? user.agentInformation?.companyName
|
||||||
|
: user.type === "corporate"
|
||||||
|
? user.corporateInformation?.companyInformation.name
|
||||||
|
: undefined,
|
||||||
|
);
|
||||||
const [commercialRegistration, setCommercialRegistration] = useState<string | undefined>(
|
const [commercialRegistration, setCommercialRegistration] = useState<string | undefined>(
|
||||||
user.type === "agent" ? user.agentInformation?.commercialRegistration : undefined,
|
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";
|
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<HTMLInputElement>) => {
|
const uploadProfilePicture = async (event: ChangeEvent<HTMLInputElement>) => {
|
||||||
if (event.target.files && event.target.files[0]) {
|
if (event.target.files && event.target.files[0]) {
|
||||||
const picture = event.target.files[0];
|
const picture = event.target.files[0];
|
||||||
@@ -155,6 +153,7 @@ function UserProfile({user, mutateUser}: Props) {
|
|||||||
gender,
|
gender,
|
||||||
passport_id,
|
passport_id,
|
||||||
},
|
},
|
||||||
|
...(user.type === "corporate" ? {corporateInformation} : {}),
|
||||||
});
|
});
|
||||||
if (request.status === 200) {
|
if (request.status === 200) {
|
||||||
toast.success("Your profile has been updated!");
|
toast.success("Your profile has been updated!");
|
||||||
@@ -167,6 +166,93 @@ function UserProfile({user, mutateUser}: Props) {
|
|||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const DoubleColumnRow = ({children}: {children: ReactNode}) => <div className="flex flex-col md:flex-row gap-8 w-full">{children}</div>;
|
||||||
|
|
||||||
|
const PasswordInput = () => (
|
||||||
|
<DoubleColumnRow>
|
||||||
|
<Input
|
||||||
|
label="Current Password"
|
||||||
|
type="password"
|
||||||
|
name="password"
|
||||||
|
onChange={(e) => setPassword(e)}
|
||||||
|
placeholder="Enter your password"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
label="New Password"
|
||||||
|
type="password"
|
||||||
|
name="newPassword"
|
||||||
|
onChange={(e) => setNewPassword(e)}
|
||||||
|
placeholder="Enter your new password (optional)"
|
||||||
|
/>
|
||||||
|
</DoubleColumnRow>
|
||||||
|
);
|
||||||
|
|
||||||
|
const NameInput = () => (
|
||||||
|
<Input label="Name" type="text" name="name" onChange={(e) => setName(e)} placeholder="Enter your name" defaultValue={name} required />
|
||||||
|
);
|
||||||
|
|
||||||
|
const AgentInformationInput = () => (
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 w-full">
|
||||||
|
<Input
|
||||||
|
label="Corporate Name"
|
||||||
|
type="text"
|
||||||
|
name="companyName"
|
||||||
|
onChange={() => null}
|
||||||
|
placeholder="Enter corporate name"
|
||||||
|
defaultValue={companyName}
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
label="Commercial Registration"
|
||||||
|
type="text"
|
||||||
|
name="commercialRegistration"
|
||||||
|
onChange={() => null}
|
||||||
|
placeholder="Enter commercial registration"
|
||||||
|
defaultValue={commercialRegistration}
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const CountryInput = () => (
|
||||||
|
<div className="flex flex-col gap-3 w-full">
|
||||||
|
<label className="font-normal text-base text-mti-gray-dim">Country *</label>
|
||||||
|
<CountrySelect value={country} onChange={setCountry} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const PhoneInput = () => (
|
||||||
|
<Input
|
||||||
|
type="tel"
|
||||||
|
name="phone"
|
||||||
|
label="Phone number"
|
||||||
|
onChange={(e) => setPhone(e)}
|
||||||
|
placeholder="Enter phone number"
|
||||||
|
defaultValue={phone}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const ExpirationDate = () => (
|
||||||
|
<div className="flex flex-col gap-3 w-full">
|
||||||
|
<label className="font-normal text-base text-mti-gray-dim">Expiry Date (click to purchase)</label>
|
||||||
|
<Link
|
||||||
|
href="/payment"
|
||||||
|
className={clsx(
|
||||||
|
"p-6 w-full flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
||||||
|
"transition duration-300 ease-in-out",
|
||||||
|
!user.subscriptionExpirationDate
|
||||||
|
? "!bg-mti-green-ultralight !border-mti-green-light"
|
||||||
|
: expirationDateColor(user.subscriptionExpirationDate),
|
||||||
|
"bg-white border-mti-gray-platinum",
|
||||||
|
)}>
|
||||||
|
{!user.subscriptionExpirationDate && "Unlimited"}
|
||||||
|
{user.subscriptionExpirationDate && moment(user.subscriptionExpirationDate).format("DD/MM/YYYY")}
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout user={user}>
|
<Layout user={user}>
|
||||||
<section className="w-full flex flex-col gap-4 md:gap-8 px-4 py-8">
|
<section className="w-full flex flex-col gap-4 md:gap-8 px-4 py-8">
|
||||||
@@ -175,16 +261,26 @@ function UserProfile({user, mutateUser}: Props) {
|
|||||||
<div className="flex flex-col gap-8 w-full md:w-2/3">
|
<div className="flex flex-col gap-8 w-full md:w-2/3">
|
||||||
<h1 className="text-4xl font-bold mb-6 -md:hidden">Edit Profile</h1>
|
<h1 className="text-4xl font-bold mb-6 -md:hidden">Edit Profile</h1>
|
||||||
<form className="flex flex-col items-center gap-6 w-full">
|
<form className="flex flex-col items-center gap-6 w-full">
|
||||||
<div className="flex flex-col md:flex-row gap-8 w-full">
|
<DoubleColumnRow>
|
||||||
<Input
|
{user.type !== "corporate" ? (
|
||||||
label="Name"
|
<NameInput />
|
||||||
type="text"
|
) : (
|
||||||
name="name"
|
<Input
|
||||||
onChange={(e) => setName(e)}
|
label="Company name"
|
||||||
placeholder="Enter your name"
|
type="text"
|
||||||
defaultValue={name}
|
name="name"
|
||||||
required
|
onChange={(e) =>
|
||||||
/>
|
setCorporateInformation((prev) => ({
|
||||||
|
...prev!,
|
||||||
|
companyInformation: {...prev!.companyInformation, name: e},
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
placeholder="Enter your company's name"
|
||||||
|
defaultValue={corporateInformation?.companyInformation.name}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
label="E-mail Address"
|
label="E-mail Address"
|
||||||
type="email"
|
type="email"
|
||||||
@@ -194,7 +290,9 @@ function UserProfile({user, mutateUser}: Props) {
|
|||||||
defaultValue={email}
|
defaultValue={email}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</DoubleColumnRow>
|
||||||
|
<PasswordInput />
|
||||||
|
|
||||||
{user.type === "student" && (
|
{user.type === "student" && (
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
@@ -206,166 +304,123 @@ function UserProfile({user, mutateUser}: Props) {
|
|||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="flex flex-col md:flex-row gap-8 w-full">
|
{user.type === "agent" && <AgentInformationInput />}
|
||||||
<Input
|
|
||||||
label="Current Password"
|
|
||||||
type="password"
|
|
||||||
name="password"
|
|
||||||
onChange={(e) => setPassword(e)}
|
|
||||||
placeholder="Enter your password"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
<Input
|
|
||||||
label="New Password"
|
|
||||||
type="password"
|
|
||||||
name="newPassword"
|
|
||||||
onChange={(e) => setNewPassword(e)}
|
|
||||||
placeholder="Enter your new password (optional)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{user.type === "agent" && (
|
<DoubleColumnRow>
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 w-full">
|
<CountryInput />
|
||||||
<Input
|
<PhoneInput />
|
||||||
label="Corporate Name"
|
</DoubleColumnRow>
|
||||||
type="text"
|
|
||||||
name="companyName"
|
<Divider />
|
||||||
onChange={() => null}
|
|
||||||
placeholder="Enter corporate name"
|
{user.type === "corporate" && (
|
||||||
defaultValue={companyName}
|
<>
|
||||||
disabled
|
<DoubleColumnRow>
|
||||||
/>
|
<Input
|
||||||
<Input
|
type="number"
|
||||||
label="Commercial Registration"
|
name="companyUsers"
|
||||||
type="text"
|
onChange={() => null}
|
||||||
name="commercialRegistration"
|
label="Number of users"
|
||||||
onChange={() => null}
|
defaultValue={user.corporateInformation.companyInformation.userAmount}
|
||||||
placeholder="Enter commercial registration"
|
disabled
|
||||||
defaultValue={commercialRegistration}
|
required
|
||||||
disabled
|
/>
|
||||||
/>
|
<Input
|
||||||
</div>
|
type="text"
|
||||||
|
name="pricing"
|
||||||
|
onChange={() => null}
|
||||||
|
label="Pricing"
|
||||||
|
defaultValue={`${user.corporateInformation.payment?.value} ${user.corporateInformation.payment?.currency}`}
|
||||||
|
disabled
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</DoubleColumnRow>
|
||||||
|
<ExpirationDate />
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="flex flex-col md:flex-row gap-8 w-full">
|
{user.type === "corporate" && (
|
||||||
<div className="flex flex-col gap-3 w-full">
|
<>
|
||||||
<label className="font-normal text-base text-mti-gray-dim">Country *</label>
|
<Divider />
|
||||||
<CountrySelect value={country} onChange={setCountry} />
|
<DoubleColumnRow>
|
||||||
</div>
|
<NameInput />
|
||||||
<Input
|
<Input
|
||||||
type="tel"
|
name="position"
|
||||||
name="phone"
|
onChange={setPosition}
|
||||||
label="Phone number"
|
defaultValue={position}
|
||||||
onChange={(e) => setPhone(e)}
|
type="text"
|
||||||
placeholder="Enter phone number"
|
label="Position"
|
||||||
defaultValue={phone}
|
placeholder="CEO, Head of Marketing..."
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</DoubleColumnRow>
|
||||||
<div className="flex flex-col md:flex-row gap-8 w-full">
|
</>
|
||||||
{user.type === "corporate" && (
|
)}
|
||||||
<Input
|
|
||||||
name="position"
|
{user.type === "corporate" && user.corporateInformation.referralAgent && (
|
||||||
onChange={setPosition}
|
<>
|
||||||
defaultValue={position}
|
<Divider />
|
||||||
type="text"
|
<DoubleColumnRow>
|
||||||
label="Position"
|
<Input
|
||||||
placeholder="CEO, Head of Marketing..."
|
name="agentName"
|
||||||
required
|
onChange={() => null}
|
||||||
/>
|
defaultValue={users.find((x) => x.id === user.corporateInformation.referralAgent)?.name}
|
||||||
)}
|
type="text"
|
||||||
{user.type !== "corporate" && (
|
label="Country Manager's Name"
|
||||||
<div className="relative flex flex-col gap-3 w-full">
|
placeholder="Not available"
|
||||||
<label className="font-normal text-base text-mti-gray-dim">Employment Status *</label>
|
required
|
||||||
<RadioGroup
|
disabled
|
||||||
value={employment}
|
/>
|
||||||
onChange={setEmployment}
|
<Input
|
||||||
className="grid grid-cols-2 items-center gap-4 place-items-center">
|
name="agentEmail"
|
||||||
{EMPLOYMENT_STATUS.map(({status, label}) => (
|
onChange={() => null}
|
||||||
<RadioGroup.Option value={status} key={status}>
|
defaultValue={users.find((x) => x.id === user.corporateInformation.referralAgent)?.email}
|
||||||
{({checked}) => (
|
type="text"
|
||||||
<span
|
label="Country Manager's E-mail"
|
||||||
className={clsx(
|
placeholder="Not available"
|
||||||
"px-6 py-4 w-40 md:w-48 flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
required
|
||||||
"transition duration-300 ease-in-out",
|
disabled
|
||||||
!checked
|
/>
|
||||||
? "bg-white border-mti-gray-platinum"
|
</DoubleColumnRow>
|
||||||
: "bg-mti-purple-light border-mti-purple-dark text-white",
|
<DoubleColumnRow>
|
||||||
)}>
|
<div className="flex flex-col gap-2 w-full">
|
||||||
{label}
|
<label className="font-normal text-base text-mti-gray-dim">Country Manager's Country *</label>
|
||||||
</span>
|
<CountrySelect
|
||||||
)}
|
value={
|
||||||
</RadioGroup.Option>
|
users.find((x) => x.id === user.corporateInformation.referralAgent)?.demographicInformation
|
||||||
))}
|
?.country
|
||||||
</RadioGroup>
|
}
|
||||||
|
onChange={() => null}
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
type="tel"
|
||||||
|
name="agentPhone"
|
||||||
|
label="Country Manager's Phone"
|
||||||
|
onChange={() => null}
|
||||||
|
placeholder="Not available"
|
||||||
|
defaultValue={
|
||||||
|
users.find((x) => x.id === user.corporateInformation.referralAgent)?.demographicInformation?.phone
|
||||||
|
}
|
||||||
|
disabled
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</DoubleColumnRow>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{user.type !== "corporate" && (
|
||||||
|
<DoubleColumnRow>
|
||||||
|
<EmploymentStatusInput value={employment} onChange={setEmployment} />
|
||||||
|
|
||||||
|
<div className="flex flex-col gap-8 w-full">
|
||||||
|
<GenderInput value={gender} onChange={setGender} />
|
||||||
|
<ExpirationDate />
|
||||||
</div>
|
</div>
|
||||||
)}
|
</DoubleColumnRow>
|
||||||
<div className="flex flex-col gap-8 w-full">
|
)}
|
||||||
<div className="relative flex flex-col gap-3 w-full">
|
|
||||||
<label className="font-normal text-base text-mti-gray-dim">Gender *</label>
|
|
||||||
<RadioGroup value={gender} onChange={setGender} className="flex flex-row gap-4 justify-between">
|
|
||||||
<RadioGroup.Option value="male">
|
|
||||||
{({checked}) => (
|
|
||||||
<span
|
|
||||||
className={clsx(
|
|
||||||
"px-6 py-4 w-28 flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
|
||||||
"transition duration-300 ease-in-out",
|
|
||||||
!checked
|
|
||||||
? "bg-white border-mti-gray-platinum"
|
|
||||||
: "bg-mti-purple-light border-mti-purple-dark text-white",
|
|
||||||
)}>
|
|
||||||
Male
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</RadioGroup.Option>
|
|
||||||
<RadioGroup.Option value="female">
|
|
||||||
{({checked}) => (
|
|
||||||
<span
|
|
||||||
className={clsx(
|
|
||||||
"px-6 py-4 w-28 flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
|
||||||
"transition duration-300 ease-in-out",
|
|
||||||
!checked
|
|
||||||
? "bg-white border-mti-gray-platinum"
|
|
||||||
: "bg-mti-purple-light border-mti-purple-dark text-white",
|
|
||||||
)}>
|
|
||||||
Female
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</RadioGroup.Option>
|
|
||||||
<RadioGroup.Option value="other">
|
|
||||||
{({checked}) => (
|
|
||||||
<span
|
|
||||||
className={clsx(
|
|
||||||
"px-6 py-4 w-28 flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
|
||||||
"transition duration-300 ease-in-out",
|
|
||||||
!checked
|
|
||||||
? "bg-white border-mti-gray-platinum"
|
|
||||||
: "bg-mti-purple-light border-mti-purple-dark text-white",
|
|
||||||
)}>
|
|
||||||
Other
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</RadioGroup.Option>
|
|
||||||
</RadioGroup>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-col gap-3">
|
|
||||||
<label className="font-normal text-base text-mti-gray-dim">Expiry Date (click to purchase)</label>
|
|
||||||
<Link
|
|
||||||
href="/payment"
|
|
||||||
className={clsx(
|
|
||||||
"p-6 w-full flex justify-center text-sm font-normal rounded-full border focus:outline-none cursor-pointer",
|
|
||||||
"transition duration-300 ease-in-out",
|
|
||||||
!user.subscriptionExpirationDate
|
|
||||||
? "!bg-mti-green-ultralight !border-mti-green-light"
|
|
||||||
: expirationDateColor(user.subscriptionExpirationDate),
|
|
||||||
"bg-white border-mti-gray-platinum",
|
|
||||||
)}>
|
|
||||||
{!user.subscriptionExpirationDate && "Unlimited"}
|
|
||||||
{user.subscriptionExpirationDate && moment(user.subscriptionExpirationDate).format("DD/MM/YYYY")}
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col gap-6 w-48">
|
<div className="flex flex-col gap-6 w-48">
|
||||||
|
|||||||
@@ -12,3 +12,16 @@ export function dateSorter(a: any, b: any, direction: "asc" | "desc", key: strin
|
|||||||
export function env(key: string) {
|
export function env(key: string) {
|
||||||
return (window as any).__ENV[key];
|
return (window as any).__ENV[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export 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);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user