mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-16 09:07:41 -05:00
refactor(client): align campers type with stored User (#49982
* refactor(client): align campers type with stored User * update snapshot
This commit is contained in:
@@ -273,6 +273,11 @@ exports[`<Profile/> renders correctly 1`] = `
|
||||
|
||||
|
||||
<br />
|
||||
<p
|
||||
class="text-center points"
|
||||
>
|
||||
profile.total-points
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
class="spacer"
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Col, Row } from '@freecodecamp/react-bootstrap';
|
||||
import React from 'react';
|
||||
import type { TFunction } from 'i18next';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { User } from '../../../redux/prop-types';
|
||||
|
||||
import envData from '../../../../../config/env.json';
|
||||
import { getLangCode } from '../../../../../config/i18n';
|
||||
@@ -21,21 +22,23 @@ const { clientLocale } = envData;
|
||||
|
||||
const localeCode = getLangCode(clientLocale);
|
||||
|
||||
interface CamperProps {
|
||||
about: string;
|
||||
githubProfile: string;
|
||||
isDonating: boolean;
|
||||
joinDate: string;
|
||||
linkedin: string;
|
||||
location: string;
|
||||
name: string;
|
||||
picture: string;
|
||||
points: number | null;
|
||||
twitter: string;
|
||||
username: string;
|
||||
website: string;
|
||||
yearsTopContributor: string[];
|
||||
}
|
||||
export type CamperProps = Pick<
|
||||
User,
|
||||
| 'about'
|
||||
| 'githubProfile'
|
||||
| 'isDonating'
|
||||
| 'linkedin'
|
||||
| 'points'
|
||||
| 'username'
|
||||
| 'twitter'
|
||||
| 'yearsTopContributor'
|
||||
| 'location'
|
||||
| 'website'
|
||||
| 'picture'
|
||||
| 'name'
|
||||
| 'joinDate'
|
||||
| 'twitter'
|
||||
>;
|
||||
|
||||
function joinArray(array: string[], t: TFunction): string {
|
||||
return array.reduce((string, item, index, array) => {
|
||||
@@ -124,11 +127,9 @@ function Camper({
|
||||
</div>
|
||||
)}
|
||||
<br />
|
||||
{typeof points === 'number' ? (
|
||||
<p className='text-center points'>
|
||||
{t('profile.total-points', { count: points })}
|
||||
</p>
|
||||
) : null}
|
||||
<p className='text-center points'>
|
||||
{t('profile.total-points', { count: points })}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user