-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/create clothes intro page #12
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c22a61c
feat: clothes introduction page
readygetset b46ab66
Merge branch 'develop' of https://github.com/KWEBofficial/stylevillag…
readygetset f4904ca
feat: clothes intro page completion
readygetset 042d23c
mod
readygetset fa87233
Merge branch 'develop' of https://github.com/KWEBofficial/stylevillag…
readygetset bcaac39
Merge branch 'develop' into feature/create-clothes-intro-page
readygetset File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Button } from '@mui/material'; | ||
|
||
interface ApplyBtnProp { | ||
status: string; | ||
} | ||
export default function ApplyBtn({ status }: ApplyBtnProp) { | ||
if (status === '대여가능') { | ||
return ( | ||
<Button sx={{ borderRadius: 10, width: 250, backgroundColor: 'black', color: 'white' }}>대여 신청하기</Button> | ||
); | ||
} | ||
if (status === '대여불가능') { | ||
return ( | ||
<Button disabled sx={{ borderRadius: 10, width: 250, backgroundColor: 'red', color: 'white' }}> | ||
대여가 불가능한 옷이에요 | ||
</Button> | ||
); | ||
} | ||
if (status === '대여중') { | ||
return ( | ||
<Button disabled sx={{ borderRadius: 10, width: 250, backgroundColor: 'orange', color: 'white' }}> | ||
지금 대여 중인 옷이에요 | ||
</Button> | ||
); | ||
} | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { Box, Typography } from '@mui/material'; | ||
|
||
interface StatusSignProp { | ||
status: string; | ||
} | ||
export default function StatusSign({ status }: StatusSignProp) { | ||
if (status === '대여가능') { | ||
return ( | ||
<Box display={'flex'} alignItems={'center'} sx={{ mr: 1 }}> | ||
<Box | ||
sx={{ | ||
backgroundColor: 'green', | ||
width: 10, | ||
height: 10, | ||
borderRadius: 100, | ||
mr: 1, | ||
}} | ||
/> | ||
<Typography>{status}</Typography> | ||
</Box> | ||
); | ||
} | ||
if (status === '대여불가능') { | ||
return ( | ||
<Box display={'flex'} alignItems={'center'} sx={{ mr: 1 }}> | ||
<Box | ||
sx={{ | ||
backgroundColor: 'red', | ||
width: 10, | ||
height: 10, | ||
borderRadius: 100, | ||
mr: 1, | ||
}} | ||
/> | ||
<Typography>{status}</Typography> | ||
</Box> | ||
); | ||
} | ||
if (status === '대여중') { | ||
return ( | ||
<Box display={'flex'} alignItems={'center'} sx={{ mr: 1 }}> | ||
<Box | ||
sx={{ | ||
backgroundColor: 'orange', | ||
width: 10, | ||
height: 10, | ||
borderRadius: 100, | ||
mr: 1, | ||
}} | ||
/> | ||
<Typography>{status}</Typography> | ||
</Box> | ||
); | ||
} | ||
if (status === '공개중') { | ||
return ( | ||
<Box display={'flex'} alignItems={'center'} sx={{ mr: 1 }}> | ||
<Box | ||
sx={{ | ||
backgroundColor: 'black', | ||
width: 10, | ||
height: 10, | ||
borderRadius: 100, | ||
mr: 1, | ||
}} | ||
/> | ||
<Typography>{status}</Typography> | ||
</Box> | ||
); | ||
} | ||
|
||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { IconButton } from '@mui/material'; | ||
import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder'; | ||
import FavoriteIcon from '@mui/icons-material/Favorite'; | ||
|
||
interface WishBtnProps { | ||
handleWish: React.MouseEventHandler<HTMLButtonElement>; | ||
isWished: boolean; | ||
} | ||
|
||
const WishBtn: React.FC<WishBtnProps> = ({ handleWish, isWished = false }: WishBtnProps) => { | ||
return ( | ||
<IconButton onClick={handleWish} size="small"> | ||
{isWished ? <FavoriteIcon sx={{ color: 'black' }} /> : <FavoriteBorderIcon sx={{ color: 'black' }} />} | ||
</IconButton> | ||
); | ||
}; | ||
|
||
export default WishBtn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { enqueueSnackbar } from 'notistack'; | ||
import axios, { AxiosError } from 'axios'; | ||
|
||
import { CLOTHES_MESSAGE } from '../../../data/messages'; | ||
|
||
interface GetClothesParams { | ||
clothesId: number; | ||
token?: string; | ||
} | ||
interface Reviewer { | ||
id?: number; | ||
username: string; | ||
nickname?: string; | ||
} | ||
interface Review { | ||
review: string; | ||
reviewer: Reviewer; | ||
} | ||
interface Owner { | ||
id?: number; | ||
nickname?: string; | ||
location?: string; | ||
} | ||
export interface GetClothesResponse { | ||
id: number; | ||
description: string; | ||
category: string; | ||
season: string; | ||
status: string; | ||
isOpen: boolean; | ||
name: string; | ||
tag: string; | ||
image: string; | ||
owner: Owner; | ||
review: Review[]; | ||
isWished: boolean; | ||
} | ||
|
||
export async function getClothesAPICall({ clothesId, token }: GetClothesParams) { | ||
try { | ||
const response = await axios.get<GetClothesResponse>(`${process.env.REACT_APP_API_URL}/clothes/${clothesId}`, { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
}); | ||
if (response.status === 200) { | ||
return response.data; | ||
} | ||
} catch (err) { | ||
if (err instanceof AxiosError) { | ||
enqueueSnackbar(err.response?.data?.message ?? CLOTHES_MESSAGE.CLOTHES_NOT_FOUND, { variant: 'error' }); | ||
} else { | ||
enqueueSnackbar(CLOTHES_MESSAGE.CLOTHES_NOT_FOUND, { variant: 'error' }); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
export async function deleteClothesAPICall({ clothesId, token }: GetClothesParams) { | ||
try { | ||
const response = await axios.delete(`${process.env.REACT_APP_API_URL}/clothes/${clothesId}`, { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
}); | ||
if (response.status === 200) { | ||
enqueueSnackbar(CLOTHES_MESSAGE.CLOTHES_DELETED, { variant: 'success' }); | ||
} | ||
} catch (err) { | ||
if (err instanceof AxiosError) { | ||
enqueueSnackbar(err.response?.data?.message ?? CLOTHES_MESSAGE.CLOTHES_NOT_FOUND, { variant: 'error' }); | ||
} else { | ||
enqueueSnackbar(CLOTHES_MESSAGE.CLOTHES_NOT_FOUND, { variant: 'error' }); | ||
} | ||
} | ||
} | ||
interface Clothes { | ||
category: string; | ||
season: string; | ||
status: string; | ||
isOpen: boolean; | ||
name: string; | ||
tag: string; | ||
} | ||
interface EditClothesParams { | ||
clothesId: number; | ||
token?: string; | ||
clothes: Clothes; | ||
} | ||
export async function editClothesAPICall({ clothesId, token, clothes }: EditClothesParams) { | ||
try { | ||
const response = await axios.put(`${process.env.REACT_APP_API_URL}/clothes/${clothesId}`, clothes, { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
}); | ||
if (response.status === 200) { | ||
enqueueSnackbar(CLOTHES_MESSAGE.CLOTHES_EDITED, { variant: 'success' }); | ||
} | ||
} catch (err) { | ||
if (err instanceof AxiosError) { | ||
enqueueSnackbar(err.response?.data?.message ?? CLOTHES_MESSAGE.CLOTHES_NOT_FOUND, { variant: 'error' }); | ||
} else { | ||
enqueueSnackbar(CLOTHES_MESSAGE.CLOTHES_NOT_FOUND, { variant: 'error' }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { enqueueSnackbar } from 'notistack'; | ||
import axios, { AxiosError } from 'axios'; | ||
|
||
import { WISH_MESSAGE } from '../../../data/messages'; | ||
|
||
interface WishAPIParams { | ||
clothesId: number; | ||
token: string; | ||
} | ||
|
||
export async function createWishAPICall({ clothesId, token }: WishAPIParams) { | ||
try { | ||
const response = await axios.post( | ||
`${process.env.REACT_APP_API_URL}/wish/${clothesId}`, | ||
{}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}, | ||
); | ||
if (response.status === 200) { | ||
enqueueSnackbar(WISH_MESSAGE.WISH_CREATED, { variant: 'success' }); | ||
} | ||
} catch (err) { | ||
if (err instanceof AxiosError) { | ||
enqueueSnackbar(err.response?.data?.message ?? WISH_MESSAGE.WISH_FAIL, { variant: 'error' }); | ||
} else { | ||
enqueueSnackbar(WISH_MESSAGE.WISH_FAIL, { variant: 'error' }); | ||
} | ||
} | ||
} | ||
|
||
export async function deleteWishAPICall({ clothesId, token }: WishAPIParams) { | ||
try { | ||
const response = await axios.put( | ||
`${process.env.REACT_APP_API_URL}/wish/${clothesId}`, | ||
{}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}, | ||
); | ||
if (response.status === 200) { | ||
enqueueSnackbar(WISH_MESSAGE.WISH_DELETED, { variant: 'success' }); | ||
} | ||
} catch (err) { | ||
if (err instanceof AxiosError) { | ||
enqueueSnackbar(err.response?.data?.message ?? WISH_MESSAGE.WISH_FAIL, { variant: 'error' }); | ||
} else { | ||
enqueueSnackbar(WISH_MESSAGE.WISH_FAIL, { variant: 'error' }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기서 혹시 공개중으로 빠지는 경우가 있나요??
clothes page보니까 status가 대여불가능/대여중/대여가능 셋 중 하나일 것 같아서요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 그건 맞는데 공개중도 똑같은 컴포넌트로 표시하기도 해서요! 제가 쓰지는 않지만 다른 데서도 이거를 써가지구 혹시 몰라서 넣어놨습니다!