diff --git a/src/front/Components/Layouts/Login/index.tsx b/src/front/Components/Layouts/Login/index.tsx index 7c8ca0a1..0069ad29 100644 --- a/src/front/Components/Layouts/Login/index.tsx +++ b/src/front/Components/Layouts/Login/index.tsx @@ -77,7 +77,7 @@ export default function Login() { confirmText={"OK"}>
- Une erreur est survenue lors de la connexion. Veuillez réessayer. + Vous ne disposez pas d'un abonnement, veuillez contacter l'administrateur de votre office.
diff --git a/src/front/Components/Layouts/Subscription/Components/SubscribeCheckoutTicket/index.tsx b/src/front/Components/Layouts/Subscription/Components/SubscribeCheckoutTicket/index.tsx index 261bab7d..87d421cb 100644 --- a/src/front/Components/Layouts/Subscription/Components/SubscribeCheckoutTicket/index.tsx +++ b/src/front/Components/Layouts/Subscription/Components/SubscribeCheckoutTicket/index.tsx @@ -21,6 +21,7 @@ type IProps = { numberOfCollaborators: number; hasNavTab?: boolean; defaultFrequency?: EPaymentFrequency; + disableInputs?: boolean; }; export enum EPaymentFrequency { @@ -72,14 +73,16 @@ export default function SubscribeCheckoutTicket(props: IProps) { name="paymentFrequency" value={EPaymentFrequency.yearly.toString()} onChange={handleFrequencyChange} - defaultChecked={paymentFrequency === EPaymentFrequency.yearly}> + defaultChecked={paymentFrequency === EPaymentFrequency.yearly} + disabled={props.disableInputs}> Annuel + defaultChecked={paymentFrequency === EPaymentFrequency.monthly} + disabled={props.disableInputs}> Mensuel @@ -186,9 +189,11 @@ export default function SubscribeCheckoutTicket(props: IProps) { )} - + {!props.disableInputs && ( + + )} ); diff --git a/src/front/Components/Layouts/Subscription/Components/SubscriptionTicket/classes.module.scss b/src/front/Components/Layouts/Subscription/Components/SubscriptionTicket/classes.module.scss deleted file mode 100644 index a0312271..00000000 --- a/src/front/Components/Layouts/Subscription/Components/SubscriptionTicket/classes.module.scss +++ /dev/null @@ -1,31 +0,0 @@ -.root { - width: 372px; - display: flex; - flex-direction: column; - gap: 40px; - - box-shadow: 0px 8px 10px 0px #00000012; - padding: 24px; - border-radius: 16px; - .top-category { - display: flex; - justify-content: center; - align-items: center; - } - - .category { - display: flex; - flex-direction: column; - gap: 8px; - .line { - display: flex; - justify-content: space-between; - } - } - - .separator { - width: 100%; - height: 2px; - background: var(--grey-medium); - } -} diff --git a/src/front/Components/Layouts/Subscription/Components/SubscriptionTicket/index.tsx b/src/front/Components/Layouts/Subscription/Components/SubscriptionTicket/index.tsx deleted file mode 100644 index 89d34d4c..00000000 --- a/src/front/Components/Layouts/Subscription/Components/SubscriptionTicket/index.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography"; -import classes from "./classes.module.scss"; - -type IProps = {}; -export default function SubscriptionTicket(props: IProps) { - return ( -
-
- - Récapitulatif - -
-
- -
- - Forfait standard - -
-
-
-
- - Plan individuel - - - 99 € - -
-
- - 2 collaborateurs - - - 13,98 € - -
-
- - 6,99 € x 2 - -
-
-
-
-
- - Sous-total - - - 112,98 € - -
-
- - FR TVA - - - 14 € - -
-
- - Taxes - - - 14 € - -
-
-
-
-
- - Total - - - 112,98 € - -
-
-
- ); -} diff --git a/src/front/Components/Layouts/Subscription/SubscriptionError/classes.module.scss b/src/front/Components/Layouts/Subscription/SubscriptionError/classes.module.scss index c0508d64..e7d63d20 100644 --- a/src/front/Components/Layouts/Subscription/SubscriptionError/classes.module.scss +++ b/src/front/Components/Layouts/Subscription/SubscriptionError/classes.module.scss @@ -3,7 +3,11 @@ gap: 104px; justify-content: center; + max-width: 1200px; + margin: auto; + .left { + flex: 1; display: flex; flex-direction: column; gap: 32px; diff --git a/src/front/Components/Layouts/Subscription/SubscriptionError/index.tsx b/src/front/Components/Layouts/Subscription/SubscriptionError/index.tsx index 22dc4b5c..1c9cab17 100644 --- a/src/front/Components/Layouts/Subscription/SubscriptionError/index.tsx +++ b/src/front/Components/Layouts/Subscription/SubscriptionError/index.tsx @@ -1,41 +1,77 @@ import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate"; import classes from "./classes.module.scss"; -import SubscriptionTicket from "../Components/SubscriptionTicket"; import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography"; import MessageBox from "@Front/Components/Elements/MessageBox"; import SubscriptionClientInfos from "../Components/SubscriptionClientInfos"; import Button from "@Front/Components/DesignSystem/Button"; +import { useCallback, useEffect, useState } from "react"; +import { Subscription } from "le-coffre-resources/dist/Admin"; +import JwtService from "@Front/Services/JwtService/JwtService"; +import Subscriptions from "@Front/Api/LeCoffreApi/Admin/Subscriptions/Subscriptions"; +import SubscribeCheckoutTicket, { EPaymentFrequency } from "../Components/SubscribeCheckoutTicket"; +import { EForfeitType } from "../SubscriptionFacturation"; export default function SubscriptionError() { + const [subscription, setSubscription] = useState(null); + + const loadSubscription = useCallback(async () => { + const jwt = JwtService.getInstance().decodeJwt(); + const subscription = await Subscriptions.getInstance().get({ where: { office: { uid: jwt?.office_Id } } }); + console.log(subscription); + if (!subscription[0]) return; + setSubscription(subscription[0]); + }, []); + + const getFrequency = useCallback(() => { + if (!subscription) return; + const start = new Date(subscription.start_date); + const end = new Date(subscription.end_date); + + const diffTime = Math.abs(end.getTime() - start.getTime()); + const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); + return diffDays >= 365 ? EPaymentFrequency.yearly : EPaymentFrequency.monthly; + }, [subscription]); + + useEffect(() => { + loadSubscription(); + }, [loadSubscription]); + return ( -
-
-
- - Paiement échoué - + {subscription && ( +
+
+
+ + Paiement échoué + +
+
+ + Votre transaction n'a pas pu être complétée. +
+
+ Malheureusement, nous n'avons pas pu traiter votre paiement et votre abonnement n'a pas été activé. Veuillez + vérifier vos informations de paiement et essayer à nouveau. +
+
+
+
+ +
+
+
-
- - Votre transaction n'a pas pu être complétée. -
-
- Malheureusement, nous n'avons pas pu traiter votre paiement et votre abonnement n'a pas été activé. Veuillez - vérifier vos informations de paiement et essayer à nouveau. -
+
+
-
-
- -
-
-
-
- -
-
+ )} ); } diff --git a/src/front/Components/Layouts/Subscription/SubscriptionInvite/index.tsx b/src/front/Components/Layouts/Subscription/SubscriptionInvite/index.tsx index 82dbcccb..eb3fa504 100644 --- a/src/front/Components/Layouts/Subscription/SubscriptionInvite/index.tsx +++ b/src/front/Components/Layouts/Subscription/SubscriptionInvite/index.tsx @@ -9,11 +9,8 @@ import Subscriptions from "@Front/Api/LeCoffreApi/Admin/Subscriptions/Subscripti import { useCallback, useState } from "react"; import { TrashIcon } from "@heroicons/react/24/outline"; import PlusIcon from "@Assets/Icons/plus.svg"; +import Module from "@Front/Config/Module"; -export enum EForfeitType { - "standard", - "unlimited", -} type EmailLine = { element: JSX.Element; id: number; @@ -55,6 +52,7 @@ export default function SubscriptionInvite() { await Subscriptions.getInstance().post({ emails, }); + router.push(Module.getInstance().get().modules.pages.Subscription.pages.Manage.props.path); } catch (e) { console.error(e); } diff --git a/src/front/Components/Layouts/Subscription/SubscriptionNew/index.tsx b/src/front/Components/Layouts/Subscription/SubscriptionNew/index.tsx index accd6b67..dd780c11 100644 --- a/src/front/Components/Layouts/Subscription/SubscriptionNew/index.tsx +++ b/src/front/Components/Layouts/Subscription/SubscriptionNew/index.tsx @@ -8,7 +8,7 @@ import Link from "next/link"; export default function SubscriptionNew() { return ( - +
diff --git a/src/front/Components/Layouts/Subscription/SubscriptionSuccess/classes.module.scss b/src/front/Components/Layouts/Subscription/SubscriptionSuccess/classes.module.scss index c0508d64..e7d63d20 100644 --- a/src/front/Components/Layouts/Subscription/SubscriptionSuccess/classes.module.scss +++ b/src/front/Components/Layouts/Subscription/SubscriptionSuccess/classes.module.scss @@ -3,7 +3,11 @@ gap: 104px; justify-content: center; + max-width: 1200px; + margin: auto; + .left { + flex: 1; display: flex; flex-direction: column; gap: 32px; diff --git a/src/front/Components/Layouts/Subscription/SubscriptionSuccess/index.tsx b/src/front/Components/Layouts/Subscription/SubscriptionSuccess/index.tsx index 2f79ee80..6a4c2666 100644 --- a/src/front/Components/Layouts/Subscription/SubscriptionSuccess/index.tsx +++ b/src/front/Components/Layouts/Subscription/SubscriptionSuccess/index.tsx @@ -1,44 +1,91 @@ import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate"; import classes from "./classes.module.scss"; -import SubscriptionTicket from "../Components/SubscriptionTicket"; import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography"; import MessageBox from "@Front/Components/Elements/MessageBox"; import SubscriptionClientInfos from "../Components/SubscriptionClientInfos"; import Button from "@Front/Components/DesignSystem/Button"; import Link from "next/link"; import Module from "@Front/Config/Module"; +import { EForfeitType } from "../SubscriptionFacturation"; +import SubscribeCheckoutTicket, { EPaymentFrequency } from "../Components/SubscribeCheckoutTicket"; +import { useCallback, useEffect, useState } from "react"; +import Subscriptions from "@Front/Api/LeCoffreApi/Admin/Subscriptions/Subscriptions"; +import JwtService from "@Front/Services/JwtService/JwtService"; +import { Subscription } from "le-coffre-resources/dist/Admin"; export default function SubscriptionSuccess() { + const [subscription, setSubscription] = useState(null); + + const loadSubscription = useCallback(async () => { + const jwt = JwtService.getInstance().decodeJwt(); + const subscription = await Subscriptions.getInstance().get({ where: { office: { uid: jwt?.office_Id } } }); + console.log(subscription); + if (!subscription[0]) return; + setSubscription(subscription[0]); + }, []); + + const getFrequency = useCallback(() => { + if (!subscription) return; + const start = new Date(subscription.start_date); + const end = new Date(subscription.end_date); + + const diffTime = Math.abs(end.getTime() - start.getTime()); + const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); + return diffDays >= 365 ? EPaymentFrequency.yearly : EPaymentFrequency.monthly; + }, [subscription]); + + useEffect(() => { + loadSubscription(); + }, [loadSubscription]); + return ( -
-
-
- - Abonnement réussi ! - + {subscription && ( +
+
+
+ + Abonnement réussi ! + +
+
+ + Votre transaction a été effectuée avec succès ! +
+
+ Votre abonnement a été pris en compte et est désormais actif. +
+
+
+
+ +
+
+ {subscription.type === "STANDARD" && ( + + + + )} + {subscription.type === "UNLIMITED" && ( + + + + )}
-
- - Votre transaction a été effectuée avec succès ! -
-
- Votre abonnement a été pris en compte et est désormais actif. -
+
+
-
-
- -
-
- - -
-
- -
-
+ )} ); }