();
- const [paymentValue, setPaymentValue] = useState(user.corporateInformation?.payment?.value);
- const [paymentCurrency, setPaymentCurrency] = useState(user.corporateInformation?.payment?.currency);
- const [monthlyDuration, setMonthlyDuration] = useState(user.corporateInformation?.monthlyDuration);
+
+ const [referralAgent, setReferralAgent] = useState(user.type === "corporate" ? user.corporateInformation?.referralAgent : undefined);
+ const [companyName, setCompanyName] = useState(user.type === "corporate" ? user.corporateInformation?.companyInformation.name : 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);
+ const [monthlyDuration, setMonthlyDuration] = useState(user.type === "corporate" ? user.corporateInformation?.monthlyDuration : undefined);
const {stats} = useStats(user.id);
const {users} = useUsers();
diff --git a/src/interfaces/user.ts b/src/interfaces/user.ts
index 2e832a33..3e223fca 100644
--- a/src/interfaces/user.ts
+++ b/src/interfaces/user.ts
@@ -1,11 +1,12 @@
import {Module} from ".";
-export interface User {
+export type User = StudentUser | TeacherUser | CorporateUser | AgentUser | AdminUser | DeveloperUser;
+
+export interface BasicUser {
email: string;
name: string;
profilePicture: string;
id: string;
- experience: number;
isFirstLogin: boolean;
focus: "academic" | "general";
levels: {[key in Module]: number};
@@ -14,12 +15,37 @@ export interface User {
bio: string;
isVerified: boolean;
demographicInformation?: DemographicInformation;
- corporateInformation?: CorporateInformation;
subscriptionExpirationDate?: null | Date;
registrationDate?: Date;
status: "active" | "disabled" | "paymentDue";
}
+export interface StudentUser extends BasicUser {
+ type: "student";
+}
+
+export interface TeacherUser extends BasicUser {
+ type: "teacher";
+}
+
+export interface CorporateUser extends BasicUser {
+ type: "corporate";
+ corporateInformation: CorporateInformation;
+}
+
+export interface AgentUser extends BasicUser {
+ type: "agent";
+ agentInformation: AgentInformation;
+}
+
+export interface AdminUser extends BasicUser {
+ type: "admin";
+}
+
+export interface DeveloperUser extends BasicUser {
+ type: "developer";
+}
+
export interface CorporateInformation {
companyInformation: CompanyInformation;
monthlyDuration: number;
@@ -30,6 +56,11 @@ export interface CorporateInformation {
referralAgent?: string;
}
+export interface AgentInformation {
+ companyName: string;
+ commercialRegistration: string;
+}
+
export interface CompanyInformation {
name: string;
userAmount: number;
diff --git a/src/pages/(status)/PaymentDue.tsx b/src/pages/(status)/PaymentDue.tsx
index 7b5e8677..ef3271ce 100644
--- a/src/pages/(status)/PaymentDue.tsx
+++ b/src/pages/(status)/PaymentDue.tsx
@@ -94,7 +94,7 @@ export default function PaymentDue({user, hasExpired = false, clientID, reload}:
)}
- {!isIndividual() && user?.corporateInformation && user?.corporateInformation.payment && (
+ {!isIndividual() && user.type === "corporate" && user?.corporateInformation.payment && (
To add to your use of EnCoach and that of your students and teachers, please pay your designated package below:
@@ -138,14 +138,25 @@ export default function PaymentDue({user, hasExpired = false, clientID, reload}:
)}
- {!isIndividual() && (!user?.corporateInformation || !user?.corporateInformation?.payment) && (
+ {!isIndividual() && user.type !== "corporate" && (
+
+
+ You are not the person in charge of your time credits, please contact your administrator about this situation.
+
+
+ If you believe this to be a mistake, please contact the platform's administration, thank you for your
+ patience.
+
+
+ )}
+ {!isIndividual() && user.type === "corporate" && !user.corporateInformation.payment && (
An admin nor your agent have yet set the price intended to your requirements in terms of the amount of users you
desire and your expected monthly duration.
- Please try again again later or contact your agent or an admin, thank you for your patience.
+ Please try again later or contact your agent or an admin, thank you for your patience.
)}