Skip to content

Commit

Permalink
feat: add survey API and types
Browse files Browse the repository at this point in the history
  • Loading branch information
timepresent95 committed Aug 20, 2024
1 parent 1034917 commit e932547
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/api/survey.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {kyInstance} from './ky';
import {surveyApis} from './routes';

import {Survey} from '@/types';
import {createUrl} from '@/utils/url';

type ParamGetSurvey = {
userId: string;
};

type ResponseGetSurvey = {
survey: Survey[];
};

async function getSurvey(param: ParamGetSurvey) {
const apiUrl = createUrl(surveyApis.getSurvey, {param});
return await kyInstance.get(apiUrl).json<ResponseGetSurvey>();
}

type BodyPostSurvey = {
survey: Survey[];
};

async function postSurvey(body: BodyPostSurvey) {
return await kyInstance.post(surveyApis.postSurvey, {json: body}).json();
}

export {getSurvey, postSurvey};
export type {ParamGetSurvey, ResponseGetSurvey, BodyPostSurvey};
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './user';
export * from './auth';
export * from './question';
export * from './survey';
4 changes: 4 additions & 0 deletions src/types/survey.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type Survey = {
id: string;
content: string;
};

0 comments on commit e932547

Please sign in to comment.