Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/cardlist-size
Browse files Browse the repository at this point in the history
  • Loading branch information
devwqc authored Jun 24, 2024
2 parents bbe3a43 + 9e529d6 commit 16a5914
Show file tree
Hide file tree
Showing 21 changed files with 171 additions and 108 deletions.
2 changes: 1 addition & 1 deletion src/components/auth/LoginButton/GoogleLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function GoogleLogin() {
<a href={API_BASE_URL + `/auth/google/${process.env.NEXT_PUBLIC_AUTH_END}`}>
<div className={cx('googleButton')}>
<GoogleLogo />
<span>카카오로 계속하기</span>
<span>구글로 계속하기</span>
</div>
</a>
</>
Expand Down
3 changes: 2 additions & 1 deletion src/components/auth/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import NextButton from '@/components/common/Button/NextButton';
import NavBottom from '@/components/common/Nav/Bottom';
import FloatingBox from '@/components/common/Layout/Footer/FloatingBox';
import { cartQueries } from '@/apis/cart/queries';
import defaultImg from '@/assets/images/rectangle.png';

import styles from './Menu.module.scss';

Expand All @@ -25,7 +26,7 @@ export default function Menu() {
<div className={styles.menuLayout}>
<h1>마이페이지</h1>
<div className={styles.profileArea}>
<ProfileImgBadge size="large" profileImage={userData.profileImage.split('?')[0]} />
<ProfileImgBadge size="large" profileImage={userData.profileImage.split('?')[0] || defaultImg} />
<h2>{userData.nickname}</h2>
</div>
<div className={styles.centerBorder} />
Expand Down
20 changes: 11 additions & 9 deletions src/components/cart/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export default function Card({
onQuantityChange(newQuantity);
}

const formattedOriginalCost = originalCost.toLocaleString('ko-KR');
const formattedProductCost = productCost.toLocaleString('ko-KR');
const totalOriginalCost = (originalCost * productNumber + combinationPrice * productNumber).toLocaleString('ko-KR');
const totalProductCost = (productCost * productNumber + combinationPrice * productNumber).toLocaleString('ko-KR');
const formattedCombinationPrice = combinationPrice.toLocaleString('ko-KR');

return (
Expand All @@ -68,15 +68,17 @@ export default function Card({
<Image className={styles.productImg} src={imageUrl} width={56} height={56} alt="productImg" />
<div>
<div className={styles.productTitle}>{productTitle}</div>
<div className={styles.optionContainer}>
<div className={styles.option}>{option}</div>
<div className={styles.optionCost}>(+{formattedCombinationPrice}원)</div>
</div>
{option !== '기본' && (
<div className={styles.optionContainer}>
<div className={styles.option}>{option}</div>
<div className={styles.optionCost}>(+{formattedCombinationPrice}원)</div>
</div>
)}
<div className={styles.moneyContainerRight}>
<div className={styles.productCost}>{formattedOriginalCost}</div>
<div className={styles.productCost}>{totalOriginalCost}</div>
<div className={styles.realPrice}>
<div className={styles.discountRate}>{discountRate.toFixed(0)}%</div>
<div className={styles.realMoney}>{formattedProductCost}</div>
<div className={styles.realMoney}>{totalProductCost}</div>
</div>
</div>
</div>
Expand All @@ -86,7 +88,7 @@ export default function Card({
<button className={styles.plusminus} onClick={removeProduct}>
-
</button>
<input className={styles.productNumber} type="number" value={productNumber} readOnly />
<input className={styles.productNumber} type="text" value={productNumber} readOnly />
<button className={styles.plusminus} onClick={addProduct}>
+
</button>
Expand Down
2 changes: 2 additions & 0 deletions src/components/cart/TotalPay.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
}

.totalPrice {
font-size: 1.8rem;
font-weight: 700;
margin-top: 1rem;
display: flex;
justify-content: space-between;
Expand Down
11 changes: 8 additions & 3 deletions src/components/cart/TotalPay.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import classNames from 'classnames/bind';

import styles from './TotalPay.module.scss';

interface TotalPayProps {
totalPrice: number;
totalOriginalPrice: number;
productCount: number; // 전체 상품 수
title: string;
inOrder?: boolean;
}

export default function TotalPay({ totalPrice, totalOriginalPrice, title, productCount }: TotalPayProps) {
const cx = classNames.bind(styles);

export default function TotalPay({ totalPrice, totalOriginalPrice, title, productCount, inOrder }: TotalPayProps) {
const discountAmount = (totalOriginalPrice || 0) - (totalPrice || 0);
const formattedTotalOriginalPrice = (totalOriginalPrice || 0).toLocaleString('ko-KR');
const formattedTotalPrice = (totalPrice || 0).toLocaleString('ko-KR');
Expand All @@ -25,7 +30,7 @@ export default function TotalPay({ totalPrice, totalOriginalPrice, title, produc
<div>할인 금액</div>
<div className={styles.priceBold}>-{formattedDiscountAmount}</div>
</div>
<div className={`${styles.pricePair} ${styles.pink}`}>
<div className={cx('pricePair', { pink: !inOrder })}>
<div>결제 금액</div>
<div className={styles.priceBold}>{formattedTotalPrice}</div>
</div>
Expand All @@ -35,7 +40,7 @@ export default function TotalPay({ totalPrice, totalOriginalPrice, title, produc
</div>
</div>
<div className={styles.line}></div>
<div className={styles.totalPrice}>
<div className={cx('totalPrice', { pink: inOrder })}>
<div>총 결제 금액</div>
<div className={styles.totalPriceNum}>{formattedTotalPrice}</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion src/components/order/Empty/Empty.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
display: flex;
flex-direction: column;
padding-top: 2.4rem;
padding-right: 1.6rem;
justify-content: space-between;
align-items: flex-start;
align-self: stretch;
Expand Down
14 changes: 9 additions & 5 deletions src/components/order/OrderFilterBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useCallback, useRef, useState } from 'react';
import { useCallback, useEffect, useRef, useState } from 'react';
import classNames from 'classnames/bind';
import useDragScroll from '@/hooks/useDragScroll';
import scrollToTargetX from '@/utils/scrollToTargetX';

import styles from './OrderFilterBar.module.scss';
import scrollToTargetX from '@/utils/scrollToTargetX';

const cx = classNames.bind(styles);

Expand Down Expand Up @@ -35,17 +35,21 @@ export default function OrderFilterBar({ onFilterChange }: OrderFilterBarProps)

const targetRef = useRef<HTMLButtonElement | null>(null);

const [isClicked, setIsClicked] = useState(false);

const handleButtonClick = useCallback(
(item: OrderFilterButtonsProps) => {
setActiveButton(item);
onFilterChange(item.id);
if (targetRef.current) {
targetRef.current.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
setIsClicked(prev => !prev);
},
[onFilterChange]
);

useEffect(() => {
scrollToTargetX(dragScrollProps.ref, targetRef);
}, [dragScrollProps.ref, isClicked]);

return (
<div className={styles.container} {...dragScrollProps}>
{buttonIds.map(item => (
Expand Down
12 changes: 7 additions & 5 deletions src/components/payment/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ export default function Card({
<Image className={styles.productImg} width={56} height={56} src={imageUrl} alt="productImg" />
<div>
<div className={styles.productTitle}>{productTitle}</div>
<div className={styles.optionContainer}>
<div>{option}</div>
<div>(+{combinationPrice}원)</div>
<div>&nbsp;| {productNumber}</div>
</div>
{option !== '기본' && (
<div className={styles.optionContainer}>
<div>{option}</div>
<div>(+{combinationPrice}원)</div>
<div>&nbsp;| {productNumber}</div>
</div>
)}
<div className={styles.moneyContainerRight}>
<div className={styles.productCost}>{totalOriginalCost}</div>
<div className={styles.realPrice}>
Expand Down
1 change: 1 addition & 0 deletions src/components/payment/PaymentAgree.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
display: flex;
gap: 0.8rem;
margin: 0.8rem 0;
align-items: center;
}

.check {
Expand Down
29 changes: 24 additions & 5 deletions src/components/payment/PaymentAgree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,38 @@ export default function PaymentAgree({ onCheckboxChange }: PaymentAgreeProps) {
<div className={styles.checkboxTitle}>
<input
type="checkbox"
id="checkboxAll"
className={styles.checkbox}
checked={checkboxChecked}
onChange={handleCheckboxChange}
/>
<div className={styles.agreeTitle}>주문내용 확인 및 결제 동의</div>
<label htmlFor="checkboxAll" className={styles.agreeTitle}>
주문내용 확인 및 결제 동의
</label>
</div>
<div className={styles.contentCheckbox}>
<input type="checkbox" className={styles.check} checked={check1Checked} onChange={handleCheck1Change} />
<div className={styles.checkContent}>(필수) 개인정보 수집, 이용 동의</div>
<input
type="checkbox"
id="check1"
className={styles.check}
checked={check1Checked}
onChange={handleCheck1Change}
/>
<label htmlFor="check1" className={styles.checkContent}>
(필수) 개인정보 수집, 이용 동의
</label>
</div>
<div className={styles.contentCheckbox}>
<input type="checkbox" className={styles.check} checked={check2Checked} onChange={handleCheck2Change} />
<div className={styles.checkContent}>(필수) 개인정보 제3자 정보 제공 동의</div>
<input
type="checkbox"
id="check2"
className={styles.check}
checked={check2Checked}
onChange={handleCheck2Change}
/>
<label htmlFor="check2" className={styles.checkContent}>
(필수) 개인정보 제3자 정보 제공 동의
</label>
</div>
</div>
</>
Expand Down
4 changes: 4 additions & 0 deletions src/components/payment/TotalPay.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
margin-top: 2.4rem;
}

.priceBold {
@include font-body1;
}

.line {
width: 100%;
height: 0.15rem;
Expand Down
8 changes: 4 additions & 4 deletions src/components/payment/TotalPay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ export default function TotalPay({ totalPrice, totalOriginalPrice, title, produc
<div className={styles.individualCost}>
<div className={`${styles.pricePair} ${styles.gray}`}>
<div>원가</div>
<div>{formattedTotalOriginalPrice}</div>
<div className={styles.priceBold}>{formattedTotalOriginalPrice}</div>
</div>
<div className={styles.pricePair}>
<div>할인 금액</div>
<div>-{formattedDiscountAmount}</div>
<div className={styles.priceBold}>-{formattedDiscountAmount}</div>
</div>
<div className={`${styles.pricePair} ${styles.pink}`}>
<div>결제 금액</div>
<div>{formattedTotalPrice}</div>
<div className={styles.priceBold}>{formattedTotalPrice}</div>
</div>
<div className={styles.pricePair}>
<div>배송비</div>
<div>무료배송</div>
<div className={styles.priceBold}>무료배송</div>
</div>
</div>
<div className={styles.line}></div>
Expand Down
4 changes: 3 additions & 1 deletion src/components/review/WroteReviewCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export default function WroteReviewCard({ href, productInfo, onClick }: WroteRev
<div className={styles.wroteReviewCardArea} onClick={onClick}>
<div className={styles.wroteReviewCardLayout}>
<Card href={href} productInfo={productInfo} direction="row" size="miniImage" />
<NextButtonTemp href={href} />
<div className={styles.wroteReviewCardButton}>
<NextButtonTemp href={href} />
</div>
</div>
<hr className={styles.updownBorder} />
</div>
Expand Down
35 changes: 22 additions & 13 deletions src/pages/my/info/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useRouter } from 'next/router';
import { SubmitHandler, useForm } from 'react-hook-form';
import { Controller, SubmitHandler, useForm } from 'react-hook-form';
import { QueryClient, dehydrate, useMutation, useQueryClient } from '@tanstack/react-query';
import * as Yup from 'yup';
import { yupResolver } from '@hookform/resolvers/yup';
Expand Down Expand Up @@ -68,22 +68,22 @@ export default function Info() {

const methods = useForm<PhoneNumberValue>({
resolver: yupResolver(phoneNumberSchema),
mode: 'onBlur',
});
const {
formState: { errors },
} = methods;

const { register, handleSubmit } = methods;
const { register, handleSubmit, control } = methods;

const onSubmit: SubmitHandler<PhoneNumberValue> = data => {
const userEditData: UserEditProps = {
nickname: userData.nickname,
phoneNumber: data.phoneNumber,
phoneNumber: data.phoneNumber || userData.phoneNumber,
profileImage: userData.profileImage,
isSubscribedToPromotions: userData.isSubscribedToPromotions,
preferredPet: userData.preferredPet,
};
console.log(data);

const params: UserEditParams = {
id: userData.id,
Expand Down Expand Up @@ -133,15 +133,24 @@ export default function Info() {
background="background"
placeholder={userData.email}
/>
<Input
id="phoneNumber"
type="tel"
size="large"
label="연락처"
isError={errors.phoneNumber && true}
labelStyle={'label'}
placeholder="000-0000-0000 형식으로 입력해주세요"
defaultValue={userData.phoneNumber}
<Controller
control={control}
render={({ field }) => (
<Input
{...field}
id="phoneNumber"
type="tel"
size="large"
label="연락처"
onBlur={() => {
field.onBlur();
}}
isError={errors.phoneNumber && true}
labelStyle={'label'}
placeholder="000-0000-0000 형식으로 입력해주세요"
defaultValue={userData.phoneNumber}
/>
)}
{...register('phoneNumber')}
/>
{errors.phoneNumber && <span className={styles.errorText}>{errors.phoneNumber.message}</span>}
Expand Down
5 changes: 4 additions & 1 deletion src/pages/my/order/[purchaseId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function OrderDetail() {
detailedAddress: purchaseDetailData.data.detailedAddress,
zipCode: purchaseDetailData.data.zipCode,
message: purchaseDetailData.data.deliveryMessage,
deliveryName: purchaseDetailData.data.deliveryName,
};

function calculateTotalOriginalPrice() {
Expand Down Expand Up @@ -71,7 +72,7 @@ export default function OrderDetail() {
<div className={styles.deliveryArea}>
<h3>배송지</h3>
<div className={styles.deliveryCard}>
<h4>{deliveryInfo?.recipient}</h4>
<h4>{deliveryInfo?.deliveryName}</h4>
<span>
{deliveryInfo?.recipient} · {deliveryInfo?.recipientPhoneNumber}
<br />
Expand All @@ -98,6 +99,7 @@ export default function OrderDetail() {
status={order.status as number}
productInfo={{ ...order, stock: 3, option: order.combinationName }}
tagText={getTagText(order.status)}
href={`/my/order/${purchaseId}`}
/>
))}
</div>
Expand All @@ -109,6 +111,7 @@ export default function OrderDetail() {
totalPrice={totalPrice}
totalOriginalPrice={totalOriginalPrice}
productCount={orderCount}
inOrder
/>
</div>
{/* <div className={styles.paymentMethod}>
Expand Down
Loading

0 comments on commit 16a5914

Please sign in to comment.