Updated from companyName to name
This commit is contained in:
@@ -48,7 +48,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers,
|
|||||||
const [referralAgent, setReferralAgent] = useState(user.type === "corporate" ? user.corporateInformation?.referralAgent : undefined);
|
const [referralAgent, setReferralAgent] = useState(user.type === "corporate" ? user.corporateInformation?.referralAgent : undefined);
|
||||||
const [companyName, setCompanyName] = useState(
|
const [companyName, setCompanyName] = useState(
|
||||||
user.type === "corporate"
|
user.type === "corporate"
|
||||||
? user.corporateInformation?.companyInformation.companyName
|
? user.corporateInformation?.companyInformation.name
|
||||||
: user.type === "agent"
|
: user.type === "agent"
|
||||||
? user.agentInformation.companyName
|
? user.agentInformation.companyName
|
||||||
: undefined,
|
: undefined,
|
||||||
@@ -90,7 +90,7 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers,
|
|||||||
agentInformation:
|
agentInformation:
|
||||||
type === "agent"
|
type === "agent"
|
||||||
? {
|
? {
|
||||||
companyName,
|
name: companyName,
|
||||||
commercialRegistration,
|
commercialRegistration,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
@@ -100,13 +100,13 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers,
|
|||||||
referralAgent,
|
referralAgent,
|
||||||
monthlyDuration,
|
monthlyDuration,
|
||||||
companyInformation: {
|
companyInformation: {
|
||||||
companyName,
|
name: companyName,
|
||||||
userAmount,
|
userAmount,
|
||||||
},
|
},
|
||||||
payment: {
|
payment: {
|
||||||
value: paymentValue,
|
value: paymentValue,
|
||||||
currency: paymentCurrency,
|
currency: paymentCurrency,
|
||||||
...referralAgent === '' ? {} : { commission: commissionValue }
|
...(referralAgent === "" ? {} : {commission: commissionValue}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
@@ -219,54 +219,56 @@ const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers,
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-3 w-full">
|
<div className="flex gap-3 w-full">
|
||||||
<div className="flex flex-col gap-3 w-8/12">
|
<div className="flex flex-col gap-3 w-8/12">
|
||||||
<label className="font-normal text-base text-mti-gray-dim">Country Manager</label>
|
<label className="font-normal text-base text-mti-gray-dim">Country Manager</label>
|
||||||
{referralAgentLabel && (
|
{referralAgentLabel && (
|
||||||
<Select
|
<Select
|
||||||
className="px-4 py-4 w-full text-sm font-normal placeholder:text-mti-gray-cool disabled:bg-mti-gray-platinum/40 disabled:text-mti-gray-dim disabled:cursor-not-allowed bg-white rounded-full border border-mti-gray-platinum focus:outline-none"
|
className="px-4 py-4 w-full text-sm font-normal placeholder:text-mti-gray-cool disabled:bg-mti-gray-platinum/40 disabled:text-mti-gray-dim disabled:cursor-not-allowed bg-white rounded-full border border-mti-gray-platinum focus:outline-none"
|
||||||
options={[
|
options={[
|
||||||
{value: "", label: "No referral"},
|
{value: "", label: "No referral"},
|
||||||
...users.filter((u) => u.type === "agent").map((x) => ({value: x.id, label: `${x.name} - ${x.email}`})),
|
...users.filter((u) => u.type === "agent").map((x) => ({value: x.id, label: `${x.name} - ${x.email}`})),
|
||||||
]}
|
]}
|
||||||
defaultValue={{
|
defaultValue={{
|
||||||
value: referralAgent,
|
value: referralAgent,
|
||||||
label: referralAgentLabel,
|
label: referralAgentLabel,
|
||||||
}}
|
}}
|
||||||
onChange={(value) => setReferralAgent(value?.value)}
|
onChange={(value) => setReferralAgent(value?.value)}
|
||||||
styles={{
|
styles={{
|
||||||
control: (styles) => ({
|
control: (styles) => ({
|
||||||
...styles,
|
...styles,
|
||||||
paddingLeft: "4px",
|
paddingLeft: "4px",
|
||||||
border: "none",
|
border: "none",
|
||||||
|
outline: "none",
|
||||||
|
":focus": {
|
||||||
outline: "none",
|
outline: "none",
|
||||||
":focus": {
|
},
|
||||||
outline: "none",
|
}),
|
||||||
},
|
option: (styles, state) => ({
|
||||||
}),
|
...styles,
|
||||||
option: (styles, state) => ({
|
backgroundColor: state.isFocused ? "#D5D9F0" : state.isSelected ? "#7872BF" : "white",
|
||||||
...styles,
|
color: state.isFocused ? "black" : styles.color,
|
||||||
backgroundColor: state.isFocused ? "#D5D9F0" : state.isSelected ? "#7872BF" : "white",
|
}),
|
||||||
color: state.isFocused ? "black" : styles.color,
|
}}
|
||||||
}),
|
/>
|
||||||
}}
|
)}
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-col gap-3 w-4/12">
|
|
||||||
{referralAgent !== '' ? (
|
|
||||||
<>
|
|
||||||
<label className="font-normal text-base text-mti-gray-dim">Commission</label>
|
|
||||||
<Input
|
|
||||||
name="commissionValue"
|
|
||||||
onChange={(e) => setCommission(e ? parseInt(e) : undefined)}
|
|
||||||
type="number"
|
|
||||||
defaultValue={commissionValue || 0}
|
|
||||||
className="col-span-3"
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
) : <div />}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex flex-col gap-3 w-4/12">
|
||||||
|
{referralAgent !== "" ? (
|
||||||
|
<>
|
||||||
|
<label className="font-normal text-base text-mti-gray-dim">Commission</label>
|
||||||
|
<Input
|
||||||
|
name="commissionValue"
|
||||||
|
onChange={(e) => setCommission(e ? parseInt(e) : undefined)}
|
||||||
|
type="number"
|
||||||
|
defaultValue={commissionValue || 0}
|
||||||
|
className="col-span-3"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<div />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<Divider className="w-full !m-0" />
|
<Divider className="w-full !m-0" />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export default function AdminDashboard({user}: Props) {
|
|||||||
<div className="flex flex-col gap-1 items-start">
|
<div className="flex flex-col gap-1 items-start">
|
||||||
<span>
|
<span>
|
||||||
{displayUser.type === "corporate"
|
{displayUser.type === "corporate"
|
||||||
? displayUser.corporateInformation?.companyInformation?.companyName || displayUser.name
|
? displayUser.corporateInformation?.companyInformation?.name || displayUser.name
|
||||||
: displayUser.name}
|
: displayUser.name}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-sm opacity-75">{displayUser.email}</span>
|
<span className="text-sm opacity-75">{displayUser.email}</span>
|
||||||
|
|||||||
@@ -7,11 +7,7 @@ import UserList from "@/pages/(admin)/Lists/UserList";
|
|||||||
import {dateSorter} from "@/utils";
|
import {dateSorter} from "@/utils";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import {
|
import {BsArrowLeft, BsPersonFill, BsBank} from "react-icons/bs";
|
||||||
BsArrowLeft,
|
|
||||||
BsPersonFill,
|
|
||||||
BsBank
|
|
||||||
} from "react-icons/bs";
|
|
||||||
import UserCard from "@/components/UserCard";
|
import UserCard from "@/components/UserCard";
|
||||||
import useGroups from "@/hooks/useGroups";
|
import useGroups from "@/hooks/useGroups";
|
||||||
import {calculateAverageLevel, calculateBandScore} from "@/utils/score";
|
import {calculateAverageLevel, calculateBandScore} from "@/utils/score";
|
||||||
@@ -41,7 +37,8 @@ export default function AgentDashboard({user}: Props) {
|
|||||||
const corporateFilter = (user: User) => user.type === "corporate";
|
const corporateFilter = (user: User) => user.type === "corporate";
|
||||||
const referredCorporateFilter = (x: User) =>
|
const referredCorporateFilter = (x: User) =>
|
||||||
x.type === "corporate" && !!x.corporateInformation && x.corporateInformation.referralAgent === user.id;
|
x.type === "corporate" && !!x.corporateInformation && x.corporateInformation.referralAgent === user.id;
|
||||||
const inactiveReferredCorporateFilter = (x: User) => referredCorporateFilter(x) && (x.status === "disabled" || moment().isAfter(x.subscriptionExpirationDate));
|
const inactiveReferredCorporateFilter = (x: User) =>
|
||||||
|
referredCorporateFilter(x) && (x.status === "disabled" || moment().isAfter(x.subscriptionExpirationDate));
|
||||||
|
|
||||||
const UserDisplay = (displayUser: User) => (
|
const UserDisplay = (displayUser: User) => (
|
||||||
<div
|
<div
|
||||||
@@ -51,7 +48,7 @@ export default function AgentDashboard({user}: Props) {
|
|||||||
<div className="flex flex-col gap-1 items-start">
|
<div className="flex flex-col gap-1 items-start">
|
||||||
<span>
|
<span>
|
||||||
{displayUser.type === "corporate"
|
{displayUser.type === "corporate"
|
||||||
? displayUser.corporateInformation?.companyInformation?.companyName || displayUser.name
|
? displayUser.corporateInformation?.companyInformation?.name || displayUser.name
|
||||||
: displayUser.name}
|
: displayUser.name}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-sm opacity-75">{displayUser.email}</span>
|
<span className="text-sm opacity-75">{displayUser.email}</span>
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export interface AgentInformation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface CompanyInformation {
|
export interface CompanyInformation {
|
||||||
companyName: string;
|
name: string;
|
||||||
userAmount: number;
|
userAmount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ export default function UserList({user, filters = []}: {user: User; filters?: ((
|
|||||||
"underline text-mti-purple-light hover:text-mti-purple-dark transition ease-in-out duration-300 cursor-pointer",
|
"underline text-mti-purple-light hover:text-mti-purple-dark transition ease-in-out duration-300 cursor-pointer",
|
||||||
)}
|
)}
|
||||||
onClick={() => (PERMISSIONS.updateExpiryDate[row.original.type].includes(user.type) ? setSelectedUser(row.original) : null)}>
|
onClick={() => (PERMISSIONS.updateExpiryDate[row.original.type].includes(user.type) ? setSelectedUser(row.original) : null)}>
|
||||||
{row.original.type === "corporate" ? row.original.corporateInformation?.companyInformation?.companyName || getValue() : getValue()}
|
{row.original.type === "corporate" ? row.original.corporateInformation?.companyInformation?.name || getValue() : getValue()}
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import Input from "@/components/Low/Input";
|
|||||||
import ReactDatePicker from "react-datepicker";
|
import ReactDatePicker from "react-datepicker";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import PaymentAssetManager from "@/components/PaymentAssetManager";
|
import PaymentAssetManager from "@/components/PaymentAssetManager";
|
||||||
import { toFixedNumber } from "@/utils/number";
|
import {toFixedNumber} from "@/utils/number";
|
||||||
|
|
||||||
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||||
const user = req.session.user;
|
const user = req.session.user;
|
||||||
@@ -59,7 +59,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
|||||||
|
|
||||||
const columnHelper = createColumnHelper<Payment>();
|
const columnHelper = createColumnHelper<Payment>();
|
||||||
|
|
||||||
const PaymentCreator = ({onClose, reload, showComission = false}: {onClose: () => void; reload: () => void, showComission: boolean}) => {
|
const PaymentCreator = ({onClose, reload, showComission = false}: {onClose: () => void; reload: () => void; showComission: boolean}) => {
|
||||||
const [corporate, setCorporate] = useState<CorporateUser>();
|
const [corporate, setCorporate] = useState<CorporateUser>();
|
||||||
const [price, setPrice] = useState<number>(0);
|
const [price, setPrice] = useState<number>(0);
|
||||||
const [currency, setCurrency] = useState<string>("EUR");
|
const [currency, setCurrency] = useState<string>("EUR");
|
||||||
@@ -117,7 +117,7 @@ const PaymentCreator = ({onClose, reload, showComission = false}: {onClose: () =
|
|||||||
options={(users.filter((u) => u.type === "corporate") as CorporateUser[]).map((user) => ({
|
options={(users.filter((u) => u.type === "corporate") as CorporateUser[]).map((user) => ({
|
||||||
value: user.id,
|
value: user.id,
|
||||||
meta: user,
|
meta: user,
|
||||||
label: `${user.corporateInformation.companyInformation.companyName || user.name} - ${user.email}`,
|
label: `${user.corporateInformation.companyInformation.name || user.name} - ${user.email}`,
|
||||||
}))}
|
}))}
|
||||||
defaultValue={{value: "undefined", label: "Select an account"}}
|
defaultValue={{value: "undefined", label: "Select an account"}}
|
||||||
onChange={(value) => setCorporate((value as any)?.meta ?? undefined)}
|
onChange={(value) => setCorporate((value as any)?.meta ?? undefined)}
|
||||||
@@ -420,9 +420,11 @@ export default function PaymentRecord() {
|
|||||||
const user = users.find((x) => x.id === info.row.original.corporate) as CorporateUser;
|
const user = users.find((x) => x.id === info.row.original.corporate) as CorporateUser;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={clsx("underline text-mti-purple-light hover:text-mti-purple-dark transition ease-in-out duration-300 cursor-pointer")}
|
className={clsx(
|
||||||
|
"underline text-mti-purple-light hover:text-mti-purple-dark transition ease-in-out duration-300 cursor-pointer",
|
||||||
|
)}
|
||||||
onClick={() => setSelectedUser(user)}>
|
onClick={() => setSelectedUser(user)}>
|
||||||
{user?.corporateInformation.companyInformation.companyName || user?.name}
|
{user?.corporateInformation.companyInformation.name || user?.name}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -551,7 +553,7 @@ export default function PaymentRecord() {
|
|||||||
options={(users.filter((u) => u.type === "corporate") as CorporateUser[]).map((user) => ({
|
options={(users.filter((u) => u.type === "corporate") as CorporateUser[]).map((user) => ({
|
||||||
value: user.id,
|
value: user.id,
|
||||||
meta: user,
|
meta: user,
|
||||||
label: `${user.corporateInformation.companyInformation.companyName || user.name} - ${user.email}`,
|
label: `${user.corporateInformation.companyInformation.name || user.name} - ${user.email}`,
|
||||||
}))}
|
}))}
|
||||||
onChange={(value) => setCorporate((value as any)?.meta ?? undefined)}
|
onChange={(value) => setCorporate((value as any)?.meta ?? undefined)}
|
||||||
styles={{
|
styles={{
|
||||||
|
|||||||
Reference in New Issue
Block a user