diff --git a/webapp/CHANGELOG.md b/webapp/CHANGELOG.md index ed7fe667..104b4807 100644 --- a/webapp/CHANGELOG.md +++ b/webapp/CHANGELOG.md @@ -1,3 +1,22 @@ +## [0.73.21](https://github.com/SocialGouv/carte-jeune-engage/compare/v0.73.20...v0.73.21) (2024-12-13) + +### Bug Fixes + +- remove crisp component from all pages ([156b1e1](https://github.com/SocialGouv/carte-jeune-engage/commit/156b1e183fa00a12e1273390e3289aae35b658e3)) + +## [0.73.20](https://github.com/SocialGouv/carte-jeune-engage/compare/v0.73.19...v0.73.20) (2024-12-05) + +### Bug Fixes + +- desactivate reminder auchan and offer user preferences notifications and group offer activated reminder by user instead by offer ([d52879d](https://github.com/SocialGouv/carte-jeune-engage/commit/d52879d1f07bcbbd4711457fac499ba02691e44e)) +- remove unused import ([fe1bb94](https://github.com/SocialGouv/carte-jeune-engage/commit/fe1bb94cc13ee929b93fd8270523e6cbd0403518)) + +## [0.73.19](https://github.com/SocialGouv/carte-jeune-engage/compare/v0.73.18...v0.73.19) (2024-12-04) + +### Bug Fixes + +- return back button offer from url ([f969374](https://github.com/SocialGouv/carte-jeune-engage/commit/f969374c2aab4ead6e125c43aa6ccfda8e48289c)) + ## [0.73.18](https://github.com/SocialGouv/carte-jeune-engage/compare/v0.73.17...v0.73.18) (2024-12-04) ### Bug Fixes diff --git a/webapp/package.json b/webapp/package.json index 20da3a4b..4e51a3a3 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -1,6 +1,6 @@ { "name": "webapp", - "version": "0.73.18", + "version": "0.73.21", "private": true, "scripts": { "dev": "next dev", diff --git a/webapp/src/components/modals/IssueModal.tsx b/webapp/src/components/modals/IssueModal.tsx index ed4e5ea7..4e5d27d2 100644 --- a/webapp/src/components/modals/IssueModal.tsx +++ b/webapp/src/components/modals/IssueModal.tsx @@ -13,10 +13,8 @@ import { Button, Center, } from "@chakra-ui/react"; -import dynamic from "next/dynamic"; import { useState } from "react"; import { - HiMiniChatBubbleOvalLeftEllipsis, HiEnvelope, HiPhone, HiChevronRight, @@ -24,12 +22,9 @@ import { HiCheckCircle, } from "react-icons/hi2"; import { IconType } from "react-icons/lib"; -import { useAuth } from "~/providers/Auth"; import { api } from "~/utils/api"; import ConditionalLink from "../ConditionalLink"; -const CRISP_TOKEN = process.env.NEXT_PUBLIC_CRISP_TOKEN as string; - const defaultIssueCases = [ "Le prix avec la réduction ne correspond pas", "Autre chose", @@ -178,10 +173,6 @@ type IssueModalProps = IssueModalOrder | IssueModalCoupon; const IssueModal = (props: IssueModalProps) => { const { isOpen, onClose, kind } = props; - const { user } = useAuth(); - const CrispWithNoSSR = dynamic(() => import("../support/Crisp")); - - const [isOpenCrisp, setIsOpenCrisp] = useState(false); const id = kind === "order" ? props.order_id : props.coupon_id; @@ -203,74 +194,53 @@ const IssueModal = (props: IssueModalProps) => { ]; return ( - <> - - - {!isOpenCrisp && ( - - - - - - - setIsOpenCrisp(true)} - icon={HiMiniChatBubbleOvalLeftEllipsis} - text="Discutez avec nous en direct" - /> - {kind === "order" && ( - <> - - ou - - - - - - Disponible du lundi au vendredi de -
- 09h à 12h30 puis de 14h à 17h30 -
-
- - )} -
-
-
- )} -
- {isOpenCrisp && user && ( - { - setIsOpenCrisp(false); - }} - /> - )} - + + + + + + + + + {/* setIsOpenCrisp(true)} + icon={HiMiniChatBubbleOvalLeftEllipsis} + text="Discutez avec nous en direct" + /> + + ou + */} + + + + + Disponible du lundi au vendredi de +
+ 09h à 12h30 puis de 14h à 17h30 +
+
+
+
+
+
); }; diff --git a/webapp/src/components/modals/ObizOrderProcessModal.tsx b/webapp/src/components/modals/ObizOrderProcessModal.tsx index d9799da6..68ed4756 100644 --- a/webapp/src/components/modals/ObizOrderProcessModal.tsx +++ b/webapp/src/components/modals/ObizOrderProcessModal.tsx @@ -17,14 +17,10 @@ import { OfferIncluded } from "~/server/api/routers/offer"; import { OfferArticle } from "~/server/types"; import { api } from "~/utils/api"; import LayoutOrderStatus from "../obiz/LayoutOrderStatus"; -import { HiMiniShieldCheck, HiQuestionMarkCircle } from "react-icons/hi2"; +import { HiMiniShieldCheck } from "react-icons/hi2"; import { formatter2Digits } from "~/utils/tools"; import { useRouter } from "next/router"; import PartnerImage from "../ui/PartnerImage"; -import dynamic from "next/dynamic"; -import { useAuth } from "~/providers/Auth"; - -const CRISP_TOKEN = process.env.NEXT_PUBLIC_CRISP_TOKEN as string; const ObizOfferVariableContent = ({ step, @@ -223,11 +219,7 @@ export default function ObizOrderProcessModal( ) { const { isOpen, onClose, onRedirectPayment, offerId } = props; const router = useRouter(); - const { user } = useAuth(); - - const CrispWithNoSSR = dynamic(() => import("../support/Crisp")); - const [isOpenCrisp, setIsOpenCrisp] = useState(false); const [amount, setAmount] = useState(0); const [step, setStep] = useState("amount"); const [selectedArticles, setSelectedArticles] = useState< @@ -265,90 +257,75 @@ export default function ObizOrderProcessModal( <> - {!isOpenCrisp && ( - - - {step !== "payment" && ( - - - - step == "amount" ? onClose() : setStep("amount") - } - /> - - - - - {offer.partner.name} - - - {offer.title} {offer.subtitle ?? ""} - - - setIsOpenCrisp(true)} + + + {step !== "payment" && ( + + + + step == "amount" ? onClose() : setStep("amount") + } /> + + + + + {offer.partner.name} + + + {offer.title} {offer.subtitle ?? ""} + - )} - { - if ( - availableArticles.length === 1 && - availableArticles[0].kind === "variable_price" - ) { - createTestOrder({ - offer_id: offer.id, - article_references: [ - { - reference: availableArticles[0].reference, - quantity: 1, - }, - ], - input_value: amount - (amount * discount) / 100, - input_value_public: amount, - }); - } else { - createTestOrder({ - offer_id: offer.id, - article_references: selectedArticles.map((article) => ({ - reference: article.article.reference, - quantity: article.quantity, - })), - }); - } - }} - selectedArticles={selectedArticles} - setSelectedArticles={setSelectedArticles} - /> - - - )} + {/* setIsOpenCrisp(true)} + /> */} + + )} + { + if ( + availableArticles.length === 1 && + availableArticles[0].kind === "variable_price" + ) { + createTestOrder({ + offer_id: offer.id, + article_references: [ + { + reference: availableArticles[0].reference, + quantity: 1, + }, + ], + input_value: amount - (amount * discount) / 100, + input_value_public: amount, + }); + } else { + createTestOrder({ + offer_id: offer.id, + article_references: selectedArticles.map((article) => ({ + reference: article.article.reference, + quantity: article.quantity, + })), + }); + } + }} + selectedArticles={selectedArticles} + setSelectedArticles={setSelectedArticles} + /> + + - {isOpenCrisp && user && ( - { - setIsOpenCrisp(false); - }} - /> - )} ); } diff --git a/webapp/src/components/wrappers/WalletWrapper.tsx b/webapp/src/components/wrappers/WalletWrapper.tsx index e0ee336c..83aec68d 100644 --- a/webapp/src/components/wrappers/WalletWrapper.tsx +++ b/webapp/src/components/wrappers/WalletWrapper.tsx @@ -1,23 +1,13 @@ import { Box, Button, Flex, Heading, Icon, Link } from "@chakra-ui/react"; -import { ReactNode, useState } from "react"; -import { HiCog6Tooth, HiQuestionMarkCircle, HiUser } from "react-icons/hi2"; +import { ReactNode } from "react"; +import { HiCog6Tooth, HiUser } from "react-icons/hi2"; import NextLink from "next/link"; -import dynamic from "next/dynamic"; -import { useAuth } from "~/providers/Auth"; - -const CRISP_TOKEN = process.env.NEXT_PUBLIC_CRISP_TOKEN as string; type WalletWrapperProps = { children: ReactNode; }; const WalletWrapper = ({ children }: WalletWrapperProps) => { - const { user } = useAuth(); - - const [isOpenCrisp, setIsOpenCrisp] = useState(false); - - const CrispWithNoSSR = dynamic(() => import("../support/Crisp")); - return ( @@ -47,13 +37,13 @@ const WalletWrapper = ({ children }: WalletWrapperProps) => { size="xs" /> - setIsOpenCrisp(true)} - /> + /> */} { {children} - {isOpenCrisp && user && ( - { - setIsOpenCrisp(false); - }} - /> - )} ); }; diff --git a/webapp/src/cronjobs/notifications/index.ts b/webapp/src/cronjobs/notifications/index.ts index ef3bf6ae..88c8339c 100644 --- a/webapp/src/cronjobs/notifications/index.ts +++ b/webapp/src/cronjobs/notifications/index.ts @@ -13,8 +13,8 @@ export const initNotifications = async () => { new Date().toLocaleString("fr-FR") ); await sendNewOfferAvailable(); - await sendReminderAuchan(); - await sendReminderOfferUserPreferences(); + // await sendReminderAuchan(); + // await sendReminderOfferUserPreferences(); await sendReminderOfferActivated(); console.log( "[INIT] - End sending notifications", diff --git a/webapp/src/cronjobs/notifications/reminderOfferActivated.ts b/webapp/src/cronjobs/notifications/reminderOfferActivated.ts index 501a6fa6..8ab453a1 100644 --- a/webapp/src/cronjobs/notifications/reminderOfferActivated.ts +++ b/webapp/src/cronjobs/notifications/reminderOfferActivated.ts @@ -1,7 +1,7 @@ import { CouponIncluded } from "../../server/api/routers/coupon"; import { getPayloadClient } from "../../payload/payloadClient"; import { sendPushNotification } from "../../utils/sendPushNotification"; -import { getBaseUrl, dateDiffInDays } from "../../utils/tools"; +import { getBaseUrl } from "../../utils/tools"; const slug = "reminder-offer-activated"; @@ -47,17 +47,37 @@ export async function sendReminderOfferActivated() { return; } + const users = new Map(); + for (const offerActivated of offersActivated.docs as CouponIncluded[]) { + if (!users.has(offerActivated.user.id)) + users.set(offerActivated.user.id, []); + + users.get(offerActivated.user.id)?.push(offerActivated); + } + + for (const [user_id, offersActivated] of users.entries()) { + const user = offersActivated[0].user; + + const title = + offersActivated.length > 1 + ? "Vos offres vous attendent !" + : "Votre offre vous attend !"; + + const message = + offersActivated.length > 1 + ? `👉 ${offersActivated.length} offres vous attendent, utilisez-les quand vous voulez. Ne l’oubliez pas 😶` + : `👉 L’offre ${offersActivated[0].offer.partner.name} vous attend, utilisez-la quand vous voulez. Ne l’oubliez pas 😶`; + const { notificationSent, notificationInDb } = await sendPushNotification( { - sub: offerActivated.user.notification_subscription, + sub: user.notification_subscription, payload, - userId: offerActivated.user.id, - offerId: offerActivated.offer.id, + userId: user_id, payloadNotification: { - title: "Votre offre vous attend !", - message: `👉 L’offre ${offerActivated.offer.title} vous attend, utilisez-la quand vous voulez. Ne l’oubliez pas 😶`, - url: `${getBaseUrl()}/dashboard/offer/${offerActivated.offer.source}/${offerActivated.offer.id}`, + title, + message, + url: `${getBaseUrl()}/dashboard/wallet`, slug, }, } diff --git a/webapp/src/pages/dashboard/account/index.tsx b/webapp/src/pages/dashboard/account/index.tsx index 321f6ddd..e5f159d9 100644 --- a/webapp/src/pages/dashboard/account/index.tsx +++ b/webapp/src/pages/dashboard/account/index.tsx @@ -1,18 +1,8 @@ import { Box, Flex, Icon, IconButton, Link, Text } from "@chakra-ui/react"; import { useRouter } from "next/router"; import PassCard from "~/components/account/PassCard"; -import { - HiCog6Tooth, - HiQuestionMarkCircle, - HiUser, - HiXMark, -} from "react-icons/hi2"; +import { HiCog6Tooth, HiUser, HiXMark } from "react-icons/hi2"; import NextLink from "next/link"; -import dynamic from "next/dynamic"; -import { useState } from "react"; -import { useAuth } from "~/providers/Auth"; - -const CRISP_TOKEN = process.env.NEXT_PUBLIC_CRISP_TOKEN as string; const HeaderButton = ({ icon, @@ -53,13 +43,6 @@ const HeaderButton = ({ export default function AccountCard() { const router = useRouter(); - const { user } = useAuth(); - - const [isOpenCrisp, setIsOpenCrisp] = useState(false); - - const CrispWithNoSSR = dynamic( - () => import("../../../components/support/Crisp") - ); return ( @@ -84,18 +67,13 @@ export default function AccountCard() { link="/dashboard/account/settings" /> {/* */} - { setIsOpenCrisp(true); }} - /> + /> */} @@ -119,15 +97,6 @@ export default function AccountCard() { Retour à mes réductions - {isOpenCrisp && user && ( - { - setIsOpenCrisp(false); - }} - /> - )} ); } diff --git a/webapp/src/pages/dashboard/index.tsx b/webapp/src/pages/dashboard/index.tsx index a411a50f..1430ba9f 100644 --- a/webapp/src/pages/dashboard/index.tsx +++ b/webapp/src/pages/dashboard/index.tsx @@ -10,7 +10,7 @@ import { import dynamic from "next/dynamic"; import NextLink from "next/link"; import { useState } from "react"; -import { HiMiniTag, HiQuestionMarkCircle } from "react-icons/hi2"; +import { HiMiniTag } from "react-icons/hi2"; import InstallationBanner from "~/components/InstallationBanner"; import LoadingLoader from "~/components/LoadingLoader"; import SearchBar from "~/components/SearchBar"; @@ -21,8 +21,6 @@ import TagsList from "~/components/lists/TagsList"; import { useAuth } from "~/providers/Auth"; import { api } from "~/utils/api"; -const CRISP_TOKEN = process.env.NEXT_PUBLIC_CRISP_TOKEN as string; - export default function Dashboard() { const { user } = useAuth(); @@ -76,7 +74,7 @@ export default function Dashboard() { Explorer - - + */} - {isOpenCrisp && user && ( - { - setIsOpenCrisp(false); - }} - /> - )} ); }