Merge branch 'dev' into staging
This commit is contained in:
commit
e9ef22bb55
6
package-lock.json
generated
6
package-lock.json
generated
@ -32,6 +32,7 @@
|
|||||||
"react-toastify": "^9.1.3",
|
"react-toastify": "^9.1.3",
|
||||||
"sass": "^1.59.2",
|
"sass": "^1.59.2",
|
||||||
"sharp": "^0.32.1",
|
"sharp": "^0.32.1",
|
||||||
|
"ts-pattern": "^5.1.1",
|
||||||
"typescript": "4.9.5",
|
"typescript": "4.9.5",
|
||||||
"uuidv4": "^6.2.13"
|
"uuidv4": "^6.2.13"
|
||||||
}
|
}
|
||||||
@ -4910,6 +4911,11 @@
|
|||||||
"node": ">=8.0"
|
"node": ">=8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/ts-pattern": {
|
||||||
|
"version": "5.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ts-pattern/-/ts-pattern-5.1.1.tgz",
|
||||||
|
"integrity": "sha512-i+owkHr5RYdQxj8olUgRrqpiWH9x27PuWVfXwDmJ/n/CoF/SAa7WW1i2oUpPDMQpJ4U+bGRUcZkVq7i1m3zFCg=="
|
||||||
|
},
|
||||||
"node_modules/tsconfig-paths": {
|
"node_modules/tsconfig-paths": {
|
||||||
"version": "3.15.0",
|
"version": "3.15.0",
|
||||||
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz",
|
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz",
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
"react-toastify": "^9.1.3",
|
"react-toastify": "^9.1.3",
|
||||||
"sass": "^1.59.2",
|
"sass": "^1.59.2",
|
||||||
"sharp": "^0.32.1",
|
"sharp": "^0.32.1",
|
||||||
|
"ts-pattern": "^5.1.1",
|
||||||
"typescript": "4.9.5",
|
"typescript": "4.9.5",
|
||||||
"uuidv4": "^6.2.13"
|
"uuidv4": "^6.2.13"
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,10 @@
|
|||||||
.line-sub-container {
|
.line-sub-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
|
.stroked-price {
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import classnames from "classnames";
|
|||||||
import { EType } from "le-coffre-resources/dist/Admin/Subscription";
|
import { EType } from "le-coffre-resources/dist/Admin/Subscription";
|
||||||
import Stripe from "@Front/Api/LeCoffreApi/Admin/Stripe/Stripe";
|
import Stripe from "@Front/Api/LeCoffreApi/Admin/Stripe/Stripe";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
import * as P from "ts-pattern";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
forfeitType: EForfeitType;
|
forfeitType: EForfeitType;
|
||||||
@ -27,11 +28,26 @@ export default function SubscribeCheckoutTicket(props: IProps) {
|
|||||||
const { forfeitType, numberOfCollaborators, hasNavTab = true } = props;
|
const { forfeitType, numberOfCollaborators, hasNavTab = true } = props;
|
||||||
const [paymentFrequency, setPaymentFrequency] = useState<EPaymentFrequency>(props.defaultFrequency ?? EPaymentFrequency.monthly);
|
const [paymentFrequency, setPaymentFrequency] = useState<EPaymentFrequency>(props.defaultFrequency ?? EPaymentFrequency.monthly);
|
||||||
const [multiplier, setMultiplier] = useState<number>(1);
|
const [multiplier, setMultiplier] = useState<number>(1);
|
||||||
|
const [totalPlan, setTotalPlan] = useState<number>(0);
|
||||||
|
const [totalCollaborator, setTotalCollaborator] = useState<number>(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setMultiplier(paymentFrequency === EPaymentFrequency.monthly ? 1 : 12);
|
setMultiplier(paymentFrequency === EPaymentFrequency.monthly ? 1 : 12);
|
||||||
}, [paymentFrequency]);
|
}, [paymentFrequency]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let multiplierToUse = paymentFrequency === EPaymentFrequency.yearly ? multiplier - 1 : multiplier;
|
||||||
|
P.match(forfeitType)
|
||||||
|
.with(EForfeitType.standard, () => {
|
||||||
|
setTotalPlan(forfeitsPrices[EForfeitType.standard] * multiplierToUse);
|
||||||
|
setTotalCollaborator(collaboratorPrice * numberOfCollaborators * multiplier);
|
||||||
|
})
|
||||||
|
.with(EForfeitType.unlimited, () => {
|
||||||
|
setTotalPlan(forfeitsPrices[EForfeitType.unlimited] * multiplierToUse);
|
||||||
|
setTotalCollaborator(0);
|
||||||
|
});
|
||||||
|
}, [multiplier, forfeitType, numberOfCollaborators, paymentFrequency]);
|
||||||
|
|
||||||
const handleFrequencyChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleFrequencyChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
setPaymentFrequency(parseInt(e.target.value) as EPaymentFrequency);
|
setPaymentFrequency(parseInt(e.target.value) as EPaymentFrequency);
|
||||||
};
|
};
|
||||||
@ -88,20 +104,31 @@ export default function SubscribeCheckoutTicket(props: IProps) {
|
|||||||
</Typography>
|
</Typography>
|
||||||
{paymentFrequency === EPaymentFrequency.yearly && (
|
{paymentFrequency === EPaymentFrequency.yearly && (
|
||||||
<Typography typo={ITypo.CAPTION_14_SB} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.CAPTION_14_SB} color={ITypoColor.BLACK}>
|
||||||
{forfeitType === EForfeitType.standard
|
{formatFloat(
|
||||||
? forfeitsPrices[EForfeitType.standard]
|
forfeitType === EForfeitType.standard
|
||||||
: forfeitsPrices[EForfeitType.unlimited]}
|
? forfeitsPrices[EForfeitType.standard]
|
||||||
€ x 12
|
: forfeitsPrices[EForfeitType.unlimited],
|
||||||
|
)}
|
||||||
|
€ x 11
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
<div className={classes["line-sub-container"]}>
|
||||||
{forfeitType === EForfeitType.standard
|
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
||||||
? forfeitsPrices[EForfeitType.standard] * multiplier
|
{totalPlan} €
|
||||||
: forfeitsPrices[EForfeitType.unlimited] * multiplier}
|
</Typography>
|
||||||
€
|
{paymentFrequency === EPaymentFrequency.yearly && (
|
||||||
</Typography>
|
<Typography typo={ITypo.P_16} color={ITypoColor.BLACK} className={classes["stroked-price"]}>
|
||||||
|
{formatFloat(
|
||||||
|
forfeitType === EForfeitType.standard
|
||||||
|
? forfeitsPrices[EForfeitType.standard] * multiplier
|
||||||
|
: forfeitsPrices[EForfeitType.unlimited] * multiplier,
|
||||||
|
)}
|
||||||
|
€
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{forfeitType === EForfeitType.standard && (
|
{forfeitType === EForfeitType.standard && (
|
||||||
<div className={classes["line"]}>
|
<div className={classes["line"]}>
|
||||||
@ -110,11 +137,12 @@ export default function SubscribeCheckoutTicket(props: IProps) {
|
|||||||
{numberOfCollaborators} collaborateurs
|
{numberOfCollaborators} collaborateurs
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography typo={ITypo.CAPTION_14_SB} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.CAPTION_14_SB} color={ITypoColor.BLACK}>
|
||||||
{formatFloat(collaboratorPrice)} € x {numberOfCollaborators}
|
{formatFloat(collaboratorPrice)} € x {numberOfCollaborators}{" "}
|
||||||
|
{paymentFrequency === EPaymentFrequency.yearly && "x 12"}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
||||||
{formatFloat(collaboratorPrice * numberOfCollaborators * multiplier)} €
|
{formatFloat(totalCollaborator)} €
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -128,9 +156,7 @@ export default function SubscribeCheckoutTicket(props: IProps) {
|
|||||||
Total HT
|
Total HT
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
||||||
{formatFloat(
|
{formatFloat(totalCollaborator + totalPlan)}
|
||||||
(forfeitsPrices[EForfeitType.standard] + collaboratorPrice * numberOfCollaborators) * multiplier,
|
|
||||||
)}
|
|
||||||
€
|
€
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
@ -139,11 +165,7 @@ export default function SubscribeCheckoutTicket(props: IProps) {
|
|||||||
TVA 20%
|
TVA 20%
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
||||||
{formatFloat(
|
{formatFloat((totalCollaborator + totalPlan) * 0.2)}
|
||||||
(forfeitsPrices[EForfeitType.standard] + collaboratorPrice * numberOfCollaborators) *
|
|
||||||
0.2 *
|
|
||||||
multiplier,
|
|
||||||
)}
|
|
||||||
€
|
€
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
@ -158,7 +180,7 @@ export default function SubscribeCheckoutTicket(props: IProps) {
|
|||||||
TVA 20%
|
TVA 20%
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
||||||
{formatFloat(forfeitsPrices[EForfeitType.unlimited] * 0.2 * multiplier)} €
|
{formatFloat((totalCollaborator + totalPlan) * 0.2)} €
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -166,20 +188,10 @@ export default function SubscribeCheckoutTicket(props: IProps) {
|
|||||||
<Typography typo={ITypo.P_18} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.P_18} color={ITypoColor.BLACK}>
|
||||||
Total TTC
|
Total TTC
|
||||||
</Typography>
|
</Typography>
|
||||||
{forfeitType === EForfeitType.standard && (
|
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
||||||
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
{formatFloat((totalCollaborator + totalPlan) * 1.2)}
|
||||||
{formatFloat(
|
€
|
||||||
(forfeitsPrices[EForfeitType.standard] + collaboratorPrice * numberOfCollaborators) * 1.2 * multiplier,
|
</Typography>
|
||||||
)}
|
|
||||||
€
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
{forfeitType === EForfeitType.unlimited && (
|
|
||||||
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
|
||||||
{formatFloat(forfeitsPrices[EForfeitType.unlimited] * 1.2 * multiplier)}
|
|
||||||
€
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{!props.disableInputs && (
|
{!props.disableInputs && (
|
||||||
|
@ -66,6 +66,11 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
|
||||||
|
.price {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-container {
|
.button-container {
|
||||||
|
@ -121,7 +121,7 @@ export default function SubscriptionFacturation() {
|
|||||||
</div>
|
</div>
|
||||||
<div className={classes["separator"]} />
|
<div className={classes["separator"]} />
|
||||||
<div className={classes["price-container"]}>
|
<div className={classes["price-container"]}>
|
||||||
<Typography typo={ITypo.H1} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.H1} color={ITypoColor.BLACK} className={classes["price"]}>
|
||||||
{forfeitsPrices[EForfeitType.standard]}€
|
{forfeitsPrices[EForfeitType.standard]}€
|
||||||
<Typography typo={ITypo.H2} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.H2} color={ITypoColor.BLACK}>
|
||||||
HT
|
HT
|
||||||
@ -185,7 +185,7 @@ export default function SubscriptionFacturation() {
|
|||||||
</div>
|
</div>
|
||||||
<div className={classes["separator"]} />
|
<div className={classes["separator"]} />
|
||||||
<div className={classes["price-container"]}>
|
<div className={classes["price-container"]}>
|
||||||
<Typography typo={ITypo.H1} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.H1} color={ITypoColor.BLACK} className={classes["price"]}>
|
||||||
{forfeitsPrices[EForfeitType.unlimited]}€
|
{forfeitsPrices[EForfeitType.unlimited]}€
|
||||||
<Typography typo={ITypo.H2} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.H2} color={ITypoColor.BLACK}>
|
||||||
HT
|
HT
|
||||||
|
@ -52,6 +52,11 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
|
||||||
|
.price {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ export default function SubscriptionNew() {
|
|||||||
</div>
|
</div>
|
||||||
<div className={classes["separator"]} />
|
<div className={classes["separator"]} />
|
||||||
<div className={classes["price-container"]}>
|
<div className={classes["price-container"]}>
|
||||||
<Typography typo={ITypo.H1} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.H1} color={ITypoColor.BLACK} className={classes["price"]}>
|
||||||
99€
|
99€
|
||||||
<Typography typo={ITypo.H2} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.H2} color={ITypoColor.BLACK}>
|
||||||
HT
|
HT
|
||||||
@ -63,7 +63,7 @@ export default function SubscriptionNew() {
|
|||||||
</div>
|
</div>
|
||||||
<div className={classes["separator"]} />
|
<div className={classes["separator"]} />
|
||||||
<div className={classes["price-container"]}>
|
<div className={classes["price-container"]}>
|
||||||
<Typography typo={ITypo.H1} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.H1} color={ITypoColor.BLACK} className={classes["price"]}>
|
||||||
{forfeitsPrices[EForfeitType.unlimited]}€
|
{forfeitsPrices[EForfeitType.unlimited]}€
|
||||||
<Typography typo={ITypo.H2} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.H2} color={ITypoColor.BLACK}>
|
||||||
HT
|
HT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user