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

[FE][Feat] #211 : 사용자 id로 채널 가져오기 api #231

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
57 changes: 57 additions & 0 deletions frontend/src/api/channel.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { ResponseDto } from '@/api/dto/response.dto.ts';
import {
createChannelReqEntity,
createChannelResEntity,
getUserChannelsResEntity,
} from '@/api/dto/channel.dto.ts';
import { getApiClient } from '@/api/client.api.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);
};

export const getUserChannels = (userId: string): Promise<ResponseDto<getUserChannelsResEntity>> => {
const promiseFn = (
fnResolve: (value: ResponseDto<getUserChannelsResEntity>) => void,
fnReject: (reason?: any) => void,
) => {
const apiClient = getApiClient();
apiClient
.get(`/channel/user/${userId}`)
.then(res => {
if (res.status !== 200) {
console.error(res);
fnReject(`msg.${res}`);
} else {
fnResolve(new ResponseDto<getUserChannelsResEntity>(res));
}
})
.catch(err => {
console.error(err);
fnReject('msg.RESULT_FAILED');
});
};
return new Promise(promiseFn);
};
59 changes: 59 additions & 0 deletions frontend/src/api/dto/channel.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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;
}

export class channelListEntity {
id: string | undefined;

name: string | undefined;

generated_at: string | undefined;
}

export class getUserChannelsResEntity {
channels: channelListEntity[] | undefined;
}
Loading