From 5ca4a972c512bec9583562acc07e2ff5e912c059 Mon Sep 17 00:00:00 2001 From: Alexander Lebedev Date: Thu, 19 Sep 2024 10:56:26 +0200 Subject: [PATCH] Remove MyMoney feature flag and related code, no longer used --- .../car-trial/CarTrialDebuggerForm.tsx | 5 +- .../carDealership/CarTrialExtensionBlock.tsx | 36 +---------- .../MyMoneyConsent/MyMoneyConsent.css.ts | 64 ------------------- .../MyMoneyConsent/MyMoneyConsent.stories.tsx | 14 ---- .../MyMoneyConsent/MyMoneyConsent.tsx | 61 ------------------ .../MyMoneyConsent/myMoneyConcentAtom.ts | 3 - .../MyMoneyConsentConfirmation.css.ts | 29 --------- .../MyMoneyConsentConfirmation.tsx | 57 ----------------- .../myMoneyConcentConfirmationAtom.ts | 9 --- .../features/carDealership/PayForTrial.tsx | 22 +------ .../TrialExtensionForm/TrialExtensionForm.tsx | 42 ++---------- .../carDealership/UpdateConsent.graphql | 5 -- apps/store/src/utils/Features.ts | 1 - 13 files changed, 9 insertions(+), 339 deletions(-) delete mode 100644 apps/store/src/features/carDealership/MyMoneyConsent/MyMoneyConsent.css.ts delete mode 100644 apps/store/src/features/carDealership/MyMoneyConsent/MyMoneyConsent.stories.tsx delete mode 100644 apps/store/src/features/carDealership/MyMoneyConsent/MyMoneyConsent.tsx delete mode 100644 apps/store/src/features/carDealership/MyMoneyConsent/myMoneyConcentAtom.ts delete mode 100644 apps/store/src/features/carDealership/MyMoneyConsentConfirmation/MyMoneyConsentConfirmation.css.ts delete mode 100644 apps/store/src/features/carDealership/MyMoneyConsentConfirmation/MyMoneyConsentConfirmation.tsx delete mode 100644 apps/store/src/features/carDealership/MyMoneyConsentConfirmation/myMoneyConcentConfirmationAtom.ts delete mode 100644 apps/store/src/features/carDealership/UpdateConsent.graphql diff --git a/apps/store/src/app/debugger/car-trial/CarTrialDebuggerForm.tsx b/apps/store/src/app/debugger/car-trial/CarTrialDebuggerForm.tsx index ddf283afcf..03d7bd6ee9 100644 --- a/apps/store/src/app/debugger/car-trial/CarTrialDebuggerForm.tsx +++ b/apps/store/src/app/debugger/car-trial/CarTrialDebuggerForm.tsx @@ -16,10 +16,7 @@ const TIER_OPTIONS = [ { name: 'Full insurance', value: '2' }, ] -const PRODUCT_OPTIONS = [ - { name: 'Hedvig', value: 'HEDVIG' }, - { name: 'My Money', value: 'MYMONEY' }, -] +const PRODUCT_OPTIONS = [{ name: 'Hedvig', value: 'HEDVIG' }] export const CarTrialDebuggerForm = () => { const [state, formAction] = useFormState(createCarTrial, { diff --git a/apps/store/src/features/carDealership/CarTrialExtensionBlock.tsx b/apps/store/src/features/carDealership/CarTrialExtensionBlock.tsx index 8cd7635add..99921da5f0 100644 --- a/apps/store/src/features/carDealership/CarTrialExtensionBlock.tsx +++ b/apps/store/src/features/carDealership/CarTrialExtensionBlock.tsx @@ -2,7 +2,6 @@ import { type QueryHookOptions } from '@apollo/client' import { datadogLogs } from '@datadog/browser-logs' -import { datadogRum } from '@datadog/browser-rum' import { storyblokEditable } from '@storyblok/react' import { addDays } from 'date-fns' import { useSetAtom } from 'jotai' @@ -13,9 +12,8 @@ import { Space } from 'ui' import { globalBannerAtom } from '@/components/GlobalBanner/globalBannerState' import * as GridLayout from '@/components/GridLayout/GridLayout' import { CarDealershipBanners } from '@/features/carDealership/carDearlership.constants' -import { useCarTrialExtensionQuery, useUpdateConsentMutation } from '@/services/graphql/generated' +import { useCarTrialExtensionQuery } from '@/services/graphql/generated' import { type SbBaseBlockProps } from '@/services/storyblok/storyblok' -import { Features } from '@/utils/Features' import { useRoutingLocale } from '@/utils/l10n/useRoutingLocale' import { PageLink } from '@/utils/PageLink' import { useFormatter } from '@/utils/useFormatter' @@ -42,15 +40,6 @@ export const CarTrialExtensionBlock = (props: Props) => { }, }) - const [updateMyMoneyConsent] = useUpdateConsentMutation({ - onCompleted() { - datadogLogs.logger.info('Car Trial | MyMoney consent updated') - }, - onError() { - datadogLogs.logger.error('Car Trial | Failed to update MyMoney consent') - }, - }) - const trialContact: TrialContract | null = useMemo(() => { if (data?.carTrial) { return { @@ -62,21 +51,6 @@ export const CarTrialExtensionBlock = (props: Props) => { return null }, [data]) - const handleMyMoneyConsent = useCallback( - (consentGiven: boolean) => { - if (data?.carTrial) { - updateMyMoneyConsent({ - variables: { - trialId: data.carTrial.id, - consentGiven: consentGiven, - }, - }) - datadogRum.addAction('MyMoney Consent | consent given', { value: consentGiven }) - } - }, - [updateMyMoneyConsent, data?.carTrial], - ) - return ( @@ -91,10 +65,6 @@ export const CarTrialExtensionBlock = (props: Props) => { priceIntent={data.carTrial.priceIntent} shopSession={data.carTrial.shopSession} requirePaymentConnection={props.blok.requirePaymentConnection ?? false} - {...(Features.enabled('MYMONEY') && { - collectConsent: data.carTrial.collectConsent, - onConsentChange: handleMyMoneyConsent, - })} /> ) : ( { shopSessionId={data.carTrial.shopSession.id} defaultOffer={data.carTrial.priceIntent.defaultOffer ?? undefined} ssn={data.carTrial.shopSession.customer?.ssn ?? undefined} - {...(Features.enabled('MYMONEY') && { - collectConsent: data.carTrial.collectConsent, - onConsentChange: handleMyMoneyConsent, - })} /> )} diff --git a/apps/store/src/features/carDealership/MyMoneyConsent/MyMoneyConsent.css.ts b/apps/store/src/features/carDealership/MyMoneyConsent/MyMoneyConsent.css.ts deleted file mode 100644 index 7143ab165c..0000000000 --- a/apps/store/src/features/carDealership/MyMoneyConsent/MyMoneyConsent.css.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { style } from '@vanilla-extract/css' -import { tokens } from 'ui' - -export const consentWrapper = style({ - display: 'grid', - gridTemplateColumns: '1.5rem 1fr', - rowGap: tokens.space.xxs, - columnGap: tokens.space.md, - alignItems: 'center', - padding: tokens.space.md, - backgroundColor: tokens.colors.opaque1, - borderRadius: tokens.radius.md, - lineHeight: 1.4, -}) - -export const consentBody = style({ - gridColumn: '2', -}) - -export const trigger = style({ - marginLeft: tokens.space.xxs, - textDecoration: 'underline', - textDecorationThickness: '1px', - textUnderlineOffset: '1.5px', - - selectors: { - '[data-state="open"] &': { - display: 'none', - }, - }, -}) - -export const checkboxRoot = style({ - display: 'flex', - placeContent: 'center', - backgroundColor: tokens.colors.opaque1, - width: '1.5rem', - height: '1.5rem', - padding: tokens.space.xxs, - border: `1.5px solid ${tokens.colors.gray500}`, - borderRadius: '0.25rem', - cursor: 'pointer', - - ':hover': { - backgroundColor: tokens.colors.gray300, - }, - - ':focus': { - borderColor: tokens.colors.borderOpaque3, - }, - - selectors: { - '&[data-state="checked"]': { - backgroundColor: tokens.colors.gray1000, - borderColor: tokens.colors.gray1000, - }, - }, -}) - -export const checkboxIndicator = style({ - display: 'flex', - placeItems: 'center', - color: tokens.colors.textNegative, -}) diff --git a/apps/store/src/features/carDealership/MyMoneyConsent/MyMoneyConsent.stories.tsx b/apps/store/src/features/carDealership/MyMoneyConsent/MyMoneyConsent.stories.tsx deleted file mode 100644 index 62e1ca8088..0000000000 --- a/apps/store/src/features/carDealership/MyMoneyConsent/MyMoneyConsent.stories.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import type { Meta, StoryObj } from '@storybook/react' -import { MyMoneyConsent } from './MyMoneyConsent' - -const meta: Meta = { - component: MyMoneyConsent, - parameters: { - grid: { width: '1/3' }, - }, -} - -export default meta -type Story = StoryObj - -export const Default: Story = {} diff --git a/apps/store/src/features/carDealership/MyMoneyConsent/MyMoneyConsent.tsx b/apps/store/src/features/carDealership/MyMoneyConsent/MyMoneyConsent.tsx deleted file mode 100644 index efffd30e69..0000000000 --- a/apps/store/src/features/carDealership/MyMoneyConsent/MyMoneyConsent.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { datadogRum } from '@datadog/browser-rum' -import * as Checkbox from '@radix-ui/react-checkbox' -import { useAtom } from 'jotai' -import { useTranslation } from 'next-i18next' -import React, { useState } from 'react' -import { CheckIcon, Text } from 'ui' -import Collapsible from '@/components/Collapsible/Collapsible' -import { concentAcceptedAtom } from './myMoneyConcentAtom' -import { - checkboxIndicator, - checkboxRoot, - consentBody, - consentWrapper, - trigger, -} from './MyMoneyConsent.css' - -export const MyMoneyConsent = () => { - const { t } = useTranslation(['carDealership', 'common']) - const [concentAccepted, setConsentAccepted] = useAtom(concentAcceptedAtom) - const [expanded, setExpanded] = useState(false) - - const handleCheckedChange = (checked: boolean) => { - setConsentAccepted(checked) - datadogRum.addAction('MyMoney Consent | checkbox toggled', { value: checked }) - } - - return ( -
- - - - - - - - - - - - - - {t('carDealership:MY_MONEY_CONSENT_BODY')} - - - {t('common:READ_MORE')} - - - - - {t('carDealership:MY_MONEY_CONSENT_BODY_COLLAPSED')} - - - -
- ) -} diff --git a/apps/store/src/features/carDealership/MyMoneyConsent/myMoneyConcentAtom.ts b/apps/store/src/features/carDealership/MyMoneyConsent/myMoneyConcentAtom.ts deleted file mode 100644 index 7774f58645..0000000000 --- a/apps/store/src/features/carDealership/MyMoneyConsent/myMoneyConcentAtom.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { atomWithStorage } from 'jotai/utils' - -export const concentAcceptedAtom = atomWithStorage('concentAccepted', false) diff --git a/apps/store/src/features/carDealership/MyMoneyConsentConfirmation/MyMoneyConsentConfirmation.css.ts b/apps/store/src/features/carDealership/MyMoneyConsentConfirmation/MyMoneyConsentConfirmation.css.ts deleted file mode 100644 index bf9f6b3872..0000000000 --- a/apps/store/src/features/carDealership/MyMoneyConsentConfirmation/MyMoneyConsentConfirmation.css.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { style } from '@vanilla-extract/css' -import { tokens } from 'ui' - -export const consentDialogContent = style({ - width: '100%', - alignSelf: 'center', -}) - -export const consentDialogWindow = style({ - padding: tokens.space.md, - paddingTop: tokens.space.xl, - borderRadius: tokens.radius.xxs, - width: `calc(100% - ${tokens.space.xs} * 2)`, - maxWidth: '24rem', - marginInline: 'auto', -}) - -export const consentDialogMessage = style({ - display: 'flex', - flexDirection: 'column', - alignItems: 'center', - textAlign: 'center', - marginBottom: tokens.space.lg, -}) - -export const consentDialogIcon = style({ - color: tokens.colors.signalBlueElement, - marginBottom: tokens.space.md, -}) diff --git a/apps/store/src/features/carDealership/MyMoneyConsentConfirmation/MyMoneyConsentConfirmation.tsx b/apps/store/src/features/carDealership/MyMoneyConsentConfirmation/MyMoneyConsentConfirmation.tsx deleted file mode 100644 index fd148209e3..0000000000 --- a/apps/store/src/features/carDealership/MyMoneyConsentConfirmation/MyMoneyConsentConfirmation.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { useTranslation } from 'next-i18next' -import type { ComponentPropsWithoutRef } from 'react' -import { Button, Dialog, InfoIcon, Text } from 'ui' -import { SpaceFlex } from '@/components/SpaceFlex/SpaceFlex' -import { - consentDialogContent, - consentDialogIcon, - consentDialogMessage, - consentDialogWindow, -} from './MyMoneyConsentConfirmation.css' - -type Props = { - onClose: () => void - onContinue: () => void - loading?: boolean -} & ComponentPropsWithoutRef - -export function MyMoneyConsentConfirmation({ children, loading, onClose, onContinue }: Props) { - const { t } = useTranslation('carDealership') - - const handleOpenChange = (isOpen: boolean) => { - if (!isOpen) { - onClose() - } - } - - return ( - - {children} - - -
- - - {t('MY_MONEY_CONSENT_CONFIRMATION_TITLE')} - - - - {t('MY_MONEY_CONSENT_CONFIRMATION_DESCRIPTION')} - - -
- - - - - - - - -
-
-
- ) -} diff --git a/apps/store/src/features/carDealership/MyMoneyConsentConfirmation/myMoneyConcentConfirmationAtom.ts b/apps/store/src/features/carDealership/MyMoneyConsentConfirmation/myMoneyConcentConfirmationAtom.ts deleted file mode 100644 index 116035ab32..0000000000 --- a/apps/store/src/features/carDealership/MyMoneyConsentConfirmation/myMoneyConcentConfirmationAtom.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { createJSONStorage } from 'jotai/utils' -import { atomWithToggleAndStorage } from '@/utils/atomWithToggleAndStorage' - -const storage = createJSONStorage(() => sessionStorage) -export const myMoneyConsentConfirmationFlagAtom = atomWithToggleAndStorage( - 'wasMyMoneyConsentShown', - false, - storage, -) diff --git a/apps/store/src/features/carDealership/PayForTrial.tsx b/apps/store/src/features/carDealership/PayForTrial.tsx index 94af02b2c9..87255830ad 100644 --- a/apps/store/src/features/carDealership/PayForTrial.tsx +++ b/apps/store/src/features/carDealership/PayForTrial.tsx @@ -1,5 +1,5 @@ import { datadogRum } from '@datadog/browser-rum' -import { useAtom, useSetAtom } from 'jotai' +import { useSetAtom } from 'jotai' import { useRouter } from 'next/router' import { useTranslation } from 'next-i18next' import { Space } from 'ui' @@ -14,34 +14,23 @@ import { useFormatter } from '@/utils/useFormatter' import { type TrialContract } from './carDealership.types' import { ConfirmPayWithoutExtensionButton } from './ConfirmPayWithoutExtensionButton' import { ExtensionOfferToggle } from './ExtensionOfferToggle' -import { concentAcceptedAtom } from './MyMoneyConsent/myMoneyConcentAtom' -import { MyMoneyConsent } from './MyMoneyConsent/MyMoneyConsent' import { PriceBreakdown } from './PriceBreakdown' import { ProductItemContractContainerCar } from './ProductItemContractContainer' -import { type MyMoneyConsentProps } from './TrialExtensionForm/TrialExtensionForm' type Props = { trialContract: TrialContract shopSessionId: string defaultOffer?: ProductOfferFragment ssn?: string -} & MyMoneyConsentProps +} -export const PayForTrial = ({ - trialContract, - shopSessionId, - defaultOffer, - ssn, - collectConsent, - onConsentChange, -}: Props) => { +export const PayForTrial = ({ trialContract, shopSessionId, defaultOffer, ssn }: Props) => { const router = useRouter() const { t } = useTranslation('carDealership') const formatter = useFormatter() const locale = useRoutingLocale() const setDismissedBannerId = useSetAtom(dismissedBannerIdAtom) const { startLogin } = useBankIdContext() - const [concentAccepted] = useAtom(concentAcceptedAtom) const handleConfirmPay = () => { datadogRum.addAction('Car dealership | Decline extension offer') @@ -50,9 +39,6 @@ export const PayForTrial = ({ throw new Error('Must have customer ssn') } - // Send MyMoney consent state - onConsentChange?.(concentAccepted) - startLogin({ ssn, async onSuccess() { @@ -99,8 +85,6 @@ export const PayForTrial = ({ })} /> - {collectConsent && } - ) diff --git a/apps/store/src/features/carDealership/TrialExtensionForm/TrialExtensionForm.tsx b/apps/store/src/features/carDealership/TrialExtensionForm/TrialExtensionForm.tsx index 87b735fe26..f21e3c7c4c 100644 --- a/apps/store/src/features/carDealership/TrialExtensionForm/TrialExtensionForm.tsx +++ b/apps/store/src/features/carDealership/TrialExtensionForm/TrialExtensionForm.tsx @@ -1,6 +1,5 @@ import { datadogRum } from '@datadog/browser-rum' import styled from '@emotion/styled' -import { useAtom } from 'jotai' import { useTranslation } from 'next-i18next' import type { ComponentPropsWithoutRef } from 'react' import { useMemo, useState } from 'react' @@ -20,39 +19,27 @@ import { PageLink } from '@/utils/PageLink' import { useFormatter } from '@/utils/useFormatter' import { type TrialContract } from '../carDealership.types' import { ExtensionOfferToggle } from '../ExtensionOfferToggle' -import { concentAcceptedAtom } from '../MyMoneyConsent/myMoneyConcentAtom' -import { MyMoneyConsent } from '../MyMoneyConsent/MyMoneyConsent' -import { myMoneyConsentConfirmationFlagAtom } from '../MyMoneyConsentConfirmation/myMoneyConcentConfirmationAtom' -import { MyMoneyConsentConfirmation } from '../MyMoneyConsentConfirmation/MyMoneyConsentConfirmation' import { PriceBreakdown } from '../PriceBreakdown' import { ProductItemContractContainerCar } from '../ProductItemContractContainer' import { EditActionButton } from './EditActionButton' import { useAcceptExtension } from './useAcceptExtension' -export type MyMoneyConsentProps = { - collectConsent?: boolean - onConsentChange?: (consentGiven: boolean) => void -} - type Props = { trialContract: TrialContract priceIntent: PriceIntentCarTrialExtensionFragment shopSession: ShopSessionFragment requirePaymentConnection: boolean -} & MyMoneyConsentProps +} export const TrialExtensionForm = ({ trialContract, priceIntent, shopSession, requirePaymentConnection, - collectConsent, - onConsentChange, }: Props) => { const { t } = useTranslation(['carDealership', 'checkout']) const locale = useRoutingLocale() const formatter = useFormatter() - const [concentAccepted] = useAtom(concentAcceptedAtom) const [acceptExtension, loading] = useAcceptExtension({ shopSession: shopSession, @@ -67,12 +54,6 @@ export const TrialExtensionForm = ({ ) }) - const [wasMyMoneyConsentShown, setWasMyMoneyConsentShown] = useAtom( - myMoneyConsentConfirmationFlagAtom, - ) - - const shouldShowMyMoneyConsentConfirmation = !concentAccepted && !wasMyMoneyConsentShown - const selectedOffer = useMemo( () => getSelectedOffer(priceIntent, tierLevel), [priceIntent, tierLevel], @@ -98,13 +79,9 @@ export const TrialExtensionForm = ({ setTierLevel(tierLevel) } - const markMyMoneyConsentConfirmationAsShown = () => setWasMyMoneyConsentShown(true) - const handleClickSign = () => { datadogRum.addAction('Car dealership | Click Sign') acceptExtension(selectedOffer.id) - // Send MyMoney consent state - onConsentChange?.(concentAccepted) } const signButtonLabel = requirePaymentConnection ? t('SIGN_AND_PAY_BUTTON') : t('SIGN_BUTTON') @@ -172,21 +149,10 @@ export const TrialExtensionForm = ({ /> )} - {collectConsent && } - - {shouldShowMyMoneyConsentConfirmation ? ( - - {signButtonLabel} - - ) : ( - - {signButtonLabel} - - )} + + {signButtonLabel} + diff --git a/apps/store/src/features/carDealership/UpdateConsent.graphql b/apps/store/src/features/carDealership/UpdateConsent.graphql deleted file mode 100644 index ae4132c313..0000000000 --- a/apps/store/src/features/carDealership/UpdateConsent.graphql +++ /dev/null @@ -1,5 +0,0 @@ -mutation UpdateConsent($trialId: UUID!, $consentGiven: Boolean!) { - updateConsent(trialId: $trialId, consentGiven: $consentGiven) { - consentGiven - } -} diff --git a/apps/store/src/utils/Features.ts b/apps/store/src/utils/Features.ts index 21ff798dfa..3d056791f6 100644 --- a/apps/store/src/utils/Features.ts +++ b/apps/store/src/utils/Features.ts @@ -12,7 +12,6 @@ const config = { // Keeping it around as a way to quickly disable Insurely if anything goes wrong INSURELY: process.env.NEXT_PUBLIC_FEATURE_INSURELY === 'true', - MYMONEY: process.env.NEXT_PUBLIC_FEATURE_MYMONEY === 'true', PRICE_CALCULATOR_PAGE: process.env.NEXT_PUBLIC_FEATURE_PRICE_CALCULATOR_PAGE === 'true', PRODUCT_PAGE_V2: process.env.NEXT_PUBLIC_FEATURE_PRODUCT_PAGE_V2 === 'true', } as const