diff --git a/src/libs/shared/lib/components/member-skill-editor/use-member-skill-editor.tsx b/src/libs/shared/lib/components/member-skill-editor/use-member-skill-editor.tsx index 1f49c4e5f..87e2ceda2 100644 --- a/src/libs/shared/lib/components/member-skill-editor/use-member-skill-editor.tsx +++ b/src/libs/shared/lib/components/member-skill-editor/use-member-skill-editor.tsx @@ -1,5 +1,5 @@ import { ReactNode, useCallback, useContext, useEffect, useMemo, useState } from 'react' -import { differenceWith } from 'lodash' +import { differenceWith, pick } from 'lodash' import { profileContext, ProfileContextData, UserSkill } from '~/libs/core' @@ -45,13 +45,15 @@ export const useMemberSkillEditor = ({ return } + const skillIds = skills.map(skill => pick(skill, 'id')) + if (!isInitialized) { - await createMemberSkills(profile.userId, skills) + await createMemberSkills(profile.userId, skillIds) setIsInitialized(true) return } - await updateMemberSkills(profile.userId, skills) + await updateMemberSkills(profile.userId, skillIds) }, [isInitialized, profile?.userId, skills]) // Handle user changes diff --git a/src/libs/shared/lib/services/standard-skills/standard-skills.service.ts b/src/libs/shared/lib/services/standard-skills/standard-skills.service.ts index f0acd5ea6..1eb55874a 100644 --- a/src/libs/shared/lib/services/standard-skills/standard-skills.service.ts +++ b/src/libs/shared/lib/services/standard-skills/standard-skills.service.ts @@ -1,7 +1,12 @@ import { EnvironmentConfig } from '~/config' import { UserSkill, xhrGetAsync, xhrPostAsync, xhrPutAsync } from '~/libs/core' -const baseUrl = `${EnvironmentConfig.API.V5}/emsi-skills/member-emsi-skills` +const baseUrl = `${EnvironmentConfig.API.V5}/standardized-skills` + +export interface UpdateUserSkillDTO { + id: string + levelId?: string +} export async function autoCompleteSkills(queryTerm: string): Promise { if (!queryTerm) { @@ -9,7 +14,7 @@ export async function autoCompleteSkills(queryTerm: string): Promise { - const url = `${baseUrl}/${userId}?pageFlag=${!config.skipPagination}` + const url = `${baseUrl}/user-skills/${userId}?disablePagination=${config.skipPagination}` return xhrGetAsync(url) } -export async function createMemberSkills(userId: number, skills: UserSkill[]): Promise { - return xhrPostAsync(baseUrl, { +export async function createMemberSkills(userId: number, skills: UpdateUserSkillDTO[]): Promise { + return xhrPostAsync(`${baseUrl}/user-skills/${userId}`, { skills, - userId, }) } -export async function updateMemberSkills(userId: string | number, skills: UserSkill[]): Promise { - return xhrPutAsync(`${baseUrl}/${userId}`, { +export async function updateMemberSkills( + userId: string | number, + skills: UpdateUserSkillDTO[], +): Promise { + return xhrPutAsync(`${baseUrl}/user-skills/${userId}`, { skills, }) }