Allow Master Corporate to pay for their subscription

This commit is contained in:
Tiago Ribeiro
2024-08-27 16:35:34 +01:00
parent b7940087b5
commit fa3929d5e9
2 changed files with 60 additions and 53 deletions

View File

@@ -160,49 +160,54 @@ export default function PaymentDue({user, hasExpired = false, reload}: Props) {
</div> </div>
</div> </div>
)} )}
{!isIndividual() && user.type === "corporate" && user?.corporateInformation.payment && ( {!isIndividual() &&
<div className="flex flex-col items-center"> (user?.type === "corporate" || user?.type === "mastercorporate") &&
<span className="max-w-lg"> user?.corporateInformation.payment && (
To add to your use of EnCoach and that of your students and teachers, please pay your designated package below: <div className="flex flex-col items-center">
</span> <span className="max-w-lg">
<div className={clsx("flex flex-col items-start gap-6 rounded-xl bg-white p-4")}> To add to your use of EnCoach and that of your students and teachers, please pay your designated package
<div className="mb-2 flex flex-col items-start"> below:
<img src="/logo_title.png" alt="EnCoach's Logo" className="w-32" /> </span>
<span className="text-xl font-semibold">EnCoach - {user.corporateInformation?.monthlyDuration} Months</span> <div className={clsx("flex flex-col items-start gap-6 rounded-xl bg-white p-4")}>
</div> <div className="mb-2 flex flex-col items-start">
<div className="flex w-full flex-col items-start gap-2"> <img src="/logo_title.png" alt="EnCoach's Logo" className="w-32" />
<span className="text-2xl"> <span className="text-xl font-semibold">
{user.corporateInformation.payment.value} {user.corporateInformation.payment.currency} EnCoach - {user.corporateInformation?.monthlyDuration} Months
</span> </span>
<PaymobPayment </div>
user={user} <div className="flex w-full flex-col items-start gap-2">
setIsPaymentLoading={setIsLoading} <span className="text-2xl">
currency={user.corporateInformation.payment.currency} {user.corporateInformation.payment.value} {user.corporateInformation.payment.currency}
price={user.corporateInformation.payment.value} </span>
duration={user.corporateInformation.monthlyDuration} <PaymobPayment
duration_unit="months" user={user}
onSuccess={() => { setIsPaymentLoading={setIsLoading}
setIsLoading(false); currency={user.corporateInformation.payment.currency}
setTimeout(reload, 500); price={user.corporateInformation.payment.value}
}} duration={user.corporateInformation.monthlyDuration}
/> duration_unit="months"
</div> onSuccess={() => {
<div className="flex flex-col items-start gap-1"> setIsLoading(false);
<span>This includes:</span> setTimeout(reload, 500);
<ul className="flex flex-col items-start text-sm"> }}
<li> />
- Allow a total of {user.corporateInformation.companyInformation.userAmount} students and teachers to </div>
use EnCoach <div className="flex flex-col items-start gap-1">
</li> <span>This includes:</span>
<li>- Train their abilities for the IELTS exam</li> <ul className="flex flex-col items-start text-sm">
<li>- Gain insights into your students&apos; weaknesses and strengths</li> <li>
<li>- Allow them to correctly prepare for the exam</li> - Allow a total of {user.corporateInformation.companyInformation.userAmount} students and teachers
</ul> to use EnCoach
</li>
<li>- Train their abilities for the IELTS exam</li>
<li>- Gain insights into your students&apos; weaknesses and strengths</li>
<li>- Allow them to correctly prepare for the exam</li>
</ul>
</div>
</div> </div>
</div> </div>
</div> )}
)} {!isIndividual() && !(user?.type === "corporate" || user?.type === "mastercorporate") && (
{!isIndividual() && user.type !== "corporate" && (
<div className="flex flex-col items-center"> <div className="flex flex-col items-center">
<span className="max-w-lg"> <span className="max-w-lg">
You are not the person in charge of your time credits, please contact your administrator about this situation. You are not the person in charge of your time credits, please contact your administrator about this situation.
@@ -213,17 +218,19 @@ export default function PaymentDue({user, hasExpired = false, reload}: Props) {
</span> </span>
</div> </div>
)} )}
{!isIndividual() && user.type === "corporate" && !user.corporateInformation.payment && ( {!isIndividual() &&
<div className="flex flex-col items-center"> (user?.type === "corporate" || user?.type === "mastercorporate") &&
<span className="max-w-lg"> !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 <div className="flex flex-col items-center">
desire and your expected monthly duration. <span className="max-w-lg">
</span> An admin nor your agent have yet set the price intended to your requirements in terms of the amount of users
<span className="max-w-lg"> you desire and your expected monthly duration.
Please try again later or contact your agent or an admin, thank you for your patience. </span>
</span> <span className="max-w-lg">
</div> Please try again later or contact your agent or an admin, thank you for your patience.
)} </span>
</div>
)}
</div> </div>
</Layout> </Layout>
) : ( ) : (

View File

@@ -13,7 +13,7 @@ export const propagateStatusChange = (userId: string, status: UserStatus) =>
const user = docUser.data() as User; const user = docUser.data() as User;
// only update the status of the user's groups if the user is a corporate user // only update the status of the user's groups if the user is a corporate user
if (user.type === "corporate") { if (user.type === "corporate" || user.type === "mastercorporate") {
getDocs(query(collection(db, "groups"), where("admin", "==", userId))).then(async (userGroupsRef) => { getDocs(query(collection(db, "groups"), where("admin", "==", userId))).then(async (userGroupsRef) => {
const userGroups = userGroupsRef.docs.map((x) => x.data()); const userGroups = userGroupsRef.docs.map((x) => x.data());