Skip to content

Commit

Permalink
#17 [Feat] add URL parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
eunbis committed Jul 26, 2022
1 parent 3491e12 commit 9771892
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 26 deletions.
5 changes: 4 additions & 1 deletion src/AppRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ function AppRouter() {
<Route path="/save" element={<Save />} />
<Route path="/complete" element={<SaveComplete />} />
<Route path="/vote" element={<Vote />} />
<Route path="/votecomplete" element={<VoteComplete />} />
<Route
path="/votecomplete/:clothes/:place"
element={<VoteComplete />}
/>
<Route path="/mypage" element={<MyPage />} />
<Route path="/mypage/save/:date" element={<SaveRecord />} />
<Route path="/" element={<Main />} />
Expand Down
13 changes: 10 additions & 3 deletions src/pages/Vote/VoteComplete/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
/* eslint-disable import/no-unresolved */
import React from 'react';
import { useNavigate } from 'react-router-dom';
import { useNavigate, useParams } from 'react-router-dom';
import {
StyledRoot,
MainText,
ContentBox,
Clothes,
Place,
Params,
HomeButton,
Text,
} from './style';

function VoteComplete() {
const navigate = useNavigate();
const { clothes } = useParams();
const { place } = useParams();

return (
<StyledRoot>
<MainText>ํˆฌํ‘œ๊ฐ€ ๋“ฑ๋ก๋˜์—ˆ์–ด์š”</MainText>
<ContentBox>
<Clothes>์˜ค๋Š˜ ์ฃผ๊ฒฝ๋ฐ”๋ง‰</Clothes>
<Place>์กฐํ˜•์˜ˆ์ˆ ๊ด€์—์„œ ํ—ˆ, ๋ถˆํ—ˆ?</Place>
<Clothes>
์˜ค๋Š˜ <Params>{clothes}</Params>
</Clothes>
<Place>
<Params>{place}</Params>์—์„œ ํ—ˆ, ๋ถˆํ—ˆ?
</Place>
</ContentBox>
<HomeButton
onClick={() => {
Expand Down
19 changes: 18 additions & 1 deletion src/pages/Vote/VoteComplete/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ const Place = styled.p`
}
`;

const Params = styled.b`
font-weight: ${({ theme: { font } }) => font.weight.bold};
${applyMediaQuery('mobile')} {
font-weight: ${({ theme: { font } }) => font.weight.bold};
}
`;

const HomeButton = styled.button`
width: 20rem;
height: 5rem;
Expand All @@ -83,4 +91,13 @@ const Text = styled.p`
}
`;

export { StyledRoot, MainText, ContentBox, Clothes, Place, HomeButton, Text };
export {
StyledRoot,
MainText,
ContentBox,
Clothes,
Place,
Params,
HomeButton,
Text,
};
40 changes: 19 additions & 21 deletions src/pages/Vote/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable import/no-unresolved */
import React, { useState } from 'react';
/* eslint-disable */
import React, { useState, useParams } from 'react';
import { useNavigate } from 'react-router-dom';
import { WhiteLeft } from 'assets';
import { HeaderIcon, PublicButton } from 'components';
Expand All @@ -21,23 +21,20 @@ import {
function Vote() {
const navigate = useNavigate();

const [clothesText, setClothesText] = useState(true);
const [clothes, setClothes] = useState('');
const [place, setPlace] = useState('');

const changeHandler = () => {
setClothesText(false);
const cChangeHandler = e => {
setClothes(e.target.value);
};

// const [content, setContent] = useState({
// clothes: '',
// place: '',
// });
const pChangeHandler = e => {
setPlace(e.target.value);
};

// const onChangeContent = e => {
// setContent({
// ...content,
// [e.target.name]: e.target.value,
// });
// };
const handleSubmit = e => {
e.preventDefault();
};

return (
<StyledRoot>
Expand All @@ -64,14 +61,14 @@ function Vote() {
<SubjectText>
์˜ค๋Š˜ ์ด ์˜ท<span>*</span>
</SubjectText>
<Form>
<Form onSubmit={handleSubmit}>
<input
type="text"
name="clothes"
placeholder="์ž…๊ณ ์‹ถ์€ ์˜ท์„ ์ ์–ด์ฃผ์„ธ์š”"
required="required"
// onChange={(changeHandler, onChangeContent)}
onChange={changeHandler}
value={clothes}
onChange={cChangeHandler}
/>
</Form>
</FormBox>
Expand All @@ -82,7 +79,8 @@ function Vote() {
type="text"
name="place"
placeholder="์˜ท์„ ์ž…๊ณ  ๊ฐˆ ์žฅ์†Œ๋ฅผ ์ ์–ด์ฃผ์„ธ์š”"
// onChange={onChangeContent}
value={place}
onChange={pChangeHandler}
/>
</Form>
</FormBox>
Expand All @@ -91,10 +89,10 @@ function Vote() {
<ButtonBox>
<PublicButton
onClick={() => {
navigate('/votecomplete');
navigate(`/votecomplete/${clothes}/${place}`);
}}
text="ํˆฌํ‘œ ๋งŒ๋“ค๊ธฐ"
isDisabled={clothesText}
isDisabled={clothes.length > 0 ? 0 : 1}
/>
</ButtonBox>
</StyledRoot>
Expand Down

0 comments on commit 9771892

Please sign in to comment.