Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…eng-dong into feature/#563
  • Loading branch information
jinhokim98 committed Sep 21, 2024
2 parents 24f1da8 + 1ab3c0d commit 053e928
Show file tree
Hide file tree
Showing 208 changed files with 3,567 additions and 4,017 deletions.
1 change: 1 addition & 0 deletions client/cypress/e2e/createEvent.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import CONSTANTS from '../constants/constants';
beforeEach(() => {
cy.blockSentry();
cy.blockKakao();
});

describe('Flow: 랜딩 페이지에서부터 이벤트를 생성 완료하는 flow', () => {
Expand Down
8 changes: 8 additions & 0 deletions client/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ Cypress.Commands.add('blockSentry', () => {
cy.intercept('POST', /.*sentry.io\/api.*/, {statusCode: 200}).as('sentry');
});

Cypress.Commands.add('blockKakao', () => {
cy.intercept('GET', 'https://t1.kakaocdn.net/kakao_js_sdk/2.7.2/kakao.min.js', {
statusCode: 200,
body: '',
}).as('blockKakao');
});

Cypress.Commands.add('interceptAPI', ({type, delay = 0, statusCode = 200}: InterceptAPIProps) => {
if (type === 'postEvent')
cy.intercept(POST_EVENT, {
Expand Down Expand Up @@ -49,6 +56,7 @@ declare global {
namespace Cypress {
interface Chainable {
blockSentry(): Chainable<void>;
blockKakao(): Chainable<void>;
interceptAPI(props: InterceptAPIProps): Chainable<void>;
createEventName(eventName: string): Chainable<void>;
}
Expand Down
5 changes: 5 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
window.amplitude.init('<%= process.env.AMPLITUDE_KEY %>');
});
</script>
<script
src="https://t1.kakaocdn.net/kakao_js_sdk/2.7.2/kakao.min.js"
integrity="sha384-TiCUE00h649CAMonG018J2ujOgDKW/kVWlChEuu4jK2vxfAAD0eZxzCKakxg55G4"
crossorigin="anonymous"
></script>
<title>행동대장</title>
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions client/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const config: Config = {
testEnvironment: 'jsdom', // 브라우저 내에서의 JavaScript 동작을 모방하여, DOM 조작, 이벤트 핸들링, 브라우저 관련 API 호출
transform: {
'^.+\\.ts?$': 'ts-jest',
'^.+\\.svg$': '<rootDir>/src/mocks/svgMock.ts',
'^.+\\.(jpg|jpeg|png|gif|svg)$': '<rootDir>/src/mocks/imageFileMock.ts',
},
collectCoverage: true,
coverageReporters: ['text'],
Expand Down Expand Up @@ -48,7 +48,7 @@ const config: Config = {
'^@theme/(.*)$': '<rootDir>/src/components/Design/theme/$1',
'^@layouts/(.*)$': '<rootDir>/src/components/Design/layouts/$1',
'^@type/(.*)$': '<rootDir>/src/components/Design/type/$1',
'\\.svg$': '<rootDir>/src/mocks/svg.ts',
'\\.(jpg|jpeg|png|gif|svg)$': '<rootDir>/src/mocks/imageFileMock.ts',
},
testEnvironmentOptions: {
customExportConditions: [''],
Expand Down
35 changes: 35 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-hooks": "^4.6.2",
"file-loader": "^6.2.0",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"globals": "^15.8.0",
"html-loader": "^5.0.0",
Expand Down
8 changes: 7 additions & 1 deletion client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import {ReactQueryDevtools} from '@tanstack/react-query-devtools';
import {ToastProvider} from '@hooks/useToast/ToastProvider';
import QueryClientBoundary from '@components/QueryClientBoundary/QueryClientBoundary';
import ErrorCatcher from '@components/AppErrorBoundary/ErrorCatcher';
import KakaoInitializer from '@components/KakaoInitializer/KakaoInitializer';

import {HDesignProvider} from '@HDesign/index';

import NetworkStateCatcher from '@utils/NetworkStateCatcher';

import {GlobalStyle} from './GlobalStyle';
import UnhandledErrorBoundary from './UnhandledErrorBoundary';

Expand All @@ -20,7 +23,10 @@ const App: React.FC = () => {
<ErrorCatcher>
<QueryClientBoundary>
<ReactQueryDevtools initialIsOpen={false} />
<Outlet />
<NetworkStateCatcher />
<KakaoInitializer>
<Outlet />
</KakaoInitializer>
</QueryClientBoundary>
</ErrorCatcher>
</ToastProvider>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// TODO: (@weadie) 반복되서 쓰이는 이 api/events가 추후 수정 가능성이 있어서 일단 편집하기 편하게 이 변수를 재사용하도록 했습니다.
export const TEMP_PREFIX = '/api/events';
export const USER_API_PREFIX = '/api/events';
export const ADMIN_API_PREFIX = '/api/admin/events';
18 changes: 9 additions & 9 deletions client/src/apis/request/auth.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import {BASE_URL} from '@apis/baseUrl';
import {TEMP_PREFIX} from '@apis/tempPrefix';
import {ADMIN_API_PREFIX, USER_API_PREFIX} from '@apis/endpointPrefix';
import {requestPostWithoutResponse} from '@apis/fetcher';
import {WithEventId} from '@apis/withEventId.type';

export type RequestToken = {
password: string;
};
import {WithEventId} from '@apis/withId.type';

export const requestPostAuthentication = async ({eventId}: WithEventId) => {
await requestPostWithoutResponse({
baseUrl: BASE_URL.HD,
endpoint: `${TEMP_PREFIX}/${eventId}/auth`,
endpoint: `${ADMIN_API_PREFIX}/${eventId}/auth`,
});
};

export const requestPostToken = async ({eventId, password}: WithEventId<RequestToken>) => {
export interface RequestPostToken {
password: string;
}

export const requestPostToken = async ({eventId, password}: WithEventId<RequestPostToken>) => {
await requestPostWithoutResponse({
baseUrl: BASE_URL.HD,
endpoint: `${TEMP_PREFIX}/${eventId}/login`,
endpoint: `${USER_API_PREFIX}/${eventId}/login`,
body: {
password: password,
},
Expand Down
78 changes: 41 additions & 37 deletions client/src/apis/request/bill.ts
Original file line number Diff line number Diff line change
@@ -1,69 +1,73 @@
import type {Bill, MemberReportInAction} from 'types/serviceType';
import type {BillDetails} from 'types/serviceType';

import {BASE_URL} from '@apis/baseUrl';
import {TEMP_PREFIX} from '@apis/tempPrefix';
import {ADMIN_API_PREFIX, USER_API_PREFIX} from '@apis/endpointPrefix';
import {requestDelete, requestGet, requestPostWithoutResponse, requestPut} from '@apis/fetcher';
import {WithEventId} from '@apis/withEventId.type';
import {WithBillId, WithEventId} from '@apis/withId.type';

type RequestPostBillList = {
billList: Bill[];
};
export interface RequestPostBill {
title: string;
price: number;
members: number[];
}

export const requestPostBillList = async ({eventId, billList}: WithEventId<RequestPostBillList>) => {
export const requestPostBill = async ({eventId, title, price, members}: WithEventId<RequestPostBill>) => {
await requestPostWithoutResponse({
baseUrl: BASE_URL.HD,
endpoint: `${TEMP_PREFIX}/${eventId}/bill-actions`,
endpoint: `${ADMIN_API_PREFIX}/${eventId}/bills`,
body: {
actions: billList,
title,
price,
members,
},
});
};

type RequestBillAction = {
actionId: number;
};

export const requestDeleteBillAction = async ({eventId, actionId}: WithEventId<RequestBillAction>) => {
export const requestDeleteBill = async ({eventId, billId}: WithEventId<WithBillId>) => {
await requestDelete({
baseUrl: BASE_URL.HD,
endpoint: `${TEMP_PREFIX}/${eventId}/bill-actions/${actionId}`,
endpoint: `${ADMIN_API_PREFIX}/${eventId}/bills/${billId}`,
});
};

type RequestPutBillAction = Bill & RequestBillAction;
export interface RequestPutBill {
title: string;
price: number;
}

export const requestPutBillAction = async ({eventId, actionId, title, price}: WithEventId<RequestPutBillAction>) => {
export const requestPutBill = async ({eventId, billId, title, price}: WithEventId<WithBillId<RequestPutBill>>) => {
await requestPut({
baseUrl: BASE_URL.HD,
endpoint: `${TEMP_PREFIX}/${eventId}/bill-actions/${actionId}`,
body: {
title,
price,
},
endpoint: `${ADMIN_API_PREFIX}/${eventId}/bills/${billId}`,
body: {title, price},
});
};

export type MemberReportList = {members: MemberReportInAction[]};

export const requestGetMemberReportListInAction = async ({eventId, actionId}: WithEventId<RequestBillAction>) => {
return requestGet<MemberReportList>({
export const requestGetBillDetails = async ({eventId, billId}: WithEventId<WithBillId>) => {
return requestGet<BillDetails>({
baseUrl: BASE_URL.HD,
endpoint: `${TEMP_PREFIX}/${eventId}/bill-actions/${actionId}/fixed`,
endpoint: `${USER_API_PREFIX}/${eventId}/bills/${billId}/fixed`,
});
};

type RequestPutMemberReportList = RequestBillAction & MemberReportList;
interface PutBillDetail {
id: number;
price: number;
isFixed: boolean;
}

export interface RequestPutBillDetails {
billDetails: PutBillDetail[];
}

export const requestPutMemberReportListInAction = async ({
export const requestPutBillDetails = async ({
eventId,
actionId,
members,
}: WithEventId<RequestPutMemberReportList>) => {
return requestPut({
billId,
billDetails,
}: WithEventId<WithBillId<RequestPutBillDetails>>) => {
await requestPut({
baseUrl: BASE_URL.HD,
endpoint: `${TEMP_PREFIX}/${eventId}/bill-actions/${actionId}/fixed`,
body: {
members,
},
endpoint: `${ADMIN_API_PREFIX}/${eventId}/bills/${billId}/fixed`,
body: {billDetails},
});
};
49 changes: 30 additions & 19 deletions client/src/apis/request/event.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
import {TEMP_PREFIX} from '@apis/tempPrefix';
import {requestGet, requestPostWithResponse} from '@apis/fetcher';
import {WithEventId} from '@apis/withEventId.type';
import {Event, EventId} from 'types/serviceType';

export type RequestPostNewEvent = {
import {USER_API_PREFIX} from '@apis/endpointPrefix';
import {requestGet, requestPostWithResponse, requestPut} from '@apis/fetcher';
import {WithEventId} from '@apis/withId.type';

export interface RequestPostEvent {
eventName: string;
password: string;
};
}

export type ResponsePostNewEvent = {
eventId: string;
};

export const requestPostNewEvent = async ({eventName, password}: RequestPostNewEvent) => {
return await requestPostWithResponse<ResponsePostNewEvent>({
endpoint: TEMP_PREFIX,
export const requestPostEvent = async ({eventName, password}: RequestPostEvent) => {
return await requestPostWithResponse<EventId>({
endpoint: USER_API_PREFIX,
body: {
eventName: eventName,
password: password,
eventName,
password,
},
});
};

type ResponseGetEventName = {
eventName: string;
export const requestGetEvent = async ({eventId}: WithEventId) => {
return await requestGet<Event>({
endpoint: `${USER_API_PREFIX}/${eventId}`,
});
};

export const requestGetEventName = async ({eventId}: WithEventId) => {
return requestGet<ResponseGetEventName>({
endpoint: `${TEMP_PREFIX}/${eventId}`,
export interface RequestPutEvent {
eventName?: string;
bankName?: string;
accountNumber?: string;
}

export const requestPutEvent = async ({eventId, eventName, bankName, accountNumber}: WithEventId<RequestPutEvent>) => {
return await requestPut({
endpoint: `${USER_API_PREFIX}/${eventId}`,
body: {
eventName,
bankName,
accountNumber,
},
});
};
Loading

0 comments on commit 053e928

Please sign in to comment.