Skip to content

Commit

Permalink
[FE][Feat] #226 : 채널 생성 api 연동
Browse files Browse the repository at this point in the history
  • Loading branch information
happyhyep committed Nov 21, 2024
1 parent e0fe6db commit 67c44df
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
29 changes: 29 additions & 0 deletions frontend/src/api/channel.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ResponseDto } from '@/api/dto/response.dto.ts';
import { getApiClient } from '@/api/client.api.ts';
import { createChannelReqEntity, createChannelResEntity } from '@/api/dto/channel.dto.ts';

export const createChannel = (
data: createChannelReqEntity,
): Promise<ResponseDto<createChannelResEntity>> => {
const promiseFn = (
fnResolve: (value: ResponseDto<createChannelResEntity>) => void,
fnReject: (reason?: any) => void,
) => {
const apiClient = getApiClient();
apiClient
.post('/channel', data)
.then(res => {
if (res.status !== 200) {
console.error(res);
fnReject(`msg.${res}`);
} else {
fnResolve(new ResponseDto<createChannelResEntity>(res));
}
})
.catch(err => {
console.error(err);
fnReject('msg.RESULT_FAILED');
});
};
return new Promise(promiseFn);
};
47 changes: 47 additions & 0 deletions frontend/src/api/dto/channel.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export class locationEntity {
lat: number | undefined;

lng: number | undefined;
}

export class guestMarkerStyleEntity {
color: string | undefined;
}

export class guestEntity {
name: string | undefined;

start_location: locationEntity | undefined;

end_location: locationEntity | undefined;

path: locationEntity[] | undefined;

marker_style: guestMarkerStyleEntity | undefined;
}

export class createChannelReqEntity {
name: string | undefined;

host_id: string | undefined;

guests: guestEntity[] | undefined;
}

export class guestSimpleEntity {
id: string | undefined;

name: string | undefined;
}

export class createChannelResEntity {
id: string | undefined;

name: string | undefined;

host_id: string | undefined;

guests: guestSimpleEntity[] | undefined;

created_at: string | undefined;
}

0 comments on commit 67c44df

Please sign in to comment.