Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Task 1—Create a feature flag

    Code Block
    enable-acceptance-agreements-marketing-email
  • Task 2—Add the checkbox market email on ModalAgreement component:

    • We will create a new attribute on component ModalAgreement

      • path: intl-whitelabel-app/workspaces/frontend/src/components/modal-agreement/index.tsx

        Code Block
        languagetypescript
        interface IModalAgreement {
          ...
          showMarketing: boolean;
        }
        Code Block
        languagetypescript
        const ModalAgreement: React.FC<IModalAgreement> = ({
          ...
          showMarketing,
        })
      • On file intl-whitelabel-app/workspaces/frontend/src/components/modal-agreement/index.tsx, we will send the attribute value:

        Code Block
        languagetypescript
        <ModalAgreement
          showMarketing={!user?.details?.promotionalEmails}
          ...
        />
  • We will add the checkbox after the agreements links protected by feature flag:

    • path: intl-whitelabel-app/workspaces/frontend/src/components/modal-agreement/index.tsx

      Code Block
      languagetypescript
      {<FEATURE_FLAG> && showMarketing && (
        <ContentCheckbox>
          <Checkbox
            aria-label={formatMessage({
              id: `acceptEmailsAndSpecialOffers.${brand()}`,
            })}
            label={formatMessage({ id: `acceptEmailsAndSpecialOffers.${brand()}` })}
            name="checkMarketing"
            checked={isCheckedMarketing}
            onChange={handleChangeMarketing}
          />
        </ContentCheckbox>
      )}
    • We will add new status to checked:

      Code Block
      languagetypescript
      const [isCheckedMarketing, setcheckMarting] = useState(false);
    • New handler change:

      Code Block
      languagetypescript
      const handleChangeMarketing = () => {
        return isCheckedMarting ? setcheckMarting(false) : setcheckMarting(true);
      };
  • Task 3—Change the update acceptance agreement flow

    • We will create a new type:

      • path: intl-whitelabel-app/workspaces/frontend/src/state/auth/index.tsx

        Code Block
        languagetypescript
        export type UpdateAgreementAcceptance = {
          acceptanceFromSanity: Array<IStaticPageRoute>;
          promotionalEmails: Boolean;
        };
      • On the same file, we will change the clickContinue method:

        • before:

          Code Block
          languagetypescript
          const clickContinue = useCallback(async () => {
            const result = await updateRequiredAcceptanceAgreementInfo(acceptanceAgreementFromSanity);
          
            if (result) {
              setShowModal(false);
            }
          }, [acceptanceAgreementFromSanity, updateRequiredAcceptanceAgreementInfo]);
        • after:

          Code Block
          languagetypescript
          const clickContinue = useCallback(
            async (updateAgreementAcceptance: UpdateAgreementAcceptance) => {
              const result = await updateRequiredAcceptanceAgreementInfo(updateAgreementAcceptance);
          
              if (result) {
                setShowModal(false);
              }
            },
            [updateRequiredAcceptanceAgreementInfo]
          );
        • We will need to remove the State acceptanceAgreementFromSanity because it won’t use anymore:

          Code Block
          languagetypescript
          const [acceptanceAgreementFromSanity, setAcceptanceAgreementFromSanity] = useState(
            [] as IStaticPageRoute[]
          );
      • On file: intl-whitelabel-app/workspaces/frontend/src/components/modal-agreement/index.tsx, we will change the continueUpdate attribute to receive a parameter:

        Code Block
        languagetypescript
        interface IModalAgreement {
          continueUpdate: (updateAgreementAcceptance: UpdateAgreementAcceptance) => Promise<any>;
          ...
        }
      • On onClickContinue method, we will send the parameters about continueUpdate method:

        • before:

          Code Block
          languagetypescript
          const onClickContinue = async () => {
            ...
            const result = await continueUpdate();
            ...
          };
        • after:

          Code Block
          languagetypescript
          const onClickContinue = async () => {
            ...
            const result = await continueUpdate({
              acceptanceFromSanity: requiredTerms,
              promotionalEmails: isCheckedMarketing,
            });
            ...
          };
      • Now, we will need to add on promotionalEmails attribute to update information:

        • path: intl-whitelabel-app/workspaces/frontend/src/state/auth/hooks/use-current-user.ts

          • We will change the updateRequiredAcceptanceAgreementInfo method:

            • before:

              Code Block
              languagetypescript
              const updateRequiredAcceptanceAgreementInfo = useCallback(
                async (acceptanceFromSanity: Array<IStaticPageRoute>): Promise<any> => {
                  ...
                },
                [formatMessage, logger, updateMeMutation, user]
              );
            • after:

              Code Block
              languagetypescript
              const updateRequiredAcceptanceAgreementInfo = useCallback(
                async (updateAgreementAcceptance: UpdateAgreementAcceptance): Promise<any> => {
                  ...
                  const { acceptanceFromSanity, promotionalEmails } = updateAgreementAcceptance;
                },
                [formatMessage, logger, updateMeMutation, user]
              );
          • On input:

            • before:

              Code Block
              languagetypescript
              const input = {
                requiredAcceptanceAgreementInfo: newUpdateAcceptanceAgreement,
              }
            • after:

              Code Block
              languagetypescript
              const input = {
                requiredAcceptanceAgreementInfo: newUpdateAcceptanceAgreement,
                promotionalEmails: promotionalEmails
                  ? promotionalEmails
                  : user.details?.promotionalEmails,
              };
        • Task 4—Add the mparticle to promotionalEmails acceptance

          • path: intl-whitelabel-app/workspaces/frontend/src/components/modal-agreement/index.tsx

            • We will add on mparticle event a new attribute:

              Code Block
              languagetypescript
              useEffect(() => {
                logEvent(CustomEventNames.MODAL_APPEARANCE, EventTypes.Other, {
                  ...
                  ModalShowMarketingEmail: <FEATURE_FLAG> && showMarketing,
                });
              }, [logEvent, modalAppearanceEventMessage, modalHeader, modalMessage, showMarketing]);
            • On onClickContinue method:

              Code Block
              languagetypescript
              if (<FEATURE_FLAG> && showMarketing) {
                logRBIEvent({
                  name: CustomEventNames.CLICK_EVENT,
                  type: EventTypes.Navigation,
                  attributes: {
                    component: ClickEventComponentNames.BUTTON,
                    headerText: 'Accepted receive special offers',
                    text: `${isCheckedMarketing}`,
                  },
               const { ..., updateUserAttributes } = useMParticleContext();
              
              if (<FEATURE_FLAG> && showMarketing) {
                updateUserAttributes({ promotionalEmails: isCheckedMarketing });
              }

Screenshots

https://www.figma.com/file/sfH3mHXoEUfHbm5qMul0Vn/Popeyes?node-id=758-67566&t=5MEetCF5Hg6m1tlY-0

...