11import { EnvironmentConfig } from '~/config'
22import { UserSkill , xhrGetAsync , xhrPostAsync , xhrPutAsync } from '~/libs/core'
33
4- const baseUrl = `${ EnvironmentConfig . API . V5 } /emsi-skills/member-emsi-skills`
4+ const baseUrl = `${ EnvironmentConfig . API . V5 } /standardized-skills`
5+
6+ export interface UpdateUserSkillDTO {
7+ id : string
8+ levelId ?: string
9+ }
510
611export async function autoCompleteSkills ( queryTerm : string ) : Promise < UserSkill [ ] > {
712 if ( ! queryTerm ) {
813 return Promise . resolve ( [ ] )
914 }
1015
1116 const encodedQuery = encodeURIComponent ( queryTerm )
12- return xhrGetAsync ( `${ EnvironmentConfig . API . V5 } /emsi- skills/skills/auto-complete ?term=${ encodedQuery } ` )
17+ return xhrGetAsync ( `${ baseUrl } / skills/autocomplete ?term=${ encodedQuery } ` )
1318}
1419
1520export type FetchMemberSkillsConfig = {
@@ -19,19 +24,21 @@ export async function fetchMemberSkills(
1924 userId : string | number | undefined ,
2025 config : FetchMemberSkillsConfig ,
2126) : Promise < UserSkill [ ] > {
22- const url = `${ baseUrl } /${ userId } ?pageFlag =${ ! config . skipPagination } `
27+ const url = `${ baseUrl } /user-skills/ ${ userId } ?disablePagination =${ config . skipPagination } `
2328 return xhrGetAsync ( url )
2429}
2530
26- export async function createMemberSkills ( userId : number , skills : UserSkill [ ] ) : Promise < void > {
27- return xhrPostAsync ( baseUrl , {
31+ export async function createMemberSkills ( userId : number , skills : UpdateUserSkillDTO [ ] ) : Promise < void > {
32+ return xhrPostAsync ( ` ${ baseUrl } /user-skills/ ${ userId } ` , {
2833 skills,
29- userId,
3034 } )
3135}
3236
33- export async function updateMemberSkills ( userId : string | number , skills : UserSkill [ ] ) : Promise < void > {
34- return xhrPutAsync ( `${ baseUrl } /${ userId } ` , {
37+ export async function updateMemberSkills (
38+ userId : string | number ,
39+ skills : UpdateUserSkillDTO [ ] ,
40+ ) : Promise < void > {
41+ return xhrPutAsync ( `${ baseUrl } /user-skills/${ userId } ` , {
3542 skills,
3643 } )
3744}
0 commit comments