Merge branch 'dev' into staging
This commit is contained in:
commit
70ed41a30d
51
package-lock.json
generated
51
package-lock.json
generated
@ -23,7 +23,7 @@
|
||||
"eslint-config-next": "13.2.4",
|
||||
"form-data": "^4.0.0",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.132",
|
||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.134",
|
||||
"next": "13.2.4",
|
||||
"prettier": "^2.8.7",
|
||||
"react": "18.2.0",
|
||||
@ -1401,20 +1401,20 @@
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/bare-fs": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-2.2.3.tgz",
|
||||
"integrity": "sha512-amG72llr9pstfXOBOHve1WjiuKKAMnebcmMbPWDZ7BCevAoJLpugjuAPRsDINEyjT0a6tbaVx3DctkXIRbLuJw==",
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-2.3.0.tgz",
|
||||
"integrity": "sha512-TNFqa1B4N99pds2a5NYHR15o0ZpdNKbAeKTE/+G6ED/UeOavv8RY3dr/Fu99HW3zU3pXpo2kDNO8Sjsm2esfOw==",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"bare-events": "^2.0.0",
|
||||
"bare-path": "^2.0.0",
|
||||
"streamx": "^2.13.0"
|
||||
"bare-stream": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bare-os": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/bare-os/-/bare-os-2.2.1.tgz",
|
||||
"integrity": "sha512-OwPyHgBBMkhC29Hl3O4/YfxW9n7mdTr2+SsO29XBWKKJsbgj3mnorDB80r5TiCQgQstgE5ga1qNYrpes6NvX2w==",
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/bare-os/-/bare-os-2.3.0.tgz",
|
||||
"integrity": "sha512-oPb8oMM1xZbhRQBngTgpcQ5gXw6kjOaRsSWsIeNyRxGed2w/ARyP7ScBYpWR1qfX2E5rS3gBw6OWcSQo+s+kUg==",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/bare-path": {
|
||||
@ -1426,6 +1426,15 @@
|
||||
"bare-os": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bare-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-KhNUoDL40iP4gFaLSsoGE479t0jHijfYdIcxRn/XtezA2BaUD0NRf/JGRpsMq6dMNM+SrCrB0YSSo/5wBY4rOQ==",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"streamx": "^2.16.1"
|
||||
}
|
||||
},
|
||||
"node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
@ -1536,9 +1545,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/caniuse-lite": {
|
||||
"version": "1.0.30001611",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001611.tgz",
|
||||
"integrity": "sha512-19NuN1/3PjA3QI8Eki55N8my4LzfkMCRLgCVfrl/slbSAchQfV0+GwjPrK3rq37As4UCLlM/DHajbKkAqbv92Q==",
|
||||
"version": "1.0.30001612",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001612.tgz",
|
||||
"integrity": "sha512-lFgnZ07UhaCcsSZgWW0K5j4e69dK1u/ltrL9lTUiFOwNHs12S3UMIEYgBV0Z6C6hRDev7iRnMzzYmKabYdXF9g==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
@ -1634,9 +1643,9 @@
|
||||
"integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA=="
|
||||
},
|
||||
"node_modules/clsx": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.0.tgz",
|
||||
"integrity": "sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg==",
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
|
||||
"integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
@ -3514,7 +3523,7 @@
|
||||
}
|
||||
},
|
||||
"node_modules/le-coffre-resources": {
|
||||
"resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#888194736ec642c64a7f6e878f5ded4fc480d4a0",
|
||||
"resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#fb09b1ebbdfbc80d43f8ae2e4b64e15575d0b69d",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"class-transformer": "^0.5.1",
|
||||
@ -3535,9 +3544,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/libphonenumber-js": {
|
||||
"version": "1.10.60",
|
||||
"resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.60.tgz",
|
||||
"integrity": "sha512-Ctgq2lXUpEJo5j1762NOzl2xo7z7pqmVWYai0p07LvAkQ32tbPv3wb+tcUeHEiXhKU5buM4H9MXsXo6OlM6C2g=="
|
||||
"version": "1.10.61",
|
||||
"resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.61.tgz",
|
||||
"integrity": "sha512-TsQsyzDttDvvzWNkbp/i0fVbzTGJIG0mUu/uNalIaRQEYeJxVQ/FPg+EJgSqfSXezREjM0V3RZ8cLVsKYhhw0Q=="
|
||||
},
|
||||
"node_modules/lines-and-columns": {
|
||||
"version": "1.2.4",
|
||||
@ -3752,9 +3761,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/node-abi": {
|
||||
"version": "3.59.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.59.0.tgz",
|
||||
"integrity": "sha512-HyyfzvTLCE8b1SX2nWimlra8cibEsypcSu/Az4SXMhWhtuctkwAX7qsEYNjUOIoYtPV884oN3wtYTN+iZKBtvw==",
|
||||
"version": "3.62.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.62.0.tgz",
|
||||
"integrity": "sha512-CPMcGa+y33xuL1E0TcNIu4YyaZCxnnvkVaEXrsosR3FxN+fV8xvb7Mzpb7IgKler10qeMkE6+Dp8qJhpzdq35g==",
|
||||
"dependencies": {
|
||||
"semver": "^7.3.5"
|
||||
},
|
||||
|
@ -25,7 +25,7 @@
|
||||
"eslint-config-next": "13.2.4",
|
||||
"form-data": "^4.0.0",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.132",
|
||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.134",
|
||||
"next": "13.2.4",
|
||||
"prettier": "^2.8.7",
|
||||
"react": "18.2.0",
|
||||
|
@ -5,7 +5,7 @@ import { useEffect, useState } from "react";
|
||||
import RadioBox from "@Front/Components/DesignSystem/RadioBox";
|
||||
import Button from "@Front/Components/DesignSystem/Button";
|
||||
import classnames from "classnames";
|
||||
import { EType } from "le-coffre-resources/dist/Admin/Subscription";
|
||||
import { EPaymentFrequency, EType } from "le-coffre-resources/dist/Admin/Subscription";
|
||||
import Stripe from "@Front/Api/LeCoffreApi/Admin/Stripe/Stripe";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
@ -13,11 +13,11 @@ type IProps = {
|
||||
forfeitType: EForfeitType;
|
||||
numberOfCollaborators: number;
|
||||
hasNavTab?: boolean;
|
||||
defaultFrequency?: EPaymentFrequency;
|
||||
defaultFrequency?: EPaymentFrequencyFront;
|
||||
disableInputs?: boolean;
|
||||
};
|
||||
|
||||
export enum EPaymentFrequency {
|
||||
export enum EPaymentFrequencyFront {
|
||||
monthly,
|
||||
yearly,
|
||||
}
|
||||
@ -25,17 +25,19 @@ export enum EPaymentFrequency {
|
||||
export default function SubscribeCheckoutTicket(props: IProps) {
|
||||
const router = useRouter();
|
||||
const { forfeitType, numberOfCollaborators, hasNavTab = true } = props;
|
||||
const [paymentFrequency, setPaymentFrequency] = useState<EPaymentFrequency>(props.defaultFrequency ?? EPaymentFrequency.monthly);
|
||||
const [paymentFrequency, setPaymentFrequency] = useState<EPaymentFrequencyFront>(
|
||||
props.defaultFrequency ?? EPaymentFrequencyFront.monthly,
|
||||
);
|
||||
const [multiplier, setMultiplier] = useState<number>(1);
|
||||
const [totalPlan, setTotalPlan] = useState<number>(0);
|
||||
const [totalCollaborator, setTotalCollaborator] = useState<number>(0);
|
||||
|
||||
useEffect(() => {
|
||||
setMultiplier(paymentFrequency === EPaymentFrequency.monthly ? 1 : 12);
|
||||
setMultiplier(paymentFrequency === EPaymentFrequencyFront.monthly ? 1 : 12);
|
||||
}, [paymentFrequency]);
|
||||
|
||||
useEffect(() => {
|
||||
let multiplierToUse = paymentFrequency === EPaymentFrequency.yearly ? multiplier - 1 : multiplier;
|
||||
let multiplierToUse = paymentFrequency === EPaymentFrequencyFront.yearly ? multiplier - 1 : multiplier;
|
||||
if (forfeitType === EForfeitType.unlimited) {
|
||||
setTotalPlan(forfeitsPrices[EForfeitType.unlimited] * multiplierToUse);
|
||||
setTotalCollaborator(0);
|
||||
@ -46,7 +48,7 @@ export default function SubscribeCheckoutTicket(props: IProps) {
|
||||
}, [multiplier, forfeitType, numberOfCollaborators, paymentFrequency]);
|
||||
|
||||
const handleFrequencyChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setPaymentFrequency(parseInt(e.target.value) as EPaymentFrequency);
|
||||
setPaymentFrequency(parseInt(e.target.value) as EPaymentFrequencyFront);
|
||||
};
|
||||
|
||||
const formatFloat = (value: number) => {
|
||||
@ -57,6 +59,7 @@ export default function SubscribeCheckoutTicket(props: IProps) {
|
||||
const stripeCheckout = {
|
||||
type: forfeitType === EForfeitType.standard ? EType.Standard : EType.Unlimited,
|
||||
nb_seats: forfeitType === EForfeitType.standard ? numberOfCollaborators : 0,
|
||||
frequency: paymentFrequency === EPaymentFrequencyFront.monthly ? EPaymentFrequency.Monthly : EPaymentFrequency.Yearly,
|
||||
};
|
||||
|
||||
try {
|
||||
@ -77,17 +80,17 @@ export default function SubscribeCheckoutTicket(props: IProps) {
|
||||
<div className={classes["container-frequency"]}>
|
||||
<RadioBox
|
||||
name="paymentFrequency"
|
||||
value={EPaymentFrequency.yearly.toString()}
|
||||
value={EPaymentFrequencyFront.yearly.toString()}
|
||||
onChange={handleFrequencyChange}
|
||||
defaultChecked={paymentFrequency === EPaymentFrequency.yearly}
|
||||
defaultChecked={paymentFrequency === EPaymentFrequencyFront.yearly}
|
||||
disabled={props.disableInputs}>
|
||||
<Typography typo={ITypo.P_ERR_18}>Annuel</Typography>
|
||||
</RadioBox>
|
||||
<RadioBox
|
||||
name="paymentFrequency"
|
||||
value={EPaymentFrequency.monthly.toString()}
|
||||
value={EPaymentFrequencyFront.monthly.toString()}
|
||||
onChange={handleFrequencyChange}
|
||||
defaultChecked={paymentFrequency === EPaymentFrequency.monthly}
|
||||
defaultChecked={paymentFrequency === EPaymentFrequencyFront.monthly}
|
||||
disabled={props.disableInputs}>
|
||||
<Typography typo={ITypo.P_ERR_18}>Mensuel</Typography>
|
||||
</RadioBox>
|
||||
@ -99,7 +102,7 @@ export default function SubscribeCheckoutTicket(props: IProps) {
|
||||
<Typography typo={ITypo.P_18} color={ITypoColor.BLACK}>
|
||||
{forfeitType === EForfeitType.standard ? "Plan individuel" : "Plan illimité"}
|
||||
</Typography>
|
||||
{paymentFrequency === EPaymentFrequency.yearly && (
|
||||
{paymentFrequency === EPaymentFrequencyFront.yearly && (
|
||||
<Typography typo={ITypo.CAPTION_14_SB} color={ITypoColor.BLACK}>
|
||||
{formatFloat(
|
||||
forfeitType === EForfeitType.standard
|
||||
@ -115,7 +118,7 @@ export default function SubscribeCheckoutTicket(props: IProps) {
|
||||
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
||||
{totalPlan} €
|
||||
</Typography>
|
||||
{paymentFrequency === EPaymentFrequency.yearly && (
|
||||
{paymentFrequency === EPaymentFrequencyFront.yearly && (
|
||||
<Typography typo={ITypo.P_16} color={ITypoColor.BLACK} className={classes["stroked-price"]}>
|
||||
{formatFloat(
|
||||
forfeitType === EForfeitType.standard
|
||||
@ -135,7 +138,7 @@ export default function SubscribeCheckoutTicket(props: IProps) {
|
||||
</Typography>
|
||||
<Typography typo={ITypo.CAPTION_14_SB} color={ITypoColor.BLACK}>
|
||||
{formatFloat(collaboratorPrice)} € x {numberOfCollaborators}{" "}
|
||||
{paymentFrequency === EPaymentFrequency.yearly && "x 12"}
|
||||
{paymentFrequency === EPaymentFrequencyFront.yearly && "x 12"}
|
||||
</Typography>
|
||||
</div>
|
||||
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
||||
|
@ -2,7 +2,7 @@ import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Ty
|
||||
import classes from "./classes.module.scss";
|
||||
import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate";
|
||||
import NavTab from "@Front/Components/Elements/NavTab";
|
||||
import SubscribeCheckoutTicket, { EPaymentFrequency } from "../SubscribeCheckoutTicket";
|
||||
import SubscribeCheckoutTicket, { EPaymentFrequencyFront as EPaymentFrequency } from "../SubscribeCheckoutTicket";
|
||||
import { EForfeitType, forfeitsPrices } from "../../SubscriptionFacturation";
|
||||
import { useEffect, useState } from "react";
|
||||
import Check from "@Front/Components/Elements/Icons/Check";
|
||||
|
@ -3,7 +3,7 @@ import classes from "./classes.module.scss";
|
||||
import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate";
|
||||
import NavTab from "@Front/Components/Elements/NavTab";
|
||||
import NumberPicker from "@Front/Components/Elements/NumberPicker";
|
||||
import SubscribeCheckoutTicket, { EPaymentFrequency } from "../SubscribeCheckoutTicket";
|
||||
import SubscribeCheckoutTicket, { EPaymentFrequencyFront as EPaymentFrequency } from "../SubscribeCheckoutTicket";
|
||||
import { EForfeitType, collaboratorPrice, forfeitsPrices } from "../../SubscriptionFacturation";
|
||||
import { useEffect, useState } from "react";
|
||||
import Check from "@Front/Components/Elements/Icons/Check";
|
||||
|
@ -10,6 +10,7 @@ import JwtService from "@Front/Services/JwtService/JwtService";
|
||||
import Subscriptions from "@Front/Api/LeCoffreApi/Admin/Subscriptions/Subscriptions";
|
||||
import Users from "@Front/Api/LeCoffreApi/Admin/Users/Users";
|
||||
import { useRouter } from "next/router";
|
||||
import CookieService from "@Front/Services/CookieService/CookieService";
|
||||
|
||||
export default function SubscriptionManageCollaborators() {
|
||||
const router = useRouter();
|
||||
@ -62,7 +63,11 @@ export default function SubscriptionManageCollaborators() {
|
||||
const subcriptionToUpdate = {
|
||||
seats: selectedCollaborators.map((collaborator) => ({ user: { uid: collaborator } })),
|
||||
};
|
||||
|
||||
await Subscriptions.getInstance().put(subscription?.uid!, subcriptionToUpdate);
|
||||
const refreshToken = CookieService.getInstance().getCookie("leCoffreRefreshToken");
|
||||
if (!refreshToken) return;
|
||||
await JwtService.getInstance().forceRefreshToken(refreshToken);
|
||||
router.push("/subscription/manage");
|
||||
if (!e) return;
|
||||
e.preventDefault();
|
||||
@ -71,7 +76,7 @@ export default function SubscriptionManageCollaborators() {
|
||||
useEffect(() => {
|
||||
loadSubscription();
|
||||
loadCollaborators();
|
||||
}, [loadSubscription]);
|
||||
}, [loadCollaborators, loadSubscription]);
|
||||
|
||||
return (
|
||||
<DefaultTemplate title="Nouvelle souscription" hasBackArrow>
|
||||
|
@ -8,7 +8,7 @@ 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 SubscribeCheckoutTicket, { EPaymentFrequencyFront as EPaymentFrequency } from "../Components/SubscribeCheckoutTicket";
|
||||
import { EForfeitType } from "../SubscriptionFacturation";
|
||||
import Stripe from "@Front/Api/LeCoffreApi/Admin/Stripe/Stripe";
|
||||
|
||||
|
@ -7,7 +7,7 @@ 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 SubscribeCheckoutTicket, { EPaymentFrequencyFront as 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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user