Skip to content

Commit

Permalink
Merge pull request #569 from BinaryStudioAcademy/task/bt-541-replace-…
Browse files Browse the repository at this point in the history
…candidate-screen-with-real-data-and-connect-filters

bt-541: replace candidate screen with real data and connect filters
  • Loading branch information
katerynakostikova authored Sep 26, 2023
2 parents 76aa7db + ac0195a commit 8a44ef5
Show file tree
Hide file tree
Showing 77 changed files with 31,401 additions and 464 deletions.
2 changes: 1 addition & 1 deletion mobile/src/bundles/auth/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const loadCurrentUser = createAsyncThunk<
>(`${sliceName}${AuthApiPath.CURRENT_USER}`, async (_, { extra }) => {
const { authApi, storage } = extra;
try {
return authApi.getCurrentUser();
return await authApi.getCurrentUser();
} catch (error) {
await storage.drop(StorageKey.TOKEN);
throw error;
Expand Down
1 change: 1 addition & 0 deletions mobile/src/bundles/common-data/hooks/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { useCommonData } from './use-common-data/use-common-data';
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
useAppDispatch,
useAppSelector,
useEffect,
} from '~/bundles/common/hooks/hooks';
import {
getBadgesData,
getHardSkillsData,
} from '~/bundles/common-data/store/actions';
import { type UseCommonDataReturn } from '~/bundles/common-data/types/types';

const useCommonData = (): UseCommonDataReturn => {
const dispatch = useAppDispatch();
const { badgesData, dataStatus, hardSkillsData } = useAppSelector(
({ commonData }) => commonData,
);

useEffect(() => {
if (!badgesData) {
void dispatch(getBadgesData());
}
if (!hardSkillsData) {
void dispatch(getHardSkillsData());
}
}, [hardSkillsData, badgesData, dispatch]);

return { dataStatus, badgesData, hardSkillsData };
};

export { useCommonData };
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type FormattedHardSkillsItem = {
label: string;
value: string;
};

export { type FormattedHardSkillsItem };
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
type FormattedHardSkillsItem = {
label: string;
value: string;
};
import { type FormattedHardSkillsItem } from './formatted-hard-skill-item';

type FormattedHardSkills = {
items: FormattedHardSkillsItem[];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { type DataStatus } from '~/bundles/common/enums/enums';
import { type ValueOf } from '~/bundles/common/types/types';
import {
type BadgesResponseDto,
type FormattedHardSkills,
} from '~/bundles/common-data/types/types';

type UseCommonDataReturn = {
dataStatus: ValueOf<typeof DataStatus>;
badgesData: BadgesResponseDto | null;
hardSkillsData: FormattedHardSkills | null;
};

export { type UseCommonDataReturn };
4 changes: 3 additions & 1 deletion mobile/src/bundles/common-data/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export { type FormattedHardSkills } from './formatted-hard-skills-type';
export { type FormattedHardSkillsItem } from './hard-skills/formatted-hard-skill-item';
export { type FormattedHardSkills } from './hard-skills/formatted-hard-skills-type';
export { type UseCommonDataReturn } from './hooks/use-common-data-return';
export {
type BadgesResponseDto,
type HardSkillsResponseDto,
Expand Down
14 changes: 14 additions & 0 deletions mobile/src/bundles/common/common-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ class CommonApi extends HttpApiBase {
);
return response.json<UserDetailsResponseDto>();
}

public async getTalents(
payload: string,
): Promise<UserDetailsResponseDto[]> {
const response = await this.load(
this.getFullEndpoint(UserDetailsApiPath.ROOT, payload, {}),
{
method: 'GET',
contentType: ContentType.JSON,
hasAuth: true,
},
);
return await response.json<UserDetailsResponseDto[]>();
}
}

export { CommonApi };
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const AutocompleteMultiSelector = <T extends FieldValues>({
onChange(value);
};

const handleItemDelete = (itemName: string): void => {
const handleItemDelete = (itemName: string | number): void => {
onChange(
value.filter(
({ label }: AutocompleteMultiSelectorValue) =>
Expand Down
90 changes: 20 additions & 70 deletions mobile/src/bundles/common/components/badge/badge.tsx
Original file line number Diff line number Diff line change
@@ -1,86 +1,36 @@
import React from 'react';

import {
MaterialIcon,
CommunityIcon,
Text,
View,
} from '~/bundles/common/components/components';
import {
BadgeSize,
BsaBadgeStepBadgesTitle,
IconName,
TextCategory,
} from '~/bundles/common/enums/enums';
import { useMemo } from '~/bundles/common/hooks/hooks';
import { BadgeSize, TextCategory } from '~/bundles/common/enums/enums';
import { getBadgeColor, getBadgeIcon } from '~/bundles/common/helpers/helpers';
import { globalStyles } from '~/bundles/common/styles/styles';
import {
type StyleProp,
type ValueOf,
type ViewStyle,
} from '~/bundles/common/types/types';
import { type BadgesItem, type ValueOf } from '~/bundles/common/types/types';

import { styles } from './styles';

type BadgeName = ValueOf<typeof BsaBadgeStepBadgesTitle>;
type TBadgeSize = ValueOf<typeof BadgeSize>;

type BadgeProperties = {
style: StyleProp<ViewStyle>;
ending: string;
defaultValue: number | string;
};

type Properties = {
value?: string | number;
badgeType: BadgeName;
badge: BadgesItem;
score?: number | null;
level?: string | null;
iconSize?: number;
size?: TBadgeSize;
};

const DEFAULT_ICON_SIZE = 40;

const Badge: React.FC<Properties> = ({
badgeType,
value,
badge,
score,
level,
iconSize = DEFAULT_ICON_SIZE,
size = BadgeSize.LARGE,
}) => {
// TODO: replace with real data
const badges: Record<BadgeName, BadgeProperties> = useMemo(() => {
return {
[BsaBadgeStepBadgesTitle.LECTURE_SCORE]: {
style: styles.lectureScore,
ending: ' / 5',
defaultValue: 4.2,
},
[BsaBadgeStepBadgesTitle.PROJECT_SCORE]: {
style: styles.projectScore,
ending: ' / 10',
defaultValue: 8.4,
},
[BsaBadgeStepBadgesTitle.COMMUNICATION_SCORE]: {
style: styles.communicationScore,
ending: ' / 10',
defaultValue: 10,
},
[BsaBadgeStepBadgesTitle.TEAM_SCORE]: {
style: styles.workingWithTeamScore,
ending: ' / 10',
defaultValue: 7,
},
[BsaBadgeStepBadgesTitle.ENGLISH_LEVEL]: {
style: styles.englishLevel,
ending: '',
defaultValue: 'B+',
},
[BsaBadgeStepBadgesTitle.PUNCTUALITY]: {
style: styles.punctuality,
ending: ' / 10',
defaultValue: 7,
},
};
}, []);

const valueFontSize =
size === BadgeSize.SMALL ? TextCategory.H5 : TextCategory.H4;

Expand All @@ -99,24 +49,24 @@ const Badge: React.FC<Properties> = ({
style={[
globalStyles.p5,
globalStyles.borderRadius9,
badges[badgeType].style,
{ backgroundColor: getBadgeColor(badge.type) },
size === BadgeSize.SMALL && globalStyles.alignSelfFlexStart,
]}
>
<MaterialIcon
name={IconName.HEADPHONES}
<CommunityIcon
name={getBadgeIcon(badge.type)}
size={iconSize}
color="#FFF"
/>
</View>
<View style={styles.textWrapper}>
<View style={globalStyles.flexDirectionRow}>
<Text category={valueFontSize}>
{value ?? badges[badgeType].defaultValue}
</Text>
<Text category={valueFontSize} style={styles.maxScore}>
{badges[badgeType].ending}
</Text>
<Text category={valueFontSize}>{score ?? level}</Text>
{badge.maxScore && (
<Text category={valueFontSize} style={styles.maxScore}>
{badge.maxScore}
</Text>
)}
</View>
<Text
maxFontSizeMultiplier={1}
Expand All @@ -126,7 +76,7 @@ const Badge: React.FC<Properties> = ({
: TextCategory.LABEL
}
>
{badgeType}
{badge.name}
</Text>
</View>
</View>
Expand Down
22 changes: 0 additions & 22 deletions mobile/src/bundles/common/components/badge/constants/constants.ts

This file was deleted.

4 changes: 2 additions & 2 deletions mobile/src/bundles/common/components/tag/tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { globalStyles } from '~/bundles/common/styles/styles';
import { styles } from './styles';

type Properties = {
value: string;
value: string | number;
iconName?: string;
iconSize?: number;
onPress?: (value: string) => void;
onPress?: (value: string | number) => void;
};
const DEFAULT_ICON_SIZE = 12;

Expand Down
1 change: 1 addition & 0 deletions mobile/src/bundles/common/enums/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export {
ApiPath,
AppEnvironment,
BsaBadgeStepBadgesTitle,
BsaBadgesTypeEnum,
ContentType,
Country,
EmploymentType,
Expand Down
6 changes: 5 additions & 1 deletion mobile/src/bundles/common/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ export { createDrawerNavigator } from '@react-navigation/drawer';
export { createNativeStackNavigator } from '@react-navigation/native-stack';
export { formatDistanceToNow, parseISO } from 'date-fns';
export { launchCamera, launchImageLibrary } from 'react-native-image-picker';
export { getAvatarInitials } from 'shared/build/index.js';
export {
getAvatarInitials,
getBadgeColor,
getBadgeIcon,
} from 'shared/build/index.js';
3 changes: 3 additions & 0 deletions mobile/src/bundles/common/store/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createSlice, isAnyOf } from '@reduxjs/toolkit';
import { DataStatus } from '~/bundles/common/enums/enums';
import {
type UserDetailsGeneralResponseDto,
type UserDetailsResponseDto,
type ValueOf,
} from '~/bundles/common/types/types';

Expand All @@ -16,11 +17,13 @@ import {
type State = {
dataStatus: ValueOf<typeof DataStatus>;
onboardingData: UserDetailsGeneralResponseDto | null;
talentsData: UserDetailsResponseDto[] | null;
};

const initialState: State = {
dataStatus: DataStatus.IDLE,
onboardingData: null,
talentsData: null,
};

const { reducer, actions, name } = createSlice({
Expand Down
1 change: 1 addition & 0 deletions mobile/src/bundles/common/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export {
type RadioGroupProps,
} from 'react-native-radio-buttons-group';
export {
type BadgesItem,
type HardSkillsResponseDto,
type ServerErrorDetail,
type ServerErrorResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import {
type UserDetailsResponseDto,
type UserDetailsUpdateRequestDto,
} from '~/bundles/common/types/types';
import { type BsaBadgesStepDto } from '~/bundles/talent/types/types';
import { type FormattedHardSkillsItem } from '~/bundles/common-data/types/types';
import { type BsaBadgesStepTypes } from '~/bundles/talent/types/types';

// TODO: replace when we know backend dto

type HardSkillsDto = {
hardSkills: { value: string; label: string }[];
hardSkills: FormattedHardSkillsItem[];
};

//TODO delete when backend is ready
Expand All @@ -29,14 +32,14 @@ type UserDetailsGeneralCreateRequestDto = UserDetailsCreateRequestDto &
Partial<CompanyLogoDto>;

type UserDetailsGeneralRequestDto = UserDetailsUpdateRequestDto &
Partial<BsaBadgesStepDto> &
Partial<BsaBadgesStepTypes> &
Partial<HardSkillsDto> &
Partial<PhotoDto> &
Partial<CVDto> &
Partial<CompanyLogoDto>;

type UserDetailsGeneralResponseDto = UserDetailsResponseDto &
Partial<BsaBadgesStepDto> &
Partial<BsaBadgesStepTypes> &
Partial<HardSkillsDto> &
Partial<PhotoDto> &
Partial<CVDto> &
Expand Down
Loading

0 comments on commit 8a44ef5

Please sign in to comment.