From 9c8d7988c5743c8af4d86df7e43348eaba65f7d0 Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Wed, 6 Dec 2023 15:16:48 +0000 Subject: [PATCH 01/18] Changed Comercial labels to Corporate --- src/components/DemographicInformationInput.tsx | 8 ++++---- src/components/UserCard.tsx | 10 +++++----- src/pages/profile.tsx | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/DemographicInformationInput.tsx b/src/components/DemographicInformationInput.tsx index 222dc546..1f90ff21 100644 --- a/src/components/DemographicInformationInput.tsx +++ b/src/components/DemographicInformationInput.tsx @@ -24,7 +24,7 @@ export default function DemographicInformationInput({user, mutateUser}: Props) { const [position, setPosition] = useState(); const [isLoading, setIsLoading] = useState(false); - const [companyName, setCompanyName] = useState(); + const [corporateName, setCorporateName] = useState(); const [commercialRegistration, setCommercialRegistration] = useState(); const save = (e?: FormEvent) => { @@ -40,7 +40,7 @@ export default function DemographicInformationInput({user, mutateUser}: Props) { employment: user.type === "corporate" ? undefined : employment, position: user.type === "corporate" ? position : undefined, }, - agentInformation: user.type === "agent" ? {companyName, commercialRegistration} : undefined, + agentInformation: user.type === "agent" ? {corporateName, commercialRegistration} : undefined, }) .then((response) => mutateUser((response.data as {user: User}).user)) .catch(() => { @@ -62,7 +62,7 @@ export default function DemographicInformationInput({user, mutateUser}: Props) {
{user.type === "agent" && (
- + {!isLoading && "Save information"} {isLoading && ( diff --git a/src/components/UserCard.tsx b/src/components/UserCard.tsx index 682b32d8..f81302ac 100644 --- a/src/components/UserCard.tsx +++ b/src/components/UserCard.tsx @@ -146,11 +146,11 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, <>
@@ -159,7 +159,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, type="text" name="commercialRegistration" onChange={setCommercialRegistration} - placeholder="Enter company name" + placeholder="Enter commercial registration" defaultValue={commercialRegistration} required /> @@ -171,11 +171,11 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, <>
null} - placeholder="Enter company name" + placeholder="Enter corporate name" defaultValue={user.agentInformation.companyName} disabled /> @@ -227,7 +227,7 @@ export default function Home() { type="text" name="commercialRegistration" onChange={() => null} - placeholder="Enter company name" + placeholder="Enter commercial registration" defaultValue={user.agentInformation.commercialRegistration} disabled /> From f36384fdb447ecf2381336c1c26aae21dbd8e8dd Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Wed, 6 Dec 2023 15:43:44 +0000 Subject: [PATCH 02/18] Replaced Corporate Icon on Admin dashboard --- src/dashboards/Admin.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dashboards/Admin.tsx b/src/dashboards/Admin.tsx index 097bb968..f50ff99d 100644 --- a/src/dashboards/Admin.tsx +++ b/src/dashboards/Admin.tsx @@ -13,9 +13,8 @@ import { BsGlobeCentralSouthAsia, BsPerson, BsPersonFill, - BsPersonFillGear, - BsPersonGear, BsPersonLinesFill, + BsBank, } from "react-icons/bs"; import UserCard from "@/components/UserCard"; import useGroups from "@/hooks/useGroups"; @@ -207,7 +206,7 @@ export default function AdminDashboard({user}: Props) { color="purple" /> x.type === "corporate").length} onClick={() => setPage("corporate")} From 62b2f477f427bb7d0d1207e4d27bfedb8462e2ee Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Wed, 6 Dec 2023 15:54:49 +0000 Subject: [PATCH 03/18] Replaced Corporate Icon on Agent Dashboard --- src/dashboards/Agent.tsx | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/dashboards/Agent.tsx b/src/dashboards/Agent.tsx index f951f04e..4c4cd21e 100644 --- a/src/dashboards/Agent.tsx +++ b/src/dashboards/Agent.tsx @@ -9,17 +9,8 @@ import moment from "moment"; import {useEffect, useState} from "react"; import { BsArrowLeft, - BsClipboard2Data, - BsClipboard2DataFill, - BsClock, - BsGlobeCentralSouthAsia, - BsPaperclip, - BsPerson, - BsPersonAdd, BsPersonFill, - BsPersonFillGear, - BsPersonGear, - BsPersonLinesFill, + BsBank } from "react-icons/bs"; import UserCard from "@/components/UserCard"; import useGroups from "@/hooks/useGroups"; @@ -119,7 +110,7 @@ export default function AgentDashboard({user}: Props) { /> setPage("corporate")} - Icon={BsPersonFill} + Icon={BsBank} label="Corporate" value={users.filter(corporateFilter).length} color="purple" From 6f5dd86cd15312caf2c96a5351b67444af3492d8 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Thu, 7 Dec 2023 16:36:57 +0000 Subject: [PATCH 04/18] Updated so the new payment prefills with all of the corporate's payment information --- src/components/UserCard.tsx | 2 +- src/pages/payment-record.tsx | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/UserCard.tsx b/src/components/UserCard.tsx index 682b32d8..76e8a830 100644 --- a/src/components/UserCard.tsx +++ b/src/components/UserCard.tsx @@ -58,7 +58,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, ); 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); + const [paymentCurrency, setPaymentCurrency] = useState(user.type === "corporate" ? user.corporateInformation?.payment?.currency : "EUR"); const [monthlyDuration, setMonthlyDuration] = useState(user.type === "corporate" ? user.corporateInformation?.monthlyDuration : undefined); const {stats} = useStats(user.id); diff --git a/src/pages/payment-record.tsx b/src/pages/payment-record.tsx index ee58653b..70f094d7 100644 --- a/src/pages/payment-record.tsx +++ b/src/pages/payment-record.tsx @@ -75,6 +75,13 @@ const PaymentCreator = ({onClose, reload}: {onClose: () => void; reload: () => v setReferralAgent(referralAgent as AgentUser | undefined); }, [corporate, users]); + useEffect(() => { + const payment = corporate?.corporateInformation?.payment; + + setPrice(payment?.value || 0); + setCurrency(payment?.currency || "EUR"); + }, [corporate]); + const submit = () => { axios .post(`/api/payments`, { @@ -138,14 +145,15 @@ const PaymentCreator = ({onClose, reload}: {onClose: () => void; reload: () => v name="paymentValue" onChange={(e) => setPrice(e ? parseInt(e) : 0)} type="number" - defaultValue={0} + value={price} className="col-span-3" /> + {!isLoading && "Save information"} {isLoading && ( diff --git a/src/components/UserCard.tsx b/src/components/UserCard.tsx index f81302ac..682b32d8 100644 --- a/src/components/UserCard.tsx +++ b/src/components/UserCard.tsx @@ -146,11 +146,11 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, <>
@@ -159,7 +159,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, type="text" name="commercialRegistration" onChange={setCommercialRegistration} - placeholder="Enter commercial registration" + placeholder="Enter company name" defaultValue={commercialRegistration} required /> @@ -171,11 +171,11 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, <>
null} - placeholder="Enter corporate name" + placeholder="Enter company name" defaultValue={user.agentInformation.companyName} disabled /> @@ -227,7 +227,7 @@ export default function Home() { type="text" name="commercialRegistration" onChange={() => null} - placeholder="Enter commercial registration" + placeholder="Enter company name" defaultValue={user.agentInformation.commercialRegistration} disabled /> From 450a4e9fe385390b79e85c2603f909f9794f3467 Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Fri, 8 Dec 2023 15:43:19 +0000 Subject: [PATCH 18/18] Changed Comercial labels to Corporate --- src/components/DemographicInformationInput.tsx | 2 +- src/components/UserCard.tsx | 10 +++++----- src/pages/profile.tsx | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/DemographicInformationInput.tsx b/src/components/DemographicInformationInput.tsx index 222dc546..2468178e 100644 --- a/src/components/DemographicInformationInput.tsx +++ b/src/components/DemographicInformationInput.tsx @@ -62,7 +62,7 @@ export default function DemographicInformationInput({user, mutateUser}: Props) { {user.type === "agent" && (
- +
@@ -159,7 +159,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, type="text" name="commercialRegistration" onChange={setCommercialRegistration} - placeholder="Enter company name" + placeholder="Enter commercial registration" defaultValue={commercialRegistration} required /> @@ -171,11 +171,11 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers, <>
null} - placeholder="Enter company name" + placeholder="Enter corporate name" defaultValue={user.agentInformation.companyName} disabled /> @@ -227,7 +227,7 @@ export default function Home() { type="text" name="commercialRegistration" onChange={() => null} - placeholder="Enter company name" + placeholder="Enter commercial registration" defaultValue={user.agentInformation.commercialRegistration} disabled />