Compare commits

..

19 Commits

Author SHA1 Message Date
Tiago Ribeiro
85b94512e9 Merge branch 'develop' into ENCOA-38/add-validity-date-for-discounts 2024-05-23 19:22:31 +01:00
Tiago Ribeiro
906646ebce Created the validity dates for discounts 2024-05-23 19:21:52 +01:00
Tiago Ribeiro
96108a4958 Reverted to have checks 2024-05-23 17:22:57 +01:00
Tiago Ribeiro
fb449f2054 Updated the status when the transaction is not successful 2024-05-21 15:40:18 +01:00
Tiago Ribeiro
d5ee3d9519 Added a log for debugging 2024-05-21 15:35:57 +01:00
Tiago Ribeiro
4e20ec6575 Removed a check from the webhook 2024-05-21 12:04:31 +01:00
Tiago Ribeiro
836b674076 Added some changes to the propagate corporate changes 2024-05-21 11:21:14 +01:00
Tiago Ribeiro
5086c6fb09 Solved a visual bug 2024-05-21 11:09:36 +01:00
Tiago Ribeiro
489c9c3b7e Possibly solved part of the issue with speaking 2024-05-20 21:28:45 +01:00
Tiago Ribeiro
e3ded29e77 Merge branch 'develop' 2024-05-20 21:09:43 +01:00
Tiago Ribeiro
16419a5584 Fixed a bug introduced on the last one 2024-05-20 11:23:52 +01:00
Tiago Ribeiro
3e3b24cc30 Solved a bug for level test 2024-05-20 11:18:46 +01:00
Tiago Ribeiro
841698ba10 Updated the profile to also have the focus in it 2024-05-20 11:13:09 +01:00
Tiago Ribeiro
d50904611c Added a missing space 2024-05-16 15:42:13 +01:00
Tiago Ribeiro
e77fd16d26 Added a space to it 2024-05-16 15:03:31 +01:00
Tiago Ribeiro
649f24e4ae Updated the showcase 2024-05-16 14:51:19 +01:00
Tiago Ribeiro
2f0cbfe74e Removed the billing details modal 2024-05-16 14:30:44 +01:00
Tiago Ribeiro
d022bd078a Updated the currencies to have OMR as well 2024-05-16 13:44:27 +01:00
Tiago Ribeiro
c18afee9ad Updated the packages 2024-05-16 13:34:18 +01:00
16 changed files with 1319 additions and 1648 deletions

View File

@@ -47,7 +47,6 @@
"next": "13.1.6", "next": "13.1.6",
"nodemailer": "^6.9.5", "nodemailer": "^6.9.5",
"nodemailer-express-handlebars": "^6.1.0", "nodemailer-express-handlebars": "^6.1.0",
"paymob-react": "git+https://github.com/tiago-ecrop/paymob-react-oman.git",
"primeicons": "^6.0.1", "primeicons": "^6.0.1",
"primereact": "^9.2.3", "primereact": "^9.2.3",
"qrcode": "^1.5.3", "qrcode": "^1.5.3",

View File

