/* eslint-disable @next/next/no-img-element */ import Layout from "@/components/High/Layout"; import PayPalPayment from "@/components/PayPalPayment"; import useGroups from "@/hooks/useGroups"; import usePackages from "@/hooks/usePackages"; import useUsers from "@/hooks/useUsers"; import {User} from "@/interfaces/user"; import clsx from "clsx"; import {capitalize} from "lodash"; import {useState} from "react"; import getSymbolFromCurrency from "currency-symbol-map"; interface Props { user: User; hasExpired?: boolean; clientID: string; reload: () => void; } export default function PaymentDue({user, hasExpired = false, clientID, reload}: Props) { const [isLoading, setIsLoading] = useState(false); const {packages} = usePackages(); const {users} = useUsers(); const {groups} = useGroups(); const isIndividual = () => { if (user?.type === "developer") return true; if (user?.type !== "student") return false; const userGroups = groups.filter((g) => g.participants.includes(user?.id)); if (userGroups.length === 0) return true; const userGroupsAdminTypes = userGroups.map((g) => users?.find((u) => u.id === g.admin)?.type).filter((t) => !!t); return userGroupsAdminTypes.every((t) => t !== "corporate"); }; return ( <> {isLoading && (
Completing your payment...
)} {user ? (
{hasExpired && You do not have time credits for your account type!} {isIndividual() && (
To add to your use of EnCoach, please purchase one of the time packages available below:
{packages.map((p) => (
EnCoach's Logo EnCoach - {p.duration}{" "} {capitalize( p.duration === 1 ? p.duration_unit.slice(0, p.duration_unit.length - 1) : p.duration_unit, )}
{p.price} {getSymbolFromCurrency(p.currency)} { setTimeout(reload, 500); }} />
This includes:
  • - Train your abilities for the IELTS exam
  • - Gain insights into your weaknesses and strengths
  • - Allow yourself to correctly prepare for the exam
))}
)} {!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:
EnCoach's Logo EnCoach - {user.corporateInformation?.monthlyDuration} Months
{user.corporateInformation.payment.value} {getSymbolFromCurrency(user.corporateInformation.payment.currency)} { setIsLoading(false); setTimeout(reload, 500); }} />
This includes:
  • - Allow a total of {user.corporateInformation.companyInformation.userAmount} students and teachers to use EnCoach
  • - Train their abilities for the IELTS exam
  • - Gain insights into your students' weaknesses and strengths
  • - Allow them to correctly prepare for the exam
)} {!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 later or contact your agent or an admin, thank you for your patience.
)}
) : (
)} ); }