diff --git a/src/components/DemographicInformationInput.tsx b/src/components/DemographicInformationInput.tsx index e138903a..dcbe16bf 100644 --- a/src/components/DemographicInformationInput.tsx +++ b/src/components/DemographicInformationInput.tsx @@ -12,16 +12,20 @@ import {KeyedMutator} from "swr"; import CountrySelect from "./Low/CountrySelect"; interface Props { + user: User; mutateUser: KeyedMutator; } -export default function DemographicInformationInput({mutateUser}: Props) { +export default function DemographicInformationInput({user, mutateUser}: Props) { const [country, setCountry] = useState(); const [phone, setPhone] = useState(); const [gender, setGender] = useState(); const [employment, setEmployment] = useState(); const [isLoading, setIsLoading] = useState(false); + const [companyName, setCompanyName] = useState(); + const [commercialRegistration, setCommercialRegistration] = useState(); + const save = (e?: FormEvent) => { if (e) e.preventDefault(); setIsLoading(true); @@ -34,6 +38,7 @@ export default function DemographicInformationInput({mutateUser}: Props) { gender, employment, }, + agentInformation: user.type === "agent" ? {companyName, commercialRegistration} : undefined, }) .then((response) => mutateUser((response.data as {user: User}).user)) .catch(() => { @@ -53,6 +58,18 @@ export default function DemographicInformationInput({mutateUser}: Props) { about yourself.
+ {user.type === "agent" && ( +
+ + +
+ )}
@@ -125,7 +142,14 @@ export default function DemographicInformationInput({mutateUser}: Props) { className="lg:mt-8 max-w-[400px] w-full self-end" color="purple" onClick={save} - disabled={isLoading || !country || !phone || !gender || !employment}> + disabled={ + isLoading || + !country || + !phone || + !gender || + !employment || + (user.type === "agent" ? !companyName || !commercialRegistration : false) + }> {!isLoading && "Save information"} {isLoading && (
diff --git a/src/components/UserCard.tsx b/src/components/UserCard.tsx index 03ca5675..d1cb6209 100644 --- a/src/components/UserCard.tsx +++ b/src/components/UserCard.tsx @@ -44,7 +44,16 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers}: const [referralAgentLabel, setReferralAgentLabel] = useState(); const [referralAgent, setReferralAgent] = useState(user.type === "corporate" ? user.corporateInformation?.referralAgent : undefined); - const [companyName, setCompanyName] = useState(user.type === "corporate" ? user.corporateInformation?.companyInformation.name : undefined); + const [companyName, setCompanyName] = useState( + user.type === "corporate" + ? user.corporateInformation?.companyInformation.name + : user.type === "agent" + ? user.agentInformation.companyName + : undefined, + ); + const [commercialRegistration, setCommercialRegistration] = useState( + user.type === "agent" ? user.agentInformation.commercialRegistration : undefined, + ); const [userAmount, setUserAmount] = useState(user.type === "corporate" ? user.corporateInformation?.companyInformation.userAmount : undefined); const [paymentValue, setPaymentValue] = useState(user.type === "corporate" ? user.corporateInformation?.payment?.value : undefined); const [paymentCurrency, setPaymentCurrency] = useState(user.type === "corporate" ? user.corporateInformation?.payment?.currency : undefined); @@ -76,6 +85,13 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers}: subscriptionExpirationDate: expiryDate, type, status, + agentInformation: + type === "agent" + ? { + companyName, + commercialRegistration, + } + : undefined, corporateInformation: type === "corporate" ? { @@ -124,6 +140,31 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers}: ]} /> + {user.type === "agent" && ( + <> +
+ + +
+ + + )} {user.type === "corporate" && ( <>
@@ -209,7 +250,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers}:
- + )}
@@ -367,7 +408,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers}: {(loggedInUser.type === "developer" || loggedInUser.type === "admin") && ( <> - +
diff --git a/src/dashboards/Admin.tsx b/src/dashboards/Admin.tsx index a0737f76..784c6d9e 100644 --- a/src/dashboards/Admin.tsx +++ b/src/dashboards/Admin.tsx @@ -7,7 +7,16 @@ import UserList from "@/pages/(admin)/Lists/UserList"; import {dateSorter} from "@/utils"; import moment from "moment"; import {useEffect, useState} from "react"; -import {BsArrowLeft, BsGlobeCentralSouthAsia, BsPerson, BsPersonFill, BsPersonFillGear, BsPersonGear, BsPersonLinesFill} from "react-icons/bs"; +import { + BsArrowLeft, + BsBriefcaseFill, + BsGlobeCentralSouthAsia, + BsPerson, + BsPersonFill, + BsPersonFillGear, + BsPersonGear, + BsPersonLinesFill, +} from "react-icons/bs"; import UserCard from "@/components/UserCard"; import useGroups from "@/hooks/useGroups"; import IconCard from "./IconCard"; @@ -95,6 +104,26 @@ export default function AdminDashboard({user}: Props) { ); }; + const AgentsList = () => { + const filter = (x: User) => x.type === "agent"; + + return ( + <> +
+
setPage("")} + className="flex gap-2 items-center text-mti-purple-light cursor-pointer hover:text-mti-purple-dark transition ease-in-out duration-300"> + + Back +
+

Country Managers ({users.filter(filter).length})

+
+ + + + ); + }; + const CorporateList = () => ( <>
@@ -175,6 +204,13 @@ export default function AdminDashboard({user}: Props) { onClick={() => setPage("corporate")} color="purple" /> + x.type === "agent").length} + onClick={() => setPage("agents")} + color="purple" + /> } {page === "teachers" && } {page === "corporate" && } + {page === "agents" && } {page === "inactiveStudents" && } {page === "inactiveCorporate" && } {page === "" && } diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 39671a87..bc6d44af 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -127,7 +127,7 @@ export default function Home({envVariables}: {envVariables: {[key: string]: stri - + ); diff --git a/src/pages/profile.tsx b/src/pages/profile.tsx index dbb545cd..c41248d9 100644 --- a/src/pages/profile.tsx +++ b/src/pages/profile.tsx @@ -208,6 +208,29 @@ export default function Home() { />
+ {user.type === "agent" && ( +
+ null} + placeholder="Enter company name" + defaultValue={user.agentInformation.companyName} + disabled + /> + null} + placeholder="Enter company name" + defaultValue={user.agentInformation.commercialRegistration} + disabled + /> +
+ )} +