Skip to content

Commit

Permalink
Fix: 내 동네 설정, 내 반경 설정 API URI 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaeYubin committed Aug 7, 2024
1 parent 97d3645 commit b945fad
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 75 deletions.
2 changes: 0 additions & 2 deletions src/mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import { locationHandlers } from './locations';
import { myActivityHandlers } from './my';
import { notificationHandlers } from './notifications';
import { profileHandlers } from './profiles';
import { radiusHandlers } from './radius';
import { rankingHandlers } from './rankings';
import { reviewHandlers } from './reviews';

export const handlers = [
...authHandlers,
...articleHandlers,
...locationHandlers,
...radiusHandlers,
...boardCafeHandlers,
...rankingHandlers,
...participationHandlers,
Expand Down
61 changes: 1 addition & 60 deletions src/mocks/locations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,4 @@ import { API_BASE_URL } from '@/constants/env';
import { http, HttpResponse } from 'msw';
import { searchLocation } from './search';

export const location = http.post(`${API_BASE_URL}/api/locations`, async () => {
const result = {
status: 'success',
data: {
'2': [
{
sido: '서울특별시',
sgg: '종로구',
emd: '청운동',
},
{
sido: '서울특별시',
sgg: '종로구',
emd: '신교동',
},
],
'5': [
{
sido: '서울특별시',
sgg: '종로구',
emd: '청운동',
},
{
sido: '서울특별시',
sgg: '종로구',
emd: '신교동',
},
],
'7': [
{
sido: '서울특별시',
sgg: '종로구',
emd: '청운동',
},
{
sido: '서울특별시',
sgg: '종로구',
emd: '신교동',
},
],
'10': [
{
sido: '서울특별시',
sgg: '종로구',
emd: '청운동',
},
{
sido: '서울특별시',
sgg: '종로구',
emd: '신교동',
},
],
},
message: '위치 정보 설정을 성공하였습니다.',
};

return HttpResponse.json(result, { status: 200 });
});

export const locationHandlers = [location, searchLocation];
export const locationHandlers = [searchLocation];
5 changes: 4 additions & 1 deletion src/mocks/my/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { getMyArticles } from './gather-articles';
import { getMyNeighborhoods } from './neighborhoods';
import { getMyNeighborhoods, setMyNeighborhoods } from './neighborhoods';
import { getMyJoinedArticles } from './participations';
import { setRadius } from './radius';

export const myActivityHandlers = [
getMyArticles,
getMyJoinedArticles,
getMyNeighborhoods,
setRadius,
setMyNeighborhoods,
];
67 changes: 67 additions & 0 deletions src/mocks/my/neighborhoods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,70 @@ export const getMyNeighborhoods = http.get(
return HttpResponse.json(result, { status: 200 });
},
);

export const setMyNeighborhoods = http.put(
`${API_BASE_URL}/api/my/neighborhoods`,
async () => {
const result = {
status: 'success',
data: {
locations: {
'2': [
{
sido: '서울특별시',
sgg: '종로구',
emd: '청운동',
},
{
sido: '서울특별시',
sgg: '종로구',
emd: '신교동',
},
],
'5': [
{
sido: '서울특별시',
sgg: '종로구',
emd: '청운동',
},
{
sido: '서울특별시',
sgg: '종로구',
emd: '신교동',
},
],
'7': [
{
sido: '서울특별시',
sgg: '종로구',
emd: '청운동',
},
{
sido: '서울특별시',
sgg: '종로구',
emd: '신교동',
},
],
'10': [
{
sido: '서울특별시',
sgg: '종로구',
emd: '청운동',
},
{
sido: '서울특별시',
sgg: '종로구',
emd: '신교동',
},
],
},
longitude: 126.96932389009248,
latitude: 37.58920545163482,
radius: 5,
},
message: '내 동네 조회를 성공하였습니다.',
};

return HttpResponse.json(result, { status: 200 });
},
);
6 changes: 2 additions & 4 deletions src/mocks/radius/index.ts → src/mocks/my/radius.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { API_BASE_URL } from '@/constants/env';
import { http, HttpResponse } from 'msw';

export const radius = http.post(`${API_BASE_URL}/api/radius`, async () => {
export const setRadius = http.put(`${API_BASE_URL}/api/my/radius`, async () => {
const result = {
status: 'success',
data: null,
message: '반경 설정을 성공하였습니다.',
message: '반경 설정을 성공하였습니다.',
};

return HttpResponse.json(result, { status: 200 });
});

export const radiusHandlers = [radius];
16 changes: 8 additions & 8 deletions src/services/location.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import api from '@/services';

/** 유저 위치 설정 API */
/** 내 동네 조회 API */
export const getMyNeighborhoods = () =>
api.get('/api/my/neighborhoods').then((response) => response.data.data);

/** 내 동네 설정 설정 API */
export const setLocation = ({ sido, sgg, emd }: { [key: string]: string }) =>
api.post('/api/locations', { sido, sgg, emd });
api.put('/api/my/neighborhoods', { sido, sgg, emd });

/** 위치 반경 설정 API */
/** 반경 설정 API */
export const setRadius = ({ radius }: { radius: 2 | 5 | 7 | 10 }) =>
api.post('/api/radius', { radius });
api.put('/api/my/radius', { radius });

/** 위치 검색 API */
export const searchLocation = (keyword: string, forAuth: boolean) => {
Expand All @@ -18,7 +22,3 @@ export const searchLocation = (keyword: string, forAuth: boolean) => {
.get(`/api/locations/search?emd=${keyword}`)
.then((response) => response.data.data.locations);
};

/** 내 동네 조회 API */
export const getMyNeighborhoods = () =>
api.get('/api/my/neighborhoods').then((response) => response.data.data);

0 comments on commit b945fad

Please sign in to comment.