Versions Compared

Key

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

...

Description

  • intl-user-service

    • TASK 1 - Add attribute on Dto

      • We will add the new attribute on class UserDetailsBaseDto:

        • path: intl-user-service/src/users/dtos/users.dtos.ts

          Code Block
          languagetypescript
          @ApiProperty({
              required: false,
              description: 'Required acceptance agreement info',
              type: [RequiredAcceptanceAgreementInfoDto],
              nullable: true,
            })
            @Type(() => RequiredAcceptanceAgreementInfoDto)
            @IsArray()
            @IsOptional()
            public requiredAcceptanceAgreementInfo?: RequiredAcceptanceAgreementInfoDto[] | null;
        • On class UserDetailsDto on constructor, we will add a mapper:

          Code Block
          languagetypescript
          const requiredAcceptanceAgreementInfo = userDetails.requiredAcceptanceAgreementInfo?.map(
            (ra: IRequiredAcceptanceAgreementInfo) => ra as RequiredAcceptanceAgreementInfoDto,
          );
          Code Block
          languagetypescript
          this.requiredAcceptanceAgreementInfo = requiredAcceptanceAgreementInfo;
  • intlctg-packages | ctg-packages

    • TASK 2 - add the attribute on TUserDetails

      • We will add the attribute requiredAcceptanceAgreementInfo on TUserDetails:

        • path: intl-packages/packages/users/src/schemata.ts

          Code Block
          languagetypescript
          requiredAcceptanceAgreementInfo: t.union([t.array(TRequiredAcceptanceAgreementInfo), t.null]),
          Code Block
          languagetypescript
          export const TRequiredAcceptanceAgreementInfo = t.interface({
            id: t.string,
            updatedAt: t.string,
          });
  • intl-packages

    • TASK 3 - add the attribute on TUserDetails

      • Duplicate change to done on ctg-packages

  • intl-whitelabel-graphql

    • TASK 4 - add the attribute on UpdateUserDetailsInput

      • We will add the attribute requiredAcceptanceAgreementInfo on UpdateUserDetailsInput

        • path: intl-whitelabel-graphql/src/functions/graphql/schemas/users.gql

          Code Block
          languagetypescript
          input UpdateUserDetailsInput {
            ...
            requiredAcceptanceAgreementInfo: [RequiredAcceptanceAgreementInfoInput]
          }
      • We will run the command:

        Code Block
        yarn run graphql:types
        • After that, will be created an automatic code on file: intl-whitelabel-graphql/src/functions/graphql/generated/graphql.ts, probably, will be many changes, but we can to discard all, except of change related about requiredAcceptanceAgreementInfo

  • intl-whitelabel-app

    • TASK 5 - Create method to update requiredAcceptanceAgreementInfo

      • We will create an update method to requiredAcceptanceAgreementInfo

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

          Code Block
          languagetypescript
          const updateRequiredAcceptanceAgreementInfo = useCallback(
              async (sanityAcceptance: Array<IStaticPageRoute>) => {
                try {
                  if (!user.details?.requiredAcceptanceAgreementInfo?.length) {
                    user.details.requiredAcceptanceAgreementInfo = 
        return
        • [];
                  }
          
                  const newAcceptanceAgreementInfo = sanityAcceptance.map(sp => {
                    return user.details.requiredAcceptanceAgreementInfo.filter((userAcceptance: any) => {
                      if (userAcceptance.id === sp._id) {
                        userAcceptance.updatedAt = sp._updatedAt;
                        return userAcceptance;
                      }
                      return {
                        id: sp._id,
                        updatedAt: sp._updatedAt,
                      };
                    });
                  });
          
                  const input = {
                    ...user,
                    details: {
                      ...user.details,
                      requiredAcceptanceAgreementInfo: newAcceptanceAgreementInfo,
                    },
                  };
          
                  const { data } = await updateMeMutation({ variables: { input } });
                  if (!data) {
                    logger.error({ message: 'An error occurred updating 
        favorite
        • acceptance 
        offers
        • agreement' });
                    toast.error(formatMessage({ id: 'updateInfoError' }));
                  }
                } catch (error) {
                  logger.error({ message: `An error occurred updating 
        favorite
        • acceptance 
        offers
        • agreement: ${error}` });
                  toast.error(formatMessage({ id: 'updateInfoError' }));
                }
              },
              [formatMessage, logger, updateMeMutation, user]
            );
        • And we will export this method from hook

          Code Block
          languagetypescript
          return {
              ...
              updateRequiredAcceptanceAgreementInfo,
            };

Screenshots

  • TODO

POC

  • TODO

Impact Analysis

  • Signup

  • Authentication

Unit Test

...

  • Authentication

MOCKS

  • TODO

...