Skip to content
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

Feat: 상품 썸네일 및 판매시작 api 연동 #124

Merged
merged 14 commits into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/pages/CreateProduct/Confirm/Confirm.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Typography } from '@material-ui/core';
import { Link } from 'react-router-dom';
import styled from 'styled-components';
import { theme } from 'themes';

export const ProductCard = styled(Link)`
color: ${theme.palette.common.black};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: color: ${palette.text.secondary}; 이런거 안써주시고 새로 정의하신 이유가 궁금해욤

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A: 정의한게 아니라 palette 정의된거 보니까 기본으로 common이라는 객체가 있고 그 안에 white, black 있습니당!
palette.ts에 common 정의되어있는거 제가 한 것 같은데 ,, 왜 추가했는지 ,, 기억도 나지 않고 제거해도 동일하게 작동하네요 (33789a3 )
${palette.text.secondary}는 회색인 것 같슴다

image
node_modules/@material-ui/core/styles/createPalette.d.ts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${palette.text.primary}도 있어용

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eb76c79 수정했어용

text-decoration: none;
width: ${theme.spacing(55)};
border: 5px solid ${theme.palette.grey[200]};
border-radius: ${theme.spacing(6)};
`;

export const RepresentativeImage = styled.img`
width: ${theme.spacing(55)};
height: ${theme.spacing(46)};
border-radius: ${theme.spacing(6)};
`;

export const Tag = styled.div`
display: inline-block;
background: ${theme.palette.grey[300]};
padding: ${theme.spacing(1)};
margin: ${theme.spacing(0.4)};
border-radius: ${theme.spacing(2)};
font-size: ${theme.spacing(1.5)};
`;

export const Price = styled(Typography)`
margin-left: ${theme.spacing(1)};
`;

export const InfoMessage = styled.li`
margin-top: ${theme.spacing(1)};
`;
83 changes: 83 additions & 0 deletions src/pages/CreateProduct/Confirm/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { Box, Grid, Typography } from '@material-ui/core';
import React from 'react';
import { useRecoilValue } from 'recoil';

import { currentProductInputAtom } from '../recoils';

import {
ProductCard,
RepresentativeImage,
InfoMessage,
Price,
Tag,
} from './Confirm.css';

const Confirm = (): React.ReactElement => {
const { name, fullPrice, discountPrice, representativeImageUrl, tags } =
useRecoilValue(currentProductInputAtom);

const splitTags = (): string[] => {
return tags
.split('#')
.map((tag) => tag.trim())
.filter((value) => value);
};
jiyaaany marked this conversation as resolved.
Show resolved Hide resolved

const getRate = (): string => {
const rate = Math.round((discountPrice / fullPrice) * 100);

return isNaN(rate) ? '' : rate.toString();
};

const getPrice = (): string => {
const price = fullPrice - discountPrice;

return isNaN(price) && Math.sign(price) ? '' : price.toLocaleString();
};

return (
<>
<Grid container justifyContent="center">
<ProductCard to="/product/1">
{representativeImageUrl && (
<RepresentativeImage
src="//via.placeholder.com/500x300"
alt="상품 대표 이미지"
/>
)}
<Box px={4} py={2}>
<Typography variant="h4">{name}</Typography>
<Box display="flex" justifyContent="space-between" mt={4}>
<div>
{splitTags().map((tag: string) => (
<Tag>#{tag}</Tag>
))}
</div>
<Box display="flex">
<Typography color="primary">
<b>{getRate()}%</b>
</Typography>
<Price variant="h4">{getPrice()}원</Price>
</Box>
</Box>
</Box>
</ProductCard>
</Grid>
<ul>
<InfoMessage>
상품은 위와 같이 다른 니터들에게 노출될 예정이에요!
</InfoMessage>
<InfoMessage>클릭하면 상세도 확인해볼 수 있어요!</InfoMessage>
<InfoMessage>
노출되는 기간은 "
<Typography display="inline" color="primary">
jiyaaany marked this conversation as resolved.
Show resolved Hide resolved
상품이 등록된 이후부터 계속해서
</Typography>
" 노출됩니다.
</InfoMessage>
</ul>
</>
);
};

export default Confirm;
4 changes: 3 additions & 1 deletion src/pages/CreateProduct/components/Footer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FAILED_TO_SAVE_PRODUCT } from 'constants/errors';
import { MY_INFORMATION_ROUTER_ROOT } from 'constants/path';

import { Button as MaterialButton } from '@material-ui/core';
import { useCommonSnackbar } from 'components/CommonSnackbar/useCommonSnackbar';
Expand All @@ -12,6 +13,7 @@ import { PAGE } from 'pages/CreateProduct/types';
import React, { useState } from 'react';
import { useRecoilState, useRecoilValue } from 'recoil';
import { FooterContainer } from 'styles/constants';
import { request } from 'utils/requests';

const Footer = (): React.ReactElement => {
const { DESIGN, PACKAGE, INTRODUCTION, CONFIRM } = PAGE;
Expand Down Expand Up @@ -61,7 +63,7 @@ const Footer = (): React.ReactElement => {
mutate(postProductData);
};

const handleOnClickPrevious = (): void => {
const handleOnClickPrevious = async (): Promise<void> => {
switch (currentStep) {
case PACKAGE:
setCurrentStep(DESIGN);
Expand Down
11 changes: 9 additions & 2 deletions src/pages/CreateProduct/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@ import Package from 'pages/CreateProduct/Package';
import SelectDesigns from 'pages/CreateProduct/SelectDesigns';
import React from 'react';
import { useRecoilValue } from 'recoil';
import styled from 'styled-components';
import { theme } from 'themes';

import Confirm from './Confirm';
import Footer from './components/Footer';
import Header from './components/Header';
import { currentStepAtom } from './recoils';
import { PAGE } from './types';

const Container = styled.section`
margin-top: ${theme.spacing(1)};
`;

const CreateProduct = (): React.ReactElement => {
const currentStep = useRecoilValue(currentStepAtom);

Expand All @@ -21,7 +28,7 @@ const CreateProduct = (): React.ReactElement => {
case PAGE.INTRODUCTION:
return <div />;
case PAGE.CONFIRM:
return <div />;
return <Confirm />;
default:
return <div />;
}
Expand All @@ -30,7 +37,7 @@ const CreateProduct = (): React.ReactElement => {
return (
<Layout>
<Header />
{renderContent()}
<Container>{renderContent()}</Container>
<Footer />
</Layout>
);
Expand Down
3 changes: 3 additions & 0 deletions src/themes/palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { deepOrange } from './colors/deepOrange';

export const { palette } = createMuiTheme({
palette: {
common: {
black: '#000',
},
primary: {
light: deepOrange[200],
main: deepOrange[600],
Expand Down