Skip to content

Commit

Permalink
Merge pull request #58 from MARU-EGG/TSK-50
Browse files Browse the repository at this point in the history
[TSK-50] api request url 변경 반영
  • Loading branch information
swgvenghy authored Nov 2, 2024
2 parents f97427f + 7084fa8 commit 85fca35
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 3 deletions.
60 changes: 60 additions & 0 deletions src/api/admin/admin-admission-type-detail.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { server_axiosInstance } from '../../utils/axios';
import { getCookie } from '../../utils/cookies';
import { TypeStatusProps } from './question-type-status/change-type-status';

export interface AdmissionTypeDetailProps extends TypeStatusProps {
detailTypeId: number;
detailTypeName: string;
}

export const updateAdmissionTypeDetail = async ({ detailTypeId, detailTypeName }: AdmissionTypeDetailProps) => {
try {
const response = server_axiosInstance.put(
`/api/admin/admissions/${detailTypeId}`,
{
detailTypeName,
},
{
headers: {
Authorization: `Bearer ${getCookie('accessToken')}`,
},
},
);
return (await response).data;
} catch (error: any) {
throw new Error('updated Failed', error);
}
};

export const deleteAdmissionTypeDetail = async ({ detailTypeId }: AdmissionTypeDetailProps) => {
try {
const response = server_axiosInstance.delete(`/api/admin/admission/${detailTypeId}`, {
headers: {
Authorization: `Bearer ${getCookie('accessToken')}`,
},
});
return (await response).data;
} catch (error: any) {
throw new Error('Delete Failed', error);
}
};

export const generateAdmissionTypeDetail = async ({ type, detailTypeName }: AdmissionTypeDetailProps) => {
try {
const response = server_axiosInstance.put(
`/api/admin/admissions/detail`,
{
detail: detailTypeName,
type: type,
},
{
headers: {
Authorization: `Bearer ${getCookie('accessToken')}`,
},
},
);
return (await response).data;
} catch (error: any) {
throw new Error('updated Failed', error);
}
};
4 changes: 2 additions & 2 deletions src/api/admin/question-type-status/change-type-status.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { server_axiosInstance } from '../../../utils/axios';
import { getCookie } from '../../../utils/cookies';

interface ChangeTypeStatusProps {
export interface TypeStatusProps {
type: 'SUSI' | 'JEONGSI' | 'PYEONIP';
}

export async function chnageTypeStatus({ type }: ChangeTypeStatusProps) {
export async function chnageTypeStatus({ type }: TypeStatusProps) {
try {
const response = await server_axiosInstance.put('/api/admin/questions/status', JSON.stringify({ type: type }), {
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/api/admin/question-type-status/get-type-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { server_axiosInstance } from '../../../utils/axios';

export async function getTypeStatus() {
try {
const response = await server_axiosInstance.get('/api/questions/status');
const response = await server_axiosInstance.get('/api/admissions/status');
return response.data;
} catch (error: any) {
throw new Error(`Upload failed: ${error.message}`);
Expand Down
20 changes: 20 additions & 0 deletions src/api/get-admission-detail-type.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { server_axiosInstance } from '../utils/axios';
import { TypeStatusProps } from './admin/question-type-status/change-type-status';

export const getAllDetailType = async () => {
try {
const response = await server_axiosInstance.get('/api/admissions/details');
return response.data;
} catch (error: any) {
throw new Error('get all detail type fail', error);
}
};

export const getDetailType = async ({ type }: TypeStatusProps) => {
try {
const response = await server_axiosInstance.get(`/api/admissions/detail/${type}`);
return response.data;
} catch (error: any) {
throw new Error('get all detail type fail', error);
}
};

0 comments on commit 85fca35

Please sign in to comment.