@@ -16,9 +16,13 @@ function Question({
}: MultipleChoiceQuestion & {userSolution: string | undefined; onSelectOption?: (option: string) => void; showSolution?: boolean}) { }: MultipleChoiceQuestion & {userSolution: string | undefined; onSelectOption?: (option: string) => void; showSolution?: boolean}) {
return ( return (
<div className="flex flex-col gap-10"> <div className="flex flex-col gap-10">
{isNaN(Number(id)) ? (
<span className="">{prompt}</span>
) : (
<span className=""> <span className="">
{id} - {prompt} {id} - {prompt}
</span> </span>
)}
<div className="flex flex-wrap gap-4 justify-between"> <div className="flex flex-wrap gap-4 justify-between">
{variant === "image" && {variant === "image" &&
options.map((option) => ( options.map((option) => (

View File

@@ -20,15 +20,6 @@ interface Props {
export default function PaymobPayment({user, price, setIsPaymentLoading, currency, duration, duration_unit, onSuccess}: Props) { export default function PaymobPayment({user, price, setIsPaymentLoading, currency, duration, duration_unit, onSuccess}: Props) {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [isModalOpen, setIsModalOpen] = useState(false);
const [firstName, setFirstName] = useState(user.name.split(" ")[0]);
const [lastName, setLastName] = useState([...user.name.split(" ")].pop());
const [street, setStreet] = useState("");
const [apartment, setApartment] = useState("");
const [building, setBuilding] = useState("");
const [state, setState] = useState("");
const [floor, setFloor] = useState("");
const router = useRouter(); const router = useRouter();
@@ -50,16 +41,16 @@ export default function PaymobPayment({user, price, setIsPaymentLoading, currenc
}, },
}, },
billing_data: { billing_data: {
apartment: apartment || "N/A", apartment: "N/A",
building: building || "N/A", building: "N/A",
country: user.demographicInformation?.country || "N/A", country: user.demographicInformation?.country || "N/A",
email: user.email, email: user.email,
first_name: user.name.split(" ")[0], first_name: user.name.split(" ")[0],
last_name: [...user.name.split(" ")].pop() || "N/A", last_name: [...user.name.split(" ")].pop() || "N/A",
floor: floor || "N/A", floor: "N/A",
phone_number: user.demographicInformation?.phone || "N/A", phone_number: user.demographicInformation?.phone || "N/A",
state: state || "N/A", state: "N/A",
street: street || "N/A", street: "N/A",
}, },
extras: { extras: {
userID: user.id, userID: user.id,
@@ -71,7 +62,6 @@ export default function PaymobPayment({user, price, setIsPaymentLoading, currenc
const response = await axios.post<{iframeURL: string}>(`/api/paymob`, paymentIntention); const response = await axios.post<{iframeURL: string}>(`/api/paymob`, paymentIntention);
router.push(response.data.iframeURL); router.push(response.data.iframeURL);
setIsModalOpen(false);
} catch (error) { } catch (error) {
console.error("Error starting card payment process:", error); console.error("Error starting card payment process:", error);
} }
@@ -79,27 +69,7 @@ export default function PaymobPayment({user, price, setIsPaymentLoading, currenc
return ( return (
<> <>
<Modal isOpen={isModalOpen} title="Billing Data" onClose={() => setIsModalOpen(false)}> <Button isLoading={isLoading} onClick={handleCardPayment}>
<div className="flex flex-col gap-4 mt-4">
<div className="grid grid-cols-2 gap-4">
<Input label="First Name" value={firstName} onChange={setFirstName} type="text" name="firstName" />
<Input label="Last Name" value={lastName} onChange={setLastName} type="text" name="lastName" />
</div>
<div className="grid grid-cols-3 -md:grid-cols-1 gap-4">
<Input label="State" value={state} onChange={setState} type="text" name="state" />
<Input label="Street" value={street} onChange={setStreet} type="text" name="street" />
<Input label="Building" value={building} onChange={setBuilding} type="text" name="building" />
</div>
<div className="grid grid-cols-2 gap-4">
<Input label="Floor" value={floor} onChange={setFloor} type="text" name="floor" />
<Input label="Apartment" value={apartment} onChange={setApartment} type="text" name="apartment" />
</div>
<Button className="w-full max-w-[200px] self-end mt-4" disabled={!firstName || !lastName} onClick={handleCardPayment}>
Complete Payment
</Button>
</div>
</Modal>
<Button isLoading={isLoading} onClick={() => setIsModalOpen(true)}>
Select Select
</Button> </Button>
</> </>

View File

@@ -27,9 +27,13 @@ function Question({
return ( return (
<div className="flex flex-col items-center gap-4"> <div className="flex flex-col items-center gap-4">
<span> {isNaN(Number(id)) ? (
<span className="">{prompt}</span>
) : (
<span className="">
{id} - {prompt} {id} - {prompt}
</span> </span>
)}
<div className="grid grid-cols-4 gap-4 place-items-center"> <div className="grid grid-cols-4 gap-4 place-items-center">
{variant === "image" && {variant === "image" &&
options.map((option) => ( options.map((option) => (

View File

@@ -24,6 +24,7 @@ export interface Discount {
id: string; id: string;
percentage: number; percentage: number;
domain: string; domain: string;
validUntil?: Date;
} }
export type DurationUnit = "weeks" | "days" | "months" | "years"; export type DurationUnit = "weeks" | "days" | "months" | "years";

View File

@@ -10,32 +10,24 @@ import useUsers from "@/hooks/useUsers";
import {Discount} from "@/interfaces/paypal"; import {Discount} from "@/interfaces/paypal";
import {Code, User} from "@/interfaces/user"; import {Code, User} from "@/interfaces/user";
import {USER_TYPE_LABELS} from "@/resources/user"; import {USER_TYPE_LABELS} from "@/resources/user";
import { import {createColumnHelper, flexRender, getCoreRowModel, useReactTable} from "@tanstack/react-table";
createColumnHelper,
flexRender,
getCoreRowModel,
useReactTable,
} from "@tanstack/react-table";
import axios from "axios"; import axios from "axios";
import clsx from "clsx";
import moment from "moment"; import moment from "moment";
import {useEffect, useState} from "react"; import {useEffect, useState} from "react";
import ReactDatePicker from "react-datepicker";
import {BsPencil, BsTrash} from "react-icons/bs"; import {BsPencil, BsTrash} from "react-icons/bs";
import {toast} from "react-toastify"; import {toast} from "react-toastify";
const columnHelper = createColumnHelper<Discount>(); const columnHelper = createColumnHelper<Discount>();
const DiscountCreator = ({ const DiscountCreator = ({discount, onClose}: {discount?: Discount; onClose: () => void}) => {
discount,
onClose,
}: {
discount?: Discount;
onClose: () => void;
}) => {
const [percentage, setPercentage] = useState(discount?.percentage); const [percentage, setPercentage] = useState(discount?.percentage);
const [domain, setDomain] = useState(discount?.domain); const [domain, setDomain] = useState(discount?.domain);
const [validUntil, setValidUntil] = useState(discount?.validUntil);
const submit = async () => { const submit = async () => {
const body = { percentage, domain }; const body = {percentage, domain, validUntil: validUntil?.toISOString() || undefined};
if (discount) { if (discount) {
return axios return axios
@@ -62,11 +54,9 @@ const DiscountCreator = ({
return ( return (
<div className="flex flex-col gap-8 py-8"> <div className="flex flex-col gap-8 py-8">
<div className="w-full grid grid-cols-1 md:grid-cols-2 gap-8"> <div className="w-full grid grid-cols-1 gap-8">
<div className="flex flex-col gap-3"> <div className="flex flex-col gap-3">
<label className="font-normal text-base text-mti-gray-dim"> <label className="font-normal text-base text-mti-gray-dim">Domain *</label>
Domain *
</label>
<div className="flex gap-4 items-center"> <div className="flex gap-4 items-center">
<Input <Input
defaultValue={domain} defaultValue={domain}
@@ -78,9 +68,7 @@ const DiscountCreator = ({
</div> </div>
</div> </div>
<div className="flex flex-col gap-3"> <div className="flex flex-col gap-3">
<label className="font-normal text-base text-mti-gray-dim"> <label className="font-normal text-base text-mti-gray-dim">Percentage (in %) *</label>
Percentage (in %) *
</label>
<div className="flex gap-4 items-center"> <div className="flex gap-4 items-center">
<Input <Input
defaultValue={percentage} defaultValue={percentage}
@@ -91,21 +79,32 @@ const DiscountCreator = ({
/> />
</div> </div>
</div> </div>
<div className="flex flex-col gap-3 w-full">
<label className="font-normal text-base text-mti-gray-dim">Valid Until</label>
<div className="flex gap-4 items-center w-full">
<ReactDatePicker
wrapperClassName="w-full z-[900]"
calendarClassName="z-[900]"
popperClassName="z-[900]"
isClearable
className={clsx(
"flex min-h-[70px] w-full cursor-pointer justify-center rounded-full border p-6 text-sm font-normal focus:outline-none",
"hover:border-mti-purple tooltip",
"transition duration-300 ease-in-out",
)}
filterDate={(date) => moment(date).isAfter(new Date())}
dateFormat="dd/MM/yyyy"
selected={validUntil}
onChange={(date) => setValidUntil(date ? moment(date).endOf("day").toDate() : undefined)}
/>
</div>
</div>
</div> </div>
<div className="flex w-full justify-end items-center gap-8 mt-8"> <div className="flex w-full justify-end items-center gap-8 mt-8">
<Button <Button variant="outline" color="red" className="w-full max-w-[200px]" onClick={onClose}>
variant="outline"
color="red"
className="w-full max-w-[200px]"
onClick={onClose}
>
Cancel Cancel
</Button> </Button>
<Button <Button className="w-full max-w-[200px]" onClick={submit} disabled={!percentage || !domain}>
className="w-full max-w-[200px]"
onClick={submit}
disabled={!percentage || !domain}
>
Submit Submit
</Button> </Button>
</div> </div>
@@ -129,25 +128,17 @@ export default function DiscountList({ user }: { user: User }) {
}, [discounts]); }, [discounts]);
const toggleDiscount = (id: string) => { const toggleDiscount = (id: string) => {
setSelectedDiscounts((prev) => setSelectedDiscounts((prev) => (prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id]));
prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id],
);
}; };
const toggleAllDiscounts = (checked: boolean) => { const toggleAllDiscounts = (checked: boolean) => {
if (checked) if (checked) return setSelectedDiscounts(filteredDiscounts.map((x) => x.id));
return setSelectedDiscounts(filteredDiscounts.map((x) => x.id));
return setSelectedDiscounts([]); return setSelectedDiscounts([]);
}; };
const deleteDiscounts = async (discounts: string[]) => { const deleteDiscounts = async (discounts: string[]) => {
if ( if (!confirm(`Are you sure you want to delete these ${discounts.length} discount(s)?`)) return;
!confirm(
`Are you sure you want to delete these ${discounts.length} discount(s)?`,
)
)
return;
const params = new URLSearchParams(); const params = new URLSearchParams();
discounts.forEach((code) => params.append("discount", code)); discounts.forEach((code) => params.append("discount", code));
@@ -172,12 +163,7 @@ export default function DiscountList({ user }: { user: User }) {
}; };
const deleteDiscount = async (discount: Discount) => { const deleteDiscount = async (discount: Discount) => {
if ( if (!confirm(`Are you sure you want to delete this "${discount.id}" discount?`)) return;
!confirm(
`Are you sure you want to delete this "${discount.id}" discount?`,
)
)
return;
axios axios
.delete(`/api/discounts/${discount.id}`) .delete(`/api/discounts/${discount.id}`)
@@ -204,20 +190,13 @@ export default function DiscountList({ user }: { user: User }) {
header: () => ( header: () => (
<Checkbox <Checkbox
disabled={filteredDiscounts.length === 0} disabled={filteredDiscounts.length === 0}
isChecked={ isChecked={selectedDiscounts.length === filteredDiscounts.length && filteredDiscounts.length > 0}
selectedDiscounts.length === filteredDiscounts.length && onChange={(checked) => toggleAllDiscounts(checked)}>
filteredDiscounts.length > 0
}
onChange={(checked) => toggleAllDiscounts(checked)}
>
{""} {""}
</Checkbox> </Checkbox>
), ),
cell: (info) => ( cell: (info) => (
<Checkbox <Checkbox isChecked={selectedDiscounts.includes(info.getValue())} onChange={() => toggleDiscount(info.getValue())}>
isChecked={selectedDiscounts.includes(info.getValue())}
onChange={() => toggleDiscount(info.getValue())}
>
{""} {""}
</Checkbox> </Checkbox>
), ),
@@ -234,6 +213,10 @@ export default function DiscountList({ user }: { user: User }) {
header: "Percentage", header: "Percentage",
cell: (info) => `${info.getValue()}%`, cell: (info) => `${info.getValue()}%`,
}), }),
columnHelper.accessor("validUntil", {
header: "Valid Until",
cell: (info) => (info.getValue() ? moment(info.getValue()).format("DD/MM/YYYY") : ""),
}),
{ {
header: "", header: "",
id: "actions", id: "actions",
@@ -245,15 +228,10 @@ export default function DiscountList({ user }: { user: User }) {
className="cursor-pointer tooltip" className="cursor-pointer tooltip"
onClick={() => { onClick={() => {
setEditingDiscount(row.original); setEditingDiscount(row.original);
}} }}>
>
<BsPencil className="hover:text-mti-purple-light transition ease-in-out duration-300" /> <BsPencil className="hover:text-mti-purple-light transition ease-in-out duration-300" />
</div> </div>
<div <div data-tip="Delete" className="cursor-pointer tooltip" onClick={() => deleteDiscount(row.original)}>
data-tip="Delete"
className="cursor-pointer tooltip"
onClick={() => deleteDiscount(row.original)}
>
<BsTrash className="hover:text-mti-purple-light transition ease-in-out duration-300" /> <BsTrash className="hover:text-mti-purple-light transition ease-in-out duration-300" />
</div> </div>
</div> </div>
@@ -279,10 +257,7 @@ export default function DiscountList({ user }: { user: User }) {
<Modal <Modal
isOpen={isCreating || !!editingDiscount} isOpen={isCreating || !!editingDiscount}
onClose={closeModal} onClose={closeModal}
title={ title={editingDiscount ? `Editing ${editingDiscount.id}` : "New Discount"}>
editingDiscount ? `Editing ${editingDiscount.id}` : "New Discount"
}
>
<DiscountCreator onClose={closeModal} discount={editingDiscount} /> <DiscountCreator onClose={closeModal} discount={editingDiscount} />
</Modal> </Modal>
<div className="flex items-center justify-end pb-4 pt-1"> <div className="flex items-center justify-end pb-4 pt-1">
@@ -293,8 +268,7 @@ export default function DiscountList({ user }: { user: User }) {
variant="outline" variant="outline"
color="red" color="red"
className="!py-1 px-10" className="!py-1 px-10"
onClick={() => deleteDiscounts(selectedDiscounts)} onClick={() => deleteDiscounts(selectedDiscounts)}>
>
Delete Delete
</Button> </Button>
</div> </div>
@@ -305,12 +279,7 @@ export default function DiscountList({ user }: { user: User }) {
<tr key={headerGroup.id}> <tr key={headerGroup.id}>
{headerGroup.headers.map((header) => ( {headerGroup.headers.map((header) => (
<th className="p-4 text-left" key={header.id}> <th className="p-4 text-left" key={header.id}>
{header.isPlaceholder {header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
? null
: flexRender(
header.column.columnDef.header,
header.getContext(),
)}
</th> </th>
))} ))}
</tr> </tr>
@@ -318,10 +287,7 @@ export default function DiscountList({ user }: { user: User }) {
</thead> </thead>
<tbody className="px-2"> <tbody className="px-2">
{table.getRowModel().rows.map((row) => ( {table.getRowModel().rows.map((row) => (
<tr <tr className="odd:bg-white even:bg-mti-purple-ultralight/40 rounded-lg py-2" key={row.id}>
className="odd:bg-white even:bg-mti-purple-ultralight/40 rounded-lg py-2"
key={row.id}
>
{row.getVisibleCells().map((cell) => ( {row.getVisibleCells().map((cell) => (
<td className="px-4 py-2" key={cell.id}> <td className="px-4 py-2" key={cell.id}>
{flexRender(cell.column.columnDef.cell, cell.getContext())} {flexRender(cell.column.columnDef.cell, cell.getContext())}
@@ -333,8 +299,7 @@ export default function DiscountList({ user }: { user: User }) {
</table> </table>
<button <button
onClick={() => setIsCreating(true)} onClick={() => setIsCreating(true)}
className="w-full py-2 bg-mti-purple-light hover:bg-mti-purple transition ease-in-out duration-300 text-white" className="w-full py-2 bg-mti-purple-light hover:bg-mti-purple transition ease-in-out duration-300 text-white">
>
New Discount New Discount
</button> </button>
</> </>

View File

@@ -40,7 +40,7 @@ function PackageCreator({pack, onClose}: {pack?: Package; onClose: () => void})
const [unit, setUnit] = useState<DurationUnit>(pack?.duration_unit || "months"); const [unit, setUnit] = useState<DurationUnit>(pack?.duration_unit || "months");
const [price, setPrice] = useState(pack?.price || 0); const [price, setPrice] = useState(pack?.price || 0);
const [currency, setCurrency] = useState<string>(pack?.currency || "EUR"); const [currency, setCurrency] = useState<string>(pack?.currency || "OMR");
const submit = () => { const submit = () => {
(pack ? axios.patch : axios.post)(pack ? `/api/packages/${pack.id}` : "/api/packages", { (pack ? axios.patch : axios.post)(pack ? `/api/packages/${pack.id}` : "/api/packages", {

View File

@@ -15,10 +15,7 @@ import useUser from "@/hooks/useUser";
import {Exam, UserSolution, Variant} from "@/interfaces/exam"; import {Exam, UserSolution, Variant} from "@/interfaces/exam";
import {Stat} from "@/interfaces/user"; import {Stat} from "@/interfaces/user";
import useExamStore from "@/stores/examStore"; import useExamStore from "@/stores/examStore";
import { import {evaluateSpeakingAnswer, evaluateWritingAnswer} from "@/utils/evaluation";
evaluateSpeakingAnswer,
evaluateWritingAnswer,
} from "@/utils/evaluation";
import {defaultExamUserSolutions, getExam} from "@/utils/exams"; import {defaultExamUserSolutions, getExam} from "@/utils/exams";
import axios from "axios"; import axios from "axios";
import {useRouter} from "next/router"; import {useRouter} from "next/router";
@@ -37,9 +34,7 @@ export default function ExamPage({ page }: Props) {
const [hasBeenUploaded, setHasBeenUploaded] = useState(false); const [hasBeenUploaded, setHasBeenUploaded] = useState(false);
const [showAbandonPopup, setShowAbandonPopup] = useState(false); const [showAbandonPopup, setShowAbandonPopup] = useState(false);
const [isEvaluationLoading, setIsEvaluationLoading] = useState(false); const [isEvaluationLoading, setIsEvaluationLoading] = useState(false);
const [statsAwaitingEvaluation, setStatsAwaitingEvaluation] = useState< const [statsAwaitingEvaluation, setStatsAwaitingEvaluation] = useState<string[]>([]);
string[]
>([]);
const [timeSpent, setTimeSpent] = useState(0); const [timeSpent, setTimeSpent] = useState(0);
const resetStore = useExamStore((state) => state.reset); const resetStore = useExamStore((state) => state.reset);
@@ -57,9 +52,7 @@ export default function ExamPage({ page }: Props) {
const {exerciseIndex, setExerciseIndex} = useExamStore((state) => state); const {exerciseIndex, setExerciseIndex} = useExamStore((state) => state);
const {userSolutions, setUserSolutions} = useExamStore((state) => state); const {userSolutions, setUserSolutions} = useExamStore((state) => state);
const {showSolutions, setShowSolutions} = useExamStore((state) => state); const {showSolutions, setShowSolutions} = useExamStore((state) => state);
const { selectedModules, setSelectedModules } = useExamStore( const {selectedModules, setSelectedModules} = useExamStore((state) => state);
(state) => state,
);
const {user} = useUser({redirectTo: "/login"}); const {user} = useUser({redirectTo: "/login"});
const router = useRouter(); const router = useRouter();
@@ -97,10 +90,7 @@ export default function ExamPage({ page }: Props) {
}); });
}; };
useEffect( useEffect(() => setTimeSpent((prev) => prev + initialTimeSpent), [initialTimeSpent]);
() => setTimeSpent((prev) => prev + initialTimeSpent),
[initialTimeSpent],
);
useEffect(() => { useEffect(() => {
if (userSolutions.length === 0 && exams.length > 0) { if (userSolutions.length === 0 && exams.length > 0) {
@@ -122,28 +112,10 @@ export default function ExamPage({ page }: Props) {
) )
saveSession(); saveSession();
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [ }, [assignment, exam, exams, moduleIndex, selectedModules, sessionId, userSolutions, user, exerciseIndex, partIndex, questionIndex]);
assignment,
exam,
exams,
moduleIndex,
selectedModules,
sessionId,
userSolutions,
user,
exerciseIndex,
partIndex,
questionIndex,
]);
useEffect(() => { useEffect(() => {
if ( if (timeSpent % 20 === 0 && timeSpent > 0 && moduleIndex < selectedModules.length && !showSolutions) saveSession();
timeSpent % 20 === 0 &&
timeSpent > 0 &&
moduleIndex < selectedModules.length &&
!showSolutions
)
saveSession();
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [timeSpent]); }, [timeSpent]);
@@ -177,20 +149,11 @@ export default function ExamPage({ page }: Props) {
useEffect(() => { useEffect(() => {
(async () => { (async () => {
if ( if (selectedModules.length > 0 && exams.length > 0 && moduleIndex < selectedModules.length) {
selectedModules.length > 0 &&
exams.length > 0 &&
moduleIndex < selectedModules.length
) {
const nextExam = exams[moduleIndex]; const nextExam = exams[moduleIndex];
if (partIndex === -1 && nextExam.module !== "listening") if (partIndex === -1 && nextExam.module !== "listening") setPartIndex(0);
setPartIndex(0); if (exerciseIndex === -1 && !["reading", "listening"].includes(nextExam?.module)) setExerciseIndex(0);
if (
exerciseIndex === -1 &&
!["reading", "listening"].includes(nextExam?.module)
)
setExerciseIndex(0);
setExam(nextExam ? updateExamWithUserSolutions(nextExam) : undefined); setExam(nextExam ? updateExamWithUserSolutions(nextExam) : undefined);
} }
})(); })();
@@ -205,9 +168,7 @@ export default function ExamPage({ page }: Props) {
module, module,
avoidRepeated, avoidRepeated,
variant, variant,
user?.type === "student" || user?.type === "developer" user?.type === "student" || user?.type === "developer" ? user.preferredGender : undefined,
? user.preferredGender
: undefined,
), ),
); );
Promise.all(examPromises).then((values) => { Promise.all(examPromises).then((values) => {
@@ -224,13 +185,7 @@ export default function ExamPage({ page }: Props) {
}, [selectedModules, setExams, exams]); }, [selectedModules, setExams, exams]);
useEffect(() => { useEffect(() => {
if ( if (selectedModules.length > 0 && exams.length !== 0 && moduleIndex >= selectedModules.length && !hasBeenUploaded && !showSolutions) {
selectedModules.length > 0 &&
exams.length !== 0 &&
moduleIndex >= selectedModules.length &&
!hasBeenUploaded &&
!showSolutions
) {
const newStats: Stat[] = userSolutions.map((solution) => ({ const newStats: Stat[] = userSolutions.map((solution) => ({
...solution, ...solution,
id: solution.id || uuidv4(), id: solution.id || uuidv4(),
@@ -266,17 +221,10 @@ export default function ExamPage({ page }: Props) {
const checkIfStatsHaveBeenEvaluated = (ids: string[]) => { const checkIfStatsHaveBeenEvaluated = (ids: string[]) => {
setTimeout(async () => { setTimeout(async () => {
try { try {
const awaitedStats = await Promise.all( const awaitedStats = await Promise.all(ids.map(async (id) => (await axios.get<Stat>(`/api/stats/${id}`)).data));
ids.map( const solutionsEvaluated = awaitedStats.every((stat) => stat.solutions.every((x) => x.evaluation !== null));
async (id) => (await axios.get<Stat>(`/api/stats/${id}`)).data,
),
);
const solutionsEvaluated = awaitedStats.every((stat) =>
stat.solutions.every((x) => x.evaluation !== null),
);
if (solutionsEvaluated) { if (solutionsEvaluated) {
const statsUserSolutions: UserSolution[] = awaitedStats.map( const statsUserSolutions: UserSolution[] = awaitedStats.map((stat) => ({
(stat) => ({
id: stat.id, id: stat.id,
exercise: stat.exercise, exercise: stat.exercise,
score: stat.score, score: stat.score,
@@ -284,20 +232,15 @@ export default function ExamPage({ page }: Props) {
type: stat.type, type: stat.type,
exam: stat.exam, exam: stat.exam,
module: stat.module, module: stat.module,
}), }));
);
const updatedUserSolutions = userSolutions.map((x) => { const updatedUserSolutions = userSolutions.map((x) => {
const respectiveSolution = statsUserSolutions.find( const respectiveSolution = statsUserSolutions.find((y) => y.exercise === x.exercise);
(y) => y.exercise === x.exercise,
);
return respectiveSolution ? respectiveSolution : x; return respectiveSolution ? respectiveSolution : x;
}); });
setUserSolutions(updatedUserSolutions); setUserSolutions(updatedUserSolutions);
return setStatsAwaitingEvaluation((prev) => return setStatsAwaitingEvaluation((prev) => prev.filter((x) => !ids.includes(x)));
prev.filter((x) => !ids.includes(x)),
);
} }
return checkIfStatsHaveBeenEvaluated(ids); return checkIfStatsHaveBeenEvaluated(ids);
@@ -313,8 +256,7 @@ export default function ExamPage({ page }: Props) {
Object.assign(p, { Object.assign(p, {
exercises: p.exercises.map((x) => exercises: p.exercises.map((x) =>
Object.assign(x, { Object.assign(x, {
userSolutions: userSolutions.find((y) => x.id === y.exercise) userSolutions: userSolutions.find((y) => x.id === y.exercise)?.solutions,
?.solutions,
}), }),
), ),
}), }),
@@ -324,8 +266,7 @@ export default function ExamPage({ page }: Props) {
const exercises = exam.exercises.map((x) => const exercises = exam.exercises.map((x) =>
Object.assign(x, { Object.assign(x, {
userSolutions: userSolutions.find((y) => x.id === y.exercise) userSolutions: userSolutions.find((y) => x.id === y.exercise)?.solutions,
?.solutions,
}), }),
); );
return Object.assign(exam, {exercises}); return Object.assign(exam, {exercises});
@@ -339,12 +280,7 @@ export default function ExamPage({ page }: Props) {
if (exam && !solutionExams.includes(exam.id)) return; if (exam && !solutionExams.includes(exam.id)) return;
if ( if (exam && (exam.module === "writing" || exam.module === "speaking") && solutions.length > 0 && !showSolutions) {
exam &&
(exam.module === "writing" || exam.module === "speaking") &&
solutions.length > 0 &&
!showSolutions
) {
setHasBeenUploaded(true); setHasBeenUploaded(true);
setIsEvaluationLoading(true); setIsEvaluationLoading(true);
@@ -353,45 +289,27 @@ export default function ExamPage({ page }: Props) {
exam.exercises.map(async (exercise, index) => { exam.exercises.map(async (exercise, index) => {
const evaluationID = uuidv4(); const evaluationID = uuidv4();
if (exercise.type === "writing") if (exercise.type === "writing")
return await evaluateWritingAnswer( return await evaluateWritingAnswer(exercise, index + 1, solutions.find((x) => x.exercise === exercise.id)!, evaluationID);
exercise,
index + 1,
solutions.find((x) => x.exercise === exercise.id)!,
evaluationID,
);
if ( if (exercise.type === "interactiveSpeaking" || exercise.type === "speaking")
exercise.type === "interactiveSpeaking" ||
exercise.type === "speaking"
)
return await evaluateSpeakingAnswer( return await evaluateSpeakingAnswer(
exercise, exercise,
solutions.find((x) => x.exercise === exercise.id)!, solutions.find((x) => x.exercise === exercise.id)!,
evaluationID, evaluationID,
index === 0 ? 1 : 2,
); );
}), }),
) )
).filter((x) => !!x) as UserSolution[]; ).filter((x) => !!x) as UserSolution[];
newSolutions = [ newSolutions = [...newSolutions.filter((x) => !responses.map((y) => y.exercise).includes(x.exercise)), ...responses];
...newSolutions.filter( setStatsAwaitingEvaluation((prev) => [...prev, ...responses.filter((x) => !!x).map((r) => (r as any).id)]);
(x) => !responses.map((y) => y.exercise).includes(x.exercise),
),
...responses,
];
setStatsAwaitingEvaluation((prev) => [
...prev,
...responses.filter((x) => !!x).map((r) => (r as any).id),
]);
setHasBeenUploaded(false); setHasBeenUploaded(false);
} }
axios.get("/api/stats/update"); axios.get("/api/stats/update");
setUserSolutions([ setUserSolutions([...userSolutions.filter((x) => !solutionIds.includes(x.exercise)), ...newSolutions]);
...userSolutions.filter((x) => !solutionIds.includes(x.exercise)),
...newSolutions,
]);
setModuleIndex(moduleIndex + 1); setModuleIndex(moduleIndex + 1);
setPartIndex(-1); setPartIndex(-1);
@@ -437,12 +355,7 @@ export default function ExamPage({ page }: Props) {
userSolutions.forEach((x) => { userSolutions.forEach((x) => {
const examModule = const examModule =
x.module || x.module || (x.type === "writing" ? "writing" : x.type === "speaking" || x.type === "interactiveSpeaking" ? "speaking" : undefined);
(x.type === "writing"
? "writing"
: x.type === "speaking" || x.type === "interactiveSpeaking"
? "speaking"
: undefined);
scores[examModule!] = { scores[examModule!] = {
total: scores[examModule!].total + x.score.total, total: scores[examModule!].total + x.score.total,
@@ -482,9 +395,7 @@ export default function ExamPage({ page }: Props) {
onViewResults={(index?: number) => { onViewResults={(index?: number) => {
setShowSolutions(true); setShowSolutions(true);
setModuleIndex(index || 0); setModuleIndex(index || 0);
setExerciseIndex( setExerciseIndex(["reading", "listening"].includes(exams[0].module) ? -1 : 0);
["reading", "listening"].includes(exams[0].module) ? -1 : 0,
);
setPartIndex(exams[0].module === "listening" ? -1 : 0); setPartIndex(exams[0].module === "listening" ? -1 : 0);
setExam(exams[0]); setExam(exams[0]);
}} }}
@@ -494,49 +405,23 @@ export default function ExamPage({ page }: Props) {
} }
if (exam && exam.module === "reading") { if (exam && exam.module === "reading") {
return ( return <Reading exam={exam} onFinish={onFinish} showSolutions={showSolutions} />;
<Reading
exam={exam}
onFinish={onFinish}
showSolutions={showSolutions}
/>
);
} }
if (exam && exam.module === "listening") { if (exam && exam.module === "listening") {
return ( return <Listening exam={exam} onFinish={onFinish} showSolutions={showSolutions} />;
<Listening
exam={exam}
onFinish={onFinish}
showSolutions={showSolutions}
/>
);
} }
if (exam && exam.module === "writing") { if (exam && exam.module === "writing") {
return ( return <Writing exam={exam} onFinish={onFinish} showSolutions={showSolutions} />;
<Writing
exam={exam}
onFinish={onFinish}
showSolutions={showSolutions}
/>
);
} }
if (exam && exam.module === "speaking") { if (exam && exam.module === "speaking") {
return ( return <Speaking exam={exam} onFinish={onFinish} showSolutions={showSolutions} />;
<Speaking
exam={exam}
onFinish={onFinish}
showSolutions={showSolutions}
/>
);
} }
if (exam && exam.module === "level") { if (exam && exam.module === "level") {
return ( return <Level exam={exam} onFinish={onFinish} showSolutions={showSolutions} />;
<Level exam={exam} onFinish={onFinish} showSolutions={showSolutions} />
);
} }
return <>Loading...</>; return <>Loading...</>;
@@ -549,13 +434,8 @@ export default function ExamPage({ page }: Props) {
<Layout <Layout
user={user} user={user}
className="justify-between" className="justify-between"
focusMode={ focusMode={selectedModules.length !== 0 && !showSolutions && moduleIndex < selectedModules.length}
selectedModules.length !== 0 && onFocusLayerMouseEnter={() => setShowAbandonPopup(true)}>
!showSolutions &&
moduleIndex < selectedModules.length
}
onFocusLayerMouseEnter={() => setShowAbandonPopup(true)}
>
<> <>
{renderScreen()} {renderScreen()}
{!showSolutions && moduleIndex < selectedModules.length && ( {!showSolutions && moduleIndex < selectedModules.length && (

View File

@@ -7,7 +7,6 @@ import {User} from "@/interfaces/user";
import clsx from "clsx"; import clsx from "clsx";
import {capitalize} from "lodash"; import {capitalize} from "lodash";
import {useEffect, useState} from "react"; import {useEffect, useState} from "react";
import getSymbolFromCurrency from "currency-symbol-map";
import useInvites from "@/hooks/useInvites"; import useInvites from "@/hooks/useInvites";
import {BsArrowRepeat} from "react-icons/bs"; import {BsArrowRepeat} from "react-icons/bs";
import InviteCard from "@/components/Medium/InviteCard"; import InviteCard from "@/components/Medium/InviteCard";
@@ -15,6 +14,7 @@ import {useRouter} from "next/router";
import {ToastContainer} from "react-toastify"; import {ToastContainer} from "react-toastify";
import useDiscounts from "@/hooks/useDiscounts"; import useDiscounts from "@/hooks/useDiscounts";
import PaymobPayment from "@/components/PaymobPayment"; import PaymobPayment from "@/components/PaymobPayment";
import moment from "moment";
interface Props { interface Props {
user: User; user: User;
@@ -40,7 +40,7 @@ export default function PaymentDue({user, hasExpired = false, clientID, reload}:
if (userDiscounts.length === 0) return; if (userDiscounts.length === 0) return;
const biggestDiscount = [...userDiscounts].sort((a, b) => b.percentage - a.percentage).shift(); const biggestDiscount = [...userDiscounts].sort((a, b) => b.percentage - a.percentage).shift();
if (!biggestDiscount) return; if (!biggestDiscount || (biggestDiscount.validUntil && moment(biggestDiscount.validUntil).isBefore(moment()))) return;
setAppliedDiscount(biggestDiscount.percentage); setAppliedDiscount(biggestDiscount.percentage);
}, [discounts, user]); }, [discounts, user]);
@@ -121,21 +121,18 @@ export default function PaymentDue({user, hasExpired = false, clientID, reload}:
</span> </span>
</div> </div>
<div className="flex w-full flex-col items-start gap-2"> <div className="flex w-full flex-col items-start gap-2">
{!appliedDiscount && ( {appliedDiscount === 0 && (
<span className="text-2xl"> <span className="text-2xl">
{p.price} {p.price} {p.currency}
{getSymbolFromCurrency(p.currency)}
</span> </span>
)} )}
{appliedDiscount && ( {appliedDiscount > 0 && (
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<span className="text-2xl line-through"> <span className="text-2xl line-through">
{p.price} {p.price} {p.currency}
{getSymbolFromCurrency(p.currency)}
</span> </span>
<span className="text-2xl text-mti-red-light"> <span className="text-2xl text-mti-red-light">
{(p.price - p.price * (appliedDiscount / 100)).toFixed(2)} {(p.price - p.price * (appliedDiscount / 100)).toFixed(2)} {p.currency}
{getSymbolFromCurrency(p.currency)}
</span> </span>
</div> </div>
)} )}
@@ -177,8 +174,7 @@ export default function PaymentDue({user, hasExpired = false, clientID, reload}:
</div> </div>
<div className="flex w-full flex-col items-start gap-2"> <div className="flex w-full flex-col items-start gap-2">
<span className="text-2xl"> <span className="text-2xl">
{user.corporateInformation.payment.value} {user.corporateInformation.payment.value} {user.corporateInformation.payment.currency}
{getSymbolFromCurrency(user.corporateInformation.payment.currency)}
</span> </span>
<PaymobPayment <PaymobPayment
key={clientID} key={clientID}

View File

@@ -30,6 +30,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
const audioFile = files.audio; const audioFile = files.audio;
const audioFileRef = ref(storage, `speaking_recordings/${fields.id}.wav`); const audioFileRef = ref(storage, `speaking_recordings/${fields.id}.wav`);
const task = parseInt(fields.task.toString());
const binary = fs.readFileSync((audioFile as any).path).buffer; const binary = fs.readFileSync((audioFile as any).path).buffer;
const snapshot = await uploadBytes(audioFileRef, binary); const snapshot = await uploadBytes(audioFileRef, binary);
@@ -39,7 +40,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
res.status(200).json(null); res.status(200).json(null);
console.log("🌱 - Still processing"); console.log("🌱 - Still processing");
const backendRequest = await evaluate({answers: [{question: fields.question, answer: path}]}); const backendRequest = await evaluate({answer: path, question: fields.question}, task);
console.log("🌱 - Process complete"); console.log("🌱 - Process complete");
const correspondingStat = await getCorrespondingStat(fields.id, 1); const correspondingStat = await getCorrespondingStat(fields.id, 1);
@@ -76,14 +77,14 @@ async function getCorrespondingStat(id: string, index: number): Promise<Stat> {
return getCorrespondingStat(id, index + 1); return getCorrespondingStat(id, index + 1);
} }
async function evaluate(body: {answers: object[]}): Promise<AxiosResponse> { async function evaluate(body: {answer: string; question: string}, task: number): Promise<AxiosResponse> {
const backendRequest = await axios.post(`${process.env.BACKEND_URL}/speaking_task_3`, body, { const backendRequest = await axios.post(`${process.env.BACKEND_URL}/speaking_task_${task}`, body, {
headers: { headers: {
Authorization: `Bearer ${process.env.BACKEND_JWT}`, Authorization: `Bearer ${process.env.BACKEND_JWT}`,
}, },
}); });
if (typeof backendRequest.data === "string") return evaluate(body); if (typeof backendRequest.data === "string") return evaluate(body, task);
return backendRequest; return backendRequest;
} }

View File

@@ -90,7 +90,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
if (updatedUser.status || updatedUser.type === "corporate") { if (updatedUser.status || updatedUser.type === "corporate") {
// there's no await as this does not affect the user // there's no await as this does not affect the user
propagateStatusChange(queryId, updatedUser.status); propagateStatusChange(queryId, updatedUser.status);
propagateExpiryDateChanges(queryId, user.subscriptionExpirationDate || null, updatedUser.subscriptionExpirationDate || null); propagateExpiryDateChanges(queryId, user.subscriptionExpirationDate, updatedUser.subscriptionExpirationDate || null);
} }
res.status(200).json({ok: true}); res.status(200).json({ok: true});

View File

@@ -2,15 +2,7 @@
import Head from "next/head"; import Head from "next/head";
import {withIronSessionSsr} from "iron-session/next"; import {withIronSessionSsr} from "iron-session/next";
import {sessionOptions} from "@/lib/session"; import {sessionOptions} from "@/lib/session";
import { import {ChangeEvent, Dispatch, ReactNode, SetStateAction, useEffect, useRef, useState} from "react";
ChangeEvent,
Dispatch,
ReactNode,
SetStateAction,
useEffect,
useRef,
useState,
} from "react";
import useUser from "@/hooks/useUser"; import useUser from "@/hooks/useUser";
import {toast, ToastContainer} from "react-toastify"; import {toast, ToastContainer} from "react-toastify";
import Layout from "@/components/High/Layout"; import Layout from "@/components/High/Layout";
@@ -20,13 +12,7 @@ import Link from "next/link";
import axios from "axios"; import axios from "axios";
import {ErrorMessage} from "@/constants/errors"; import {ErrorMessage} from "@/constants/errors";
import clsx from "clsx"; import clsx from "clsx";
import { import {CorporateUser, EmploymentStatus, EMPLOYMENT_STATUS, Gender, User} from "@/interfaces/user";
CorporateUser,
EmploymentStatus,
EMPLOYMENT_STATUS,
Gender,
User,
} from "@/interfaces/user";
import CountrySelect from "@/components/Low/CountrySelect"; import CountrySelect from "@/components/Low/CountrySelect";
import {shouldRedirectHome} from "@/utils/navigation.disabled"; import {shouldRedirectHome} from "@/utils/navigation.disabled";
import moment from "moment"; import moment from "moment";
@@ -78,9 +64,7 @@ interface Props {
mutateUser: Function; mutateUser: Function;
} }
const DoubleColumnRow = ({ children }: { children: ReactNode }) => ( const DoubleColumnRow = ({children}: {children: ReactNode}) => <div className="flex flex-col lg:flex-row gap-8 w-full">{children}</div>;
<div className="flex flex-col lg:flex-row gap-8 w-full">{children}</div>
);
function UserProfile({user, mutateUser}: Props) { function UserProfile({user, mutateUser}: Props) {
const [bio, setBio] = useState(user.bio || ""); const [bio, setBio] = useState(user.bio || "");
@@ -91,72 +75,35 @@ function UserProfile({ user, mutateUser }: Props) {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [profilePicture, setProfilePicture] = useState(user.profilePicture); const [profilePicture, setProfilePicture] = useState(user.profilePicture);
const [desiredLevels, setDesiredLevels] = useState< const [desiredLevels, setDesiredLevels] = useState<{[key in Module]: number} | undefined>(
{ [key in Module]: number } | undefined ["developer", "student"].includes(user.type) ? user.desiredLevels : undefined,
>(
["developer", "student"].includes(user.type)
? user.desiredLevels
: undefined,
); );
const [focus, setFocus] = useState<"academic" | "general">(user.focus);
const [country, setCountry] = useState<string>( const [country, setCountry] = useState<string>(user.demographicInformation?.country || "");
user.demographicInformation?.country || "", const [phone, setPhone] = useState<string>(user.demographicInformation?.phone || "");
); const [gender, setGender] = useState<Gender | undefined>(user.demographicInformation?.gender || undefined);
const [phone, setPhone] = useState<string>(
user.demographicInformation?.phone || "",
);
const [gender, setGender] = useState<Gender | undefined>(
user.demographicInformation?.gender || undefined,
);
const [employment, setEmployment] = useState<EmploymentStatus | undefined>( const [employment, setEmployment] = useState<EmploymentStatus | undefined>(
user.type === "corporate" user.type === "corporate" ? undefined : user.demographicInformation?.employment,
? undefined
: user.demographicInformation?.employment,
);
const [passport_id, setPassportID] = useState<string | undefined>(
user.type === "student"
? user.demographicInformation?.passport_id
: undefined,
); );
const [passport_id, setPassportID] = useState<string | undefined>(user.type === "student" ? user.demographicInformation?.passport_id : undefined);
const [preferredGender, setPreferredGender] = useState< const [preferredGender, setPreferredGender] = useState<InstructorGender | undefined>(
InstructorGender | undefined user.type === "student" || user.type === "developer" ? user.preferredGender || "varied" : undefined,
>(
user.type === "student" || user.type === "developer"
? user.preferredGender || "varied"
: undefined,
); );
const [preferredTopics, setPreferredTopics] = useState<string[] | undefined>( const [preferredTopics, setPreferredTopics] = useState<string[] | undefined>(
user.type === "student" || user.type === "developer" user.type === "student" || user.type === "developer" ? user.preferredTopics : undefined,
? user.preferredTopics
: undefined,
); );
const [position, setPosition] = useState<string | undefined>( const [position, setPosition] = useState<string | undefined>(user.type === "corporate" ? user.demographicInformation?.position : undefined);
user.type === "corporate" const [corporateInformation, setCorporateInformation] = useState(user.type === "corporate" ? user.corporateInformation : undefined);
? user.demographicInformation?.position const [companyName, setCompanyName] = useState<string | undefined>(user.type === "agent" ? user.agentInformation?.companyName : undefined);
: undefined, const [commercialRegistration, setCommercialRegistration] = useState<string | undefined>(
); user.type === "agent" ? user.agentInformation?.commercialRegistration : undefined,
const [corporateInformation, setCorporateInformation] = useState(
user.type === "corporate" ? user.corporateInformation : undefined,
);
const [companyName, setCompanyName] = useState<string | undefined>(
user.type === "agent" ? user.agentInformation?.companyName : undefined,
);
const [commercialRegistration, setCommercialRegistration] = useState<
string | undefined
>(
user.type === "agent"
? user.agentInformation?.commercialRegistration
: undefined,
);
const [arabName, setArabName] = useState<string | undefined>(
user.type === "agent" ? user.agentInformation?.companyArabName : undefined,
); );
const [arabName, setArabName] = useState<string | undefined>(user.type === "agent" ? user.agentInformation?.companyArabName : undefined);
const [timezone, setTimezone] = useState<string>( const [timezone, setTimezone] = useState<string>(user.demographicInformation?.timezone || moment.tz.guess());
user.demographicInformation?.timezone || moment.tz.guess(),
);
const [isPreferredTopicsOpen, setIsPreferredTopicsOpen] = useState(false); const [isPreferredTopicsOpen, setIsPreferredTopicsOpen] = useState(false);
@@ -168,12 +115,9 @@ function UserProfile({ user, mutateUser }: Props) {
const momentDate = moment(date); const momentDate = moment(date);
const today = moment(new Date()); const today = moment(new Date());
if (today.add(1, "days").isAfter(momentDate)) if (today.add(1, "days").isAfter(momentDate)) return "!bg-mti-red-ultralight border-mti-red-light";
return "!bg-mti-red-ultralight border-mti-red-light"; if (today.add(3, "days").isAfter(momentDate)) return "!bg-mti-rose-ultralight border-mti-rose-light";
if (today.add(3, "days").isAfter(momentDate)) if (today.add(7, "days").isAfter(momentDate)) return "!bg-mti-orange-ultralight border-mti-orange-light";
return "!bg-mti-rose-ultralight border-mti-rose-light";
if (today.add(7, "days").isAfter(momentDate))
return "!bg-mti-orange-ultralight border-mti-orange-light";
}; };
const uploadProfilePicture = async (event: ChangeEvent<HTMLInputElement>) => { const uploadProfilePicture = async (event: ChangeEvent<HTMLInputElement>) => {
@@ -193,20 +137,15 @@ function UserProfile({ user, mutateUser }: Props) {
} }
if (newPassword && !password) { if (newPassword && !password) {
toast.error( toast.error("To update your password you need to input your current one!");
"To update your password you need to input your current one!",
);
setIsLoading(false); setIsLoading(false);
return; return;
} }
if (email !== user?.email) { if (email !== user?.email) {
const userAdmins = groups const userAdmins = groups.filter((x) => x.participants.includes(user.id)).map((x) => x.admin);
.filter((x) => x.participants.includes(user.id))
.map((x) => x.admin);
const message = const message =
users.filter((x) => userAdmins.includes(x.id) && x.type === "corporate") users.filter((x) => userAdmins.includes(x.id) && x.type === "corporate").length > 0
.length > 0
? "If you change your e-mail address, you will lose all benefits from your university/institute. Are you sure you want to continue?" ? "If you change your e-mail address, you will lose all benefits from your university/institute. Are you sure you want to continue?"
: "Are you sure you want to update your e-mail address?"; : "Are you sure you want to update your e-mail address?";
@@ -227,6 +166,7 @@ function UserProfile({ user, mutateUser }: Props) {
desiredLevels, desiredLevels,
preferredGender, preferredGender,
preferredTopics, preferredTopics,
focus,
demographicInformation: { demographicInformation: {
phone, phone,
country, country,
@@ -266,9 +206,7 @@ function UserProfile({ user, mutateUser }: Props) {
const ExpirationDate = () => ( const ExpirationDate = () => (
<div className="flex flex-col gap-3 w-full"> <div className="flex flex-col gap-3 w-full">
<label className="font-normal text-base text-mti-gray-dim"> <label className="font-normal text-base text-mti-gray-dim">Expiry Date (click to purchase)</label>
Expiry Date (click to purchase)
</label>
<Link <Link
href="/payment" href="/payment"
className={clsx( className={clsx(
@@ -278,29 +216,21 @@ function UserProfile({ user, mutateUser }: Props) {
? "!bg-mti-green-ultralight !border-mti-green-light" ? "!bg-mti-green-ultralight !border-mti-green-light"
: expirationDateColor(user.subscriptionExpirationDate), : expirationDateColor(user.subscriptionExpirationDate),
"bg-white border-mti-gray-platinum", "bg-white border-mti-gray-platinum",
)} )}>
>
{!user.subscriptionExpirationDate && "Unlimited"} {!user.subscriptionExpirationDate && "Unlimited"}
{user.subscriptionExpirationDate && {user.subscriptionExpirationDate && moment(user.subscriptionExpirationDate).format("DD/MM/YYYY")}
moment(user.subscriptionExpirationDate).format("DD/MM/YYYY")}
</Link> </Link>
</div> </div>
); );
const TimezoneInput = () => ( const TimezoneInput = () => (
<div className="flex flex-col gap-3 w-full"> <div className="flex flex-col gap-3 w-full">
<label className="font-normal text-base text-mti-gray-dim"> <label className="font-normal text-base text-mti-gray-dim">Timezone</label>
Timezone
</label>
<TimezoneSelect value={timezone} onChange={setTimezone} /> <TimezoneSelect value={timezone} onChange={setTimezone} />
</div> </div>
); );
const manualDownloadLink = ["student", "teacher", "corporate"].includes( const manualDownloadLink = ["student", "teacher", "corporate"].includes(user.type) ? `/manuals/${user.type}.pdf` : "";
user.type,
)
? `/manuals/${user.type}.pdf`
: "";
return ( return (
<Layout user={user}> <Layout user={user}>
@@ -309,10 +239,7 @@ function UserProfile({ user, mutateUser }: Props) {
<div className="flex -md:flex-col-reverse -md:items-center w-full justify-between"> <div className="flex -md:flex-col-reverse -md:items-center w-full justify-between">
<div className="flex flex-col gap-8 w-full md:w-2/3"> <div className="flex flex-col gap-8 w-full md:w-2/3">
<h1 className="text-4xl font-bold mb-6 -md:hidden">Edit Profile</h1> <h1 className="text-4xl font-bold mb-6 -md:hidden">Edit Profile</h1>
<form <form className="flex flex-col items-center gap-6 w-full" onSubmit={(e) => e.preventDefault()}>
className="flex flex-col items-center gap-6 w-full"
onSubmit={(e) => e.preventDefault()}
>
<DoubleColumnRow> <DoubleColumnRow>
{user.type !== "corporate" ? ( {user.type !== "corporate" ? (
<Input <Input
@@ -408,9 +335,7 @@ function UserProfile({ user, mutateUser }: Props) {
<DoubleColumnRow> <DoubleColumnRow>
<div className="flex flex-col gap-3 w-full"> <div className="flex flex-col gap-3 w-full">
<label className="font-normal text-base text-mti-gray-dim"> <label className="font-normal text-base text-mti-gray-dim">Country *</label>
Country *
</label>
<CountrySelect value={country} onChange={setCountry} /> <CountrySelect value={country} onChange={setCountry} />
</div> </div>
<Input <Input
@@ -443,44 +368,55 @@ function UserProfile({ user, mutateUser }: Props) {
<Divider /> <Divider />
{desiredLevels && {desiredLevels && ["developer", "student"].includes(user.type) && (
["developer", "student"].includes(user.type) && ( <>
<div className="flex flex-col gap-3 w-full"> <div className="flex flex-col gap-3 w-full">
<label className="font-normal text-base text-mti-gray-dim"> <label className="font-normal text-base text-mti-gray-dim">Desired Levels</label>
Desired Levels
</label>
<ModuleLevelSelector <ModuleLevelSelector
levels={desiredLevels} levels={desiredLevels}
setLevels={ setLevels={setDesiredLevels as Dispatch<SetStateAction<{[key in Module]: number}>>}
setDesiredLevels as Dispatch<
SetStateAction<{ [key in Module]: number }>
>
}
/> />
</div> </div>
<div className="flex flex-col gap-3 w-full">
<label className="font-normal text-base text-mti-gray-dim">Focus</label>
<div className="grid grid-cols-1 md:grid-cols-2 gap-y-4 gap-x-16 w-full">
<button
onClick={() => setFocus("academic")}
className={clsx(
"w-full border border-mti-gray-platinum rounded-full px-6 py-4 flex justify-center items-center gap-12 bg-white",
"hover:bg-mti-purple-light hover:text-white",
focus === "academic" && "!bg-mti-purple-light !text-white",
"transition duration-300 ease-in-out",
)}>
Academic
</button>
<button
onClick={() => setFocus("general")}
className={clsx(
"w-full border border-mti-gray-platinum rounded-full px-6 py-4 flex justify-center items-center gap-12 bg-white",
"hover:bg-mti-purple-light hover:text-white",
focus === "general" && "!bg-mti-purple-light !text-white",
"transition duration-300 ease-in-out",
)}>
General
</button>
</div>
</div>
</>
)} )}
{preferredGender && {preferredGender && ["developer", "student"].includes(user.type) && (
["developer", "student"].includes(user.type) && (
<> <>
<Divider /> <Divider />
<DoubleColumnRow> <DoubleColumnRow>
<div className="flex flex-col gap-3 w-full"> <div className="flex flex-col gap-3 w-full">
<label className="font-normal text-base text-mti-gray-dim"> <label className="font-normal text-base text-mti-gray-dim">Speaking Instructor&apos;s Gender</label>
Speaking Instructor&apos;s Gender
</label>
<Select <Select
value={{ value={{
value: preferredGender, value: preferredGender,
label: capitalize(preferredGender), label: capitalize(preferredGender),
}} }}
onChange={(value) => onChange={(value) => (value ? setPreferredGender(value.value as InstructorGender) : null)}
value
? setPreferredGender(
value.value as InstructorGender,
)
: null
}
options={[ options={[
{value: "male", label: "Male"}, {value: "male", label: "Male"},
{value: "female", label: "Female"}, {value: "female", label: "Female"},
@@ -493,18 +429,12 @@ function UserProfile({ user, mutateUser }: Props) {
Preferred Topics{" "} Preferred Topics{" "}
<span <span
className="tooltip" className="tooltip"
data-tip="These topics will be considered for speaking and writing modules, aiming to include at least one exercise containing of the these in the selected exams." data-tip="These topics will be considered for speaking and writing modules, aiming to include at least one exercise containing of the these in the selected exams.">
>
<BsQuestionCircleFill /> <BsQuestionCircleFill />
</span> </span>
</label> </label>
<Button <Button className="w-full" variant="outline" onClick={() => setIsPreferredTopicsOpen(true)}>
className="w-full" Select Topics ({preferredTopics?.length || "All"} selected)
variant="outline"
onClick={() => setIsPreferredTopicsOpen(true)}
>
Select Topics ({preferredTopics?.length || "All"}{" "}
selected)
</Button> </Button>
</div> </div>
</DoubleColumnRow> </DoubleColumnRow>
@@ -529,9 +459,7 @@ function UserProfile({ user, mutateUser }: Props) {
name="companyUsers" name="companyUsers"
onChange={() => null} onChange={() => null}
label="Number of users" label="Number of users"
defaultValue={ defaultValue={user.corporateInformation.companyInformation.userAmount}
user.corporateInformation.companyInformation.userAmount
}
disabled disabled
required required
/> />
@@ -575,20 +503,14 @@ function UserProfile({ user, mutateUser }: Props) {
</> </>
)} )}
{user.type === "corporate" && {user.type === "corporate" && user.corporateInformation.referralAgent && (
user.corporateInformation.referralAgent && (
<> <>
<Divider /> <Divider />
<DoubleColumnRow> <DoubleColumnRow>
<Input <Input
name="agentName" name="agentName"
onChange={() => null} onChange={() => null}
defaultValue={ defaultValue={users.find((x) => x.id === user.corporateInformation.referralAgent)?.name}
users.find(
(x) =>
x.id === user.corporateInformation.referralAgent,
)?.name
}
type="text" type="text"
label="Country Manager's Name" label="Country Manager's Name"
placeholder="Not available" placeholder="Not available"
@@ -598,12 +520,7 @@ function UserProfile({ user, mutateUser }: Props) {
<Input <Input
name="agentEmail" name="agentEmail"
onChange={() => null} onChange={() => null}
defaultValue={ defaultValue={users.find((x) => x.id === user.corporateInformation.referralAgent)?.email}
users.find(
(x) =>
x.id === user.corporateInformation.referralAgent,
)?.email
}
type="text" type="text"
label="Country Manager's E-mail" label="Country Manager's E-mail"
placeholder="Not available" placeholder="Not available"
@@ -613,16 +530,11 @@ function UserProfile({ user, mutateUser }: Props) {
</DoubleColumnRow> </DoubleColumnRow>
<DoubleColumnRow> <DoubleColumnRow>
<div className="flex flex-col gap-2 w-full"> <div className="flex flex-col gap-2 w-full">
<label className="font-normal text-base text-mti-gray-dim"> <label className="font-normal text-base text-mti-gray-dim">Country Manager&apos;s Country *</label>
Country Manager&apos;s Country *
</label>
<CountrySelect <CountrySelect
value={ value={
users.find( users.find((x) => x.id === user.corporateInformation.referralAgent)?.demographicInformation
(x) => ?.country
x.id ===
user.corporateInformation.referralAgent,
)?.demographicInformation?.country
} }
onChange={() => null} onChange={() => null}
disabled disabled
@@ -636,10 +548,7 @@ function UserProfile({ user, mutateUser }: Props) {
onChange={() => null} onChange={() => null}
placeholder="Not available" placeholder="Not available"
defaultValue={ defaultValue={
users.find( users.find((x) => x.id === user.corporateInformation.referralAgent)?.demographicInformation?.phone
(x) =>
x.id === user.corporateInformation.referralAgent,
)?.demographicInformation?.phone
} }
disabled disabled
required required
@@ -650,10 +559,7 @@ function UserProfile({ user, mutateUser }: Props) {
{user.type !== "corporate" && ( {user.type !== "corporate" && (
<DoubleColumnRow> <DoubleColumnRow>
<EmploymentStatusInput <EmploymentStatusInput value={employment} onChange={setEmployment} />
value={employment}
onChange={setEmployment}
/>
<div className="flex flex-col gap-8 w-full"> <div className="flex flex-col gap-8 w-full">
<GenderInput value={gender} onChange={setGender} /> <GenderInput value={gender} onChange={setGender} />
@@ -666,62 +572,37 @@ function UserProfile({ user, mutateUser }: Props) {
<div className="flex flex-col gap-6 w-48"> <div className="flex flex-col gap-6 w-48">
<div <div
className="flex flex-col gap-3 items-center h-fit cursor-pointer group" className="flex flex-col gap-3 items-center h-fit cursor-pointer group"
onClick={() => (profilePictureInput.current as any)?.click()} onClick={() => (profilePictureInput.current as any)?.click()}>
>
<div className="relative overflow-hidden h-48 w-48 rounded-full"> <div className="relative overflow-hidden h-48 w-48 rounded-full">
<div <div
className={clsx( className={clsx(
"absolute top-0 left-0 bg-mti-purple-light/60 w-full h-full z-20 flex items-center justify-center opacity-0 group-hover:opacity-100", "absolute top-0 left-0 bg-mti-purple-light/60 w-full h-full z-20 flex items-center justify-center opacity-0 group-hover:opacity-100",
"transition ease-in-out duration-300", "transition ease-in-out duration-300",
)} )}>
>
<BsCamera className="text-6xl text-mti-purple-ultralight/80" /> <BsCamera className="text-6xl text-mti-purple-ultralight/80" />
</div> </div>
<img <img src={profilePicture} alt={user.name} className="aspect-square drop-shadow-xl self-end object-cover" />
src={profilePicture}
alt={user.name}
className="aspect-square drop-shadow-xl self-end object-cover"
/>
</div> </div>
<input <input type="file" className="hidden" onChange={uploadProfilePicture} accept="image/*" ref={profilePictureInput} />
type="file"
className="hidden"
onChange={uploadProfilePicture}
accept="image/*"
ref={profilePictureInput}
/>
<span <span
onClick={() => (profilePictureInput.current as any)?.click()} onClick={() => (profilePictureInput.current as any)?.click()}
className="cursor-pointer text-mti-purple-light text-sm" className="cursor-pointer text-mti-purple-light text-sm">
>
Change picture Change picture
</span> </span>
<h6 className="font-normal text-base text-mti-gray-taupe"> <h6 className="font-normal text-base text-mti-gray-taupe">{USER_TYPE_LABELS[user.type]}</h6>
{USER_TYPE_LABELS[user.type]}
</h6>
</div> </div>
{user.type === "agent" && ( {user.type === "agent" && (
<div className="flag items-center h-fit"> <div className="flag items-center h-fit">
<img <img
alt={ alt={user.demographicInformation?.country.toLowerCase() + "_flag"}
user.demographicInformation?.country.toLowerCase() + "_flag"
}
src={`https://flagcdn.com/w320/${user.demographicInformation?.country.toLowerCase()}.png`} src={`https://flagcdn.com/w320/${user.demographicInformation?.country.toLowerCase()}.png`}
width="320" width="320"
/> />
</div> </div>
)} )}
{manualDownloadLink && ( {manualDownloadLink && (
<a <a href={manualDownloadLink} className="max-w-[200px] self-end w-full" download>
href={manualDownloadLink} <Button color="purple" variant="outline" className="max-w-[200px] self-end w-full">
className="max-w-[200px] self-end w-full"
download
>
<Button
color="purple"
variant="outline"
className="max-w-[200px] self-end w-full"
>
Download Manual Download Manual
</Button> </Button>
</a> </a>
@@ -740,20 +621,11 @@ function UserProfile({ user, mutateUser }: Props) {
<div className="self-end flex justify-between w-full gap-8 absolute bottom-8 left-0 px-8"> <div className="self-end flex justify-between w-full gap-8 absolute bottom-8 left-0 px-8">
<Link href="/" className="max-w-[200px] self-end w-full"> <Link href="/" className="max-w-[200px] self-end w-full">
<Button <Button color="purple" variant="outline" className="max-w-[200px] self-end w-full">
color="purple"
variant="outline"
className="max-w-[200px] self-end w-full"
>
Back Back
</Button> </Button>
</Link> </Link>
<Button <Button color="purple" className="max-w-[200px] self-end w-full" onClick={updateUser} disabled={isLoading}>
color="purple"
className="max-w-[200px] self-end w-full"
onClick={updateUser}
disabled={isLoading}
>
Save Changes Save Changes
</Button> </Button>
</div> </div>

View File

@@ -95,4 +95,8 @@ export const CURRENCIES: {label: string; currency: string}[] = [
label: "United States dollar", label: "United States dollar",
currency: "USD", currency: "USD",
}, },
{
label: "Omani rial",
currency: "OMR",
},
]; ];

View File

@@ -45,10 +45,11 @@ export const evaluateSpeakingAnswer = async (
exercise: SpeakingExercise | InteractiveSpeakingExercise, exercise: SpeakingExercise | InteractiveSpeakingExercise,
solution: UserSolution, solution: UserSolution,
id: string, id: string,
task: number,
): Promise<UserSolution | undefined> => { ): Promise<UserSolution | undefined> => {
switch (exercise?.type) { switch (exercise?.type) {
case "speaking": case "speaking":
return {...(await evaluateSpeakingExercise(exercise, exercise.id, solution, id)), id} as UserSolution; return {...(await evaluateSpeakingExercise(exercise, exercise.id, solution, id, task)), id} as UserSolution;
case "interactiveSpeaking": case "interactiveSpeaking":
return {...(await evaluateInteractiveSpeakingExercise(exercise.id, solution, id)), id} as UserSolution; return {...(await evaluateInteractiveSpeakingExercise(exercise.id, solution, id)), id} as UserSolution;
default: default:
@@ -66,6 +67,7 @@ const evaluateSpeakingExercise = async (
exerciseId: string, exerciseId: string,
solution: UserSolution, solution: UserSolution,
id: string, id: string,
task: number,
): Promise<UserSolution | undefined> => { ): Promise<UserSolution | undefined> => {
const formData = new FormData(); const formData = new FormData();
@@ -81,6 +83,7 @@ const evaluateSpeakingExercise = async (
`${exercise.text.replaceAll("\n", "")}` + (exercise.prompts.length > 0 ? `You should talk about: ${exercise.prompts.join(", ")}` : ""); `${exercise.text.replaceAll("\n", "")}` + (exercise.prompts.length > 0 ? `You should talk about: ${exercise.prompts.join(", ")}` : "");
formData.append("question", evaluationQuestion); formData.append("question", evaluationQuestion);
formData.append("id", id); formData.append("id", id);
formData.append("task", task.toString());
const config = { const config = {
headers: { headers: {

View File

@@ -67,7 +67,7 @@ export const propagateStatusChange = (userId: string, status: UserStatus) =>
}); });
}); });
export const propagateExpiryDateChanges = (userId: string, initialExpiryDate: Date | null, subscriptionExpirationDate: Date | null) => export const propagateExpiryDateChanges = (userId: string, initialExpiryDate: Date | null | undefined, subscriptionExpirationDate: Date | null) =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
getDoc(doc(db, "users", userId)) getDoc(doc(db, "users", userId))
.then((docUser) => { .then((docUser) => {
@@ -93,6 +93,7 @@ export const propagateExpiryDateChanges = (userId: string, initialExpiryDate: Da
.then(async (data) => { .then(async (data) => {
const filtered = data.filter((x) => { const filtered = data.filter((x) => {
if (x === null) return false; if (x === null) return false;
if (!x.subscriptionExpirationDate && !initialExpiryDate) return true;
if (x.subscriptionExpirationDate !== initialExpiryDate) return false; if (x.subscriptionExpirationDate !== initialExpiryDate) return false;
return true; return true;
}) as User[]; }) as User[];

View File

@@ -4870,13 +4870,6 @@ path-type@^4.0.0:
resolved "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz" resolved "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz"
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
"paymob-react@git+https://github.com/tiago-ecrop/paymob-react-oman.git":
version "1.0.0"
resolved "git+https://github.com/tiago-ecrop/paymob-react-oman.git#9e7d1e86f01d29dd10192bbd371517849a264e5d"
dependencies:
react "^18.2.0"
react-dom "^18.2.0"
picocolors@^1.0.0: picocolors@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz" resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz"
@@ -5208,14 +5201,6 @@ react-dom@18.2.0:
loose-envify "^1.1.0" loose-envify "^1.1.0"
scheduler "^0.23.0" scheduler "^0.23.0"
react-dom@^18.2.0:
version "18.3.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.3.1.tgz#c2265d79511b57d479b3dd3fdfa51536494c5cb4"
integrity sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==
dependencies:
loose-envify "^1.1.0"
scheduler "^0.23.2"
react-fast-compare@^3.0.1: react-fast-compare@^3.0.1:
version "3.2.1" version "3.2.1"
resolved "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.1.tgz" resolved "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.1.tgz"
@@ -5345,13 +5330,6 @@ react@18.2.0:
dependencies: dependencies:
loose-envify "^1.1.0" loose-envify "^1.1.0"
react@^18.2.0:
version "18.3.1"
resolved "https://registry.yarnpkg.com/react/-/react-18.3.1.tgz#49ab892009c53933625bd16b2533fc754cab2891"
integrity sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==
dependencies:
loose-envify "^1.1.0"
read-cache@^1.0.0: read-cache@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz" resolved "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz"
@@ -5557,13 +5535,6 @@ scheduler@^0.23.0:
dependencies: dependencies:
loose-envify "^1.1.0" loose-envify "^1.1.0"
scheduler@^0.23.2:
version "0.23.2"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.23.2.tgz#414ba64a3b282892e944cf2108ecc078d115cdc3"
integrity sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==
dependencies:
loose-envify "^1.1.0"
seedrandom@^3.0.5: seedrandom@^3.0.5:
version "3.0.5" version "3.0.5"
resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7" resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7"