Skip to content

Commit

Permalink
feat: 행사 생성 페이지 구현 (#87)
Browse files Browse the repository at this point in the history
* feat: 행사 생성 페이지 디자인시스템 적용

* design : index.css 수정

* feat: 행사 생성 api 연결

* style: lint 적용
  • Loading branch information
Todari authored Jul 24, 2024
1 parent 165618a commit ce65a4c
Show file tree
Hide file tree
Showing 18 changed files with 182 additions and 165 deletions.
2 changes: 1 addition & 1 deletion client/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"jsxSingleQuote": false,
"bracketSpacing": false,
"proseWrap": "preserve"
}
}
193 changes: 84 additions & 109 deletions client/package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
},
"dependencies": {
"@emotion/react": "^11.11.4",
"@types/dotenv-webpack": "^7.0.7",
"dotenv-webpack": "^8.1.0",
"haengdong-design": "^0.1.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.24.1"
Expand Down
7 changes: 6 additions & 1 deletion client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import {HDesignProvider} from 'haengdong-design';
import {Outlet} from 'react-router-dom';

const App: React.FC = () => {
return <Outlet />;
return (
<HDesignProvider>
<Outlet />
</HDesignProvider>
);
};

export default App;
6 changes: 4 additions & 2 deletions client/src/apis/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type HeadersType = [string, string][] | Record<string, string> | Headers;
export type ObjectQueryParams = Record<string, string | number | boolean>;

type RequestProps = {
baseUrl: string;
baseUrl?: string;
endpoint: string;
headers?: HeadersType;
body?: Body | object | null;
Expand All @@ -24,6 +24,8 @@ type Options = {
body?: Body | null;
};

const API_BASE_URL = process.env.API_BASE_URL;

const objectToQueryString = (params: ObjectQueryParams): string => {
return Object.entries(params)
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
Expand Down Expand Up @@ -57,7 +59,7 @@ export const requestDelete = ({headers = {}, ...args}: RequestProps) => {
return fetcher({method: 'DELETE', headers, ...args});
};

const fetcher = ({method, baseUrl, endpoint, headers, body, queryParams}: FetcherProps) => {
const fetcher = ({baseUrl = API_BASE_URL, method, endpoint, headers, body, queryParams}: FetcherProps) => {
// const token = generateBasicToken(USER_ID, USER_PASSWORD);
const options = {
method,
Expand Down
13 changes: 13 additions & 0 deletions client/src/apis/requestPostEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {requestPost} from './fetcher';

interface RequestPostEventProps {
name: string;
}

export const requestPostEvent = async ({name}: RequestPostEventProps) => {
requestPost({
headers: {'Content-Type': 'application/json'},
body: {name},
endpoint: '/api/events',
});
};
4 changes: 2 additions & 2 deletions client/src/constants/routerUrls.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const ROUTER_URLS = {
main: '',
createEvent: '/create-event',
completeCreateEvent: '/create-event/complete',
eventCreateName: '/event/create/name',
eventCreateComplete: '/event/create/complete',
event: '/event',
eventManage: '/event/:eventId',
};
6 changes: 5 additions & 1 deletion client/src/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
body {
max-width: 768px;
height: 100lvh;
margin: 0 auto;
border: 1px solid gray;
}

section {
width: 100%;
}
1 change: 0 additions & 1 deletion client/src/pages/CompleteCreateEvent/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {useEffect, useState} from 'react';
import {useLocation, useNavigate} from 'react-router-dom';
import {FixedButton, MainLayout, Title} from 'haengdong-design';

import {ROUTER_URLS} from '@constants/routerUrls';

Expand All @@ -11,7 +12,7 @@ const CompleteCreateEvent = () => {
useEffect(() => {
const getUrl = async () => {
const eventTitle = location.search;
console.log(eventTitle);
// console.log(eventTitle);

// const url = await fetch();
setUrl('hangsapage');
Expand All @@ -21,14 +22,15 @@ const CompleteCreateEvent = () => {
}, []);

return (
<section>
<h1>행사 개시</h1>
<h3>
행사가 성공적으로 개시됐어요 :) 행사 링크를 통해서 참여자 관리가 가능해요. 관리를 위해서 행사 관리 링크를 보관해
주세요.
</h3>
<button onClick={() => navigate(`${ROUTER_URLS.event}/${url}`)}>관리 페이지로 이동</button>
</section>
<MainLayout>
{/* <TopNav navType="back" /> */}
<Title
title="행사 개시"
description="행사가 성공적으로 개시됐어요 :) 행사 링크를 통해서 참여자 관리가 가능해요. 관리를 위해서 행사 관리 링크를 보관해
주세요."
/>
<FixedButton onClick={() => navigate(`${ROUTER_URLS.event}/${url}`)}>관리 페이지로 이동</FixedButton>
</MainLayout>
);
};

Expand Down
36 changes: 36 additions & 0 deletions client/src/pages/Create/Name.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {useState} from 'react';
import {useNavigate} from 'react-router-dom';
import {FixedButton, Input, MainLayout, TextButton, Title, TopNav} from 'haengdong-design';

import {requestPostEvent} from '@apis/requestPostEvent';

import {ROUTER_URLS} from '@constants/routerUrls';

const CreateEvent = () => {
const [eventTitle, setEventTitle] = useState('');
const navigate = useNavigate();

const submitEventTitle = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
const result = await requestPostEvent({name: eventTitle});

navigate(`${ROUTER_URLS.eventCreateComplete}?${new URLSearchParams({title: eventTitle})}`);
};

return (
<MainLayout>
<TopNav navType="back" />
<Title title="행사 이름 입력" description="시작할 행사 이름을 입력해 주세요." />
<form onSubmit={submitEventTitle}>
<Input
value={eventTitle}
onChange={event => setEventTitle(event.target.value)}
placeholder="ex) 행동대장 야유회"
/>
<FixedButton>행동 개시!</FixedButton>
</form>
</MainLayout>
);
};

export default CreateEvent;
2 changes: 2 additions & 0 deletions client/src/pages/Create/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {default as CreateNamePage} from './Name';
export {default as CreateCompletePage} from './Complete';
27 changes: 0 additions & 27 deletions client/src/pages/CreateEvent/CreateEvent.tsx

This file was deleted.

1 change: 0 additions & 1 deletion client/src/pages/CreateEvent/index.ts

This file was deleted.

10 changes: 6 additions & 4 deletions client/src/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import {useNavigate} from 'react-router-dom';
import {FixedButton, MainLayout, Title} from 'haengdong-design';

import {ROUTER_URLS} from '@constants/routerUrls';

const Main = () => {
const navigate = useNavigate();

return (
<section>
<h1>행동대장</h1>
<button onClick={() => navigate(ROUTER_URLS.createEvent)}>행사 생성하기</button>
</section>
<MainLayout>
{/* <TopNav navType="back" /> */}
<Title title="행동대장" description="랜딩페이지입니다." />
<FixedButton onClick={() => navigate(ROUTER_URLS.eventCreateName)}>행사 생성하기</FixedButton>
</MainLayout>
);
};

Expand Down
11 changes: 5 additions & 6 deletions client/src/router.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {createBrowserRouter} from 'react-router-dom';

import {MainPage} from '@pages/Main';
import {CreateEventPage} from '@pages/CreateEvent';
import {CompleteCreateEventPage} from '@pages/CompleteCreateEvent';
import {CreateNamePage, CreateCompletePage} from '@pages/Create';
import {EventPage} from '@pages/Event';

import {ROUTER_URLS} from '@constants/routerUrls';
Expand All @@ -20,12 +19,12 @@ const router = createBrowserRouter([
element: <MainPage />,
},
{
path: ROUTER_URLS.createEvent,
element: <CreateEventPage />,
path: ROUTER_URLS.eventCreateName,
element: <CreateNamePage />,
},
{
path: ROUTER_URLS.completeCreateEvent,
element: <CompleteCreateEventPage />,
path: ROUTER_URLS.eventCreateComplete,
element: <CreateCompletePage />,
},
{
path: ROUTER_URLS.eventManage,
Expand Down
3 changes: 2 additions & 1 deletion client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,

"types": ["jest"],
"types": ["node", "jest"],
"esModuleInterop": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
Expand All @@ -46,5 +46,6 @@
},
"outDir": "./dist"
},
"node": true,
"include": ["src"]
}
2 changes: 2 additions & 0 deletions client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import HtmlWebpackPlugin from 'html-webpack-plugin';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import {ModifySourcePlugin, ConcatOperation} from 'modify-source-webpack-plugin';
import {fileURLToPath} from 'url';
import Dotenv from 'dotenv-webpack';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand Down Expand Up @@ -62,6 +63,7 @@ export default {
},
],
}),
new Dotenv(),
],
devServer: {
port: 3000,
Expand Down

0 comments on commit ce65a4c

Please sign in to comment.