From 44a1a05ab04a8e8b7f8b09cc3ca81d2cbdebc994 Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Mon, 17 Apr 2023 20:16:28 +0200 Subject: [PATCH] refactor(client): align campers type with stored User (#49982 * refactor(client): align campers type with stored User * update snapshot --- .../__snapshots__/profile.test.tsx.snap | 5 +++ .../components/profile/components/camper.tsx | 41 ++++++++++--------- client/src/components/settings/about.tsx | 18 ++++---- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/client/src/components/profile/__snapshots__/profile.test.tsx.snap b/client/src/components/profile/__snapshots__/profile.test.tsx.snap index bcb90fcb3d5..eb5d61f3585 100644 --- a/client/src/components/profile/__snapshots__/profile.test.tsx.snap +++ b/client/src/components/profile/__snapshots__/profile.test.tsx.snap @@ -273,6 +273,11 @@ exports[` renders correctly 1`] = `
+

+ profile.total-points +

; function joinArray(array: string[], t: TFunction): string { return array.reduce((string, item, index, array) => { @@ -124,11 +127,9 @@ function Camper({
)}
- {typeof points === 'number' ? ( -

- {t('profile.total-points', { count: points })} -

- ) : null} +

+ {t('profile.total-points', { count: points })} +

); } diff --git a/client/src/components/settings/about.tsx b/client/src/components/settings/about.tsx index 9a8a03c9675..d35c096b18f 100644 --- a/client/src/components/settings/about.tsx +++ b/client/src/components/settings/about.tsx @@ -12,6 +12,7 @@ import { withTranslation } from 'react-i18next'; import isURL from 'validator/lib/isURL'; import { FullWidthRow, Spacer } from '../helpers'; import BlockSaveButton from '../helpers/form/block-save-button'; +import type { CamperProps } from '../profile/components/camper'; import SoundSettings from './sound'; import ThemeSettings, { Themes } from './theme'; import UsernameSettings from './username'; @@ -25,13 +26,17 @@ type FormValues = { about: string; }; -type AboutProps = { - about: string; +type AboutProps = Omit< + CamperProps, + | 'linkedin' + | 'joinDate' + | 'isDonating' + | 'githubProfile' + | 'twitter' + | 'website' + | 'yearsTopContributor' +> & { currentTheme: Themes; - location: string; - name: string; - picture: string; - points: number; sound: boolean; keyboardShortcuts: boolean; submitNewAbout: (formValues: FormValues) => void; @@ -39,7 +44,6 @@ type AboutProps = { toggleNightMode: (theme: Themes) => void; toggleSoundMode: (sound: boolean) => void; toggleKeyboardShortcuts: (keyboardShortcuts: boolean) => void; - username: string; }; type AboutState = {