Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bt-541: replace candidate screen with real data and connect filters #569

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
89f91c9
bt-451: + employer slice
mskmee Sep 20, 2023
33dc326
bt-451: + employer api
mskmee Sep 20, 2023
133a663
bt-451: + candidate card value
mskmee Sep 20, 2023
faf781a
bt-541: + disable es lint comments
mskmee Sep 20, 2023
f6924c2
bt-541: + merge develop
mskmee Sep 21, 2023
713f1c7
bt-541: + filter basic data
mskmee Sep 21, 2023
d0ab01a
bt-541: + filter basic data
mskmee Sep 21, 2023
e2c3e64
bt-541: + merge development
mskmee Sep 21, 2023
f12a24d
bt-541: + filters logic
mskmee Sep 21, 2023
cea3c9f
bt-541: + bring back bsa badges to dto
mskmee Sep 21, 2023
a03c613
bt-541: * comment refactor
mskmee Sep 21, 2023
3d27d25
bt-541: * refactor filters logic
mskmee Sep 22, 2023
7d30788
bt-541: * add badges types
mskmee Sep 23, 2023
286c270
bt-541: + merge development
mskmee Sep 23, 2023
2734d03
bt-541: * refactor data helper
mskmee Sep 23, 2023
077d854
bt-541: * refactor types
mskmee Sep 23, 2023
ad92041
bt-541: * refactor types
mskmee Sep 23, 2023
7394f1b
bt-541: + badge helpers
mskmee Sep 23, 2023
6849b91
bt-541: + loader to profile page
mskmee Sep 23, 2023
7985f61
bt-541: + badges from backend
mskmee Sep 23, 2023
42554a1
bt-541: * refactor candidates list
mskmee Sep 23, 2023
b8941d1
bt-541: + sorted filter
mskmee Sep 23, 2023
ecb0c81
bt-541: * return lint values
mskmee Sep 23, 2023
4311e16
bt-541: * lint files
mskmee Sep 23, 2023
de1c2de
bt-541: * refactor variables
mskmee Sep 24, 2023
9a757b1
bt-541: + common data hook
mskmee Sep 24, 2023
bff3055
bt-530: * refactor api to one function
mskmee Sep 25, 2023
2e6a808
bt-530: + helpers
mskmee Sep 25, 2023
378e01b
bt-530: + development
mskmee Sep 25, 2023
a7008fc
bt-541: + merge development
mskmee Sep 25, 2023
ca60dab
bt-541: + fix issues after merge develop
mskmee Sep 25, 2023
f0c76ac
bt-541: * refactor type
mskmee Sep 26, 2023
f842f93
bt-541: + merge development
mskmee Sep 26, 2023
ac0195a
bt-541: * filter form type
mskmee Sep 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

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