diff --git a/src/components/ProfileCard.tsx b/src/components/ProfileCard.tsx deleted file mode 100644 index e0223bbf..00000000 --- a/src/components/ProfileCard.tsx +++ /dev/null @@ -1,31 +0,0 @@ -/* eslint-disable @next/next/no-img-element */ -import {User} from "@/interfaces/user"; -import clsx from "clsx"; -import LevelLabel from "./LevelLabel"; -import LevelProgressBar from "./LevelProgressBar"; -import {Avatar} from "primereact/avatar"; - -interface Props { - user: User; - className: string; -} - -export default function ProfileCard({user, className}: Props) { - return ( -
-
-
- {user.profilePicture.length > 0 && Profile picture} - {user.profilePicture.length === 0 && ( - - )} -
-
- {user.name} - -
-
- -
- ); -} diff --git a/src/components/ProfileLevel.tsx b/src/components/ProfileLevel.tsx deleted file mode 100644 index d1a5828f..00000000 --- a/src/components/ProfileLevel.tsx +++ /dev/null @@ -1,31 +0,0 @@ -/* eslint-disable @next/next/no-img-element */ -import {User} from "@/interfaces/user"; -import {levelCalculator} from "@/resources/level"; -import clsx from "clsx"; -import LevelLabel from "./LevelLabel"; -import LevelProgressBar from "./LevelProgressBar"; -import {Avatar} from "primereact/avatar"; - -interface Props { - user: User; - className?: string; -} - -export default function ProfileLevel({user, className}: Props) { - const levelResult = levelCalculator(user.experience); - - return ( -
-
- {user.profilePicture.length > 0 && Profile picture} - {user.profilePicture.length === 0 && ( - - )} -
-
- - -
-
- ); -} diff --git a/src/components/UserCard.tsx b/src/components/UserCard.tsx index 22e158cf..03ca5675 100644 --- a/src/components/UserCard.tsx +++ b/src/components/UserCard.tsx @@ -39,15 +39,16 @@ interface Props { const UserCard = ({user, loggedInUser, onClose, onViewStudents, onViewTeachers}: Props) => { const [expiryDate, setExpiryDate] = useState(user.subscriptionExpirationDate); - const [referralAgent, setReferralAgent] = useState(user.corporateInformation?.referralAgent); const [type, setType] = useState(user.type); const [status, setStatus] = useState(user.status); - const [companyName, setCompanyName] = useState(user.corporateInformation?.companyInformation.name); - const [userAmount, setUserAmount] = useState(user.corporateInformation?.companyInformation.userAmount); const [referralAgentLabel, setReferralAgentLabel] = useState(); - 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.
)}