Skip to content

Commit

Permalink
Chore : guide, login, product page type ์ •์˜
Browse files Browse the repository at this point in the history
guide page์— ํ•ด๋‹นํ•˜๋Š” ์ผ๋ถ€ ์ปดํฌ๋„ŒํŠธ๋Š” ํƒ€์ž… ๋ฏธ์ง€์ • ์ƒํƒœ, ์ถ”ํ›„ product/detail page๋ถ€ํ„ฐ ํƒ€์ž… ์ง€์ • ์˜ˆ์ •

Fixes : #22
  • Loading branch information
oyatplum committed Oct 29, 2023
1 parent 125362e commit cbb24e5
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 68 deletions.
25 changes: 8 additions & 17 deletions src/app/guide/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,19 @@ import small_logo from '@/assets/images/guide/small_logo.svg';
import ContentBodyInfo from '@/components/guide/ContentBodyInfo';
import { useRouter } from 'next/navigation';
import { getMainPageProducts } from '@/api/requests';
import guide_first from '@/assets/images/guide/guide_first.png';
import guide_second from '@/assets/images/guide/guide_second.png';
import guide_third from '@/assets/images/guide/guide_third.png';
import guide_fourth from '@/assets/images/guide/guide_fourth.png';
import character_2 from '@/assets/images/guide/character_2.png';
import character_4 from '@/assets/images/guide/character_4.png';
import character_5 from '@/assets/images/guide/character_5.png';
import presents from '@/assets/images/guide/presents.png';
import banner2 from '@/assets/images/banner/banner2.png';
import SubBackground from '@/assets/images/guide/SubBackground.png';
import 'react-alice-carousel/lib/alice-carousel.css';
import AliceCarousel from 'react-alice-carousel';
import { selectedNavPage } from '@/atom/states';
import { useRecoilState } from 'recoil';
import { useInView } from 'react-intersection-observer';
import { flexCenter, flexColumn } from '@/styles/theme';
type SlideInDivProps = {
inview: string;
};
import { Product, SlideInDivProps } from '@/interface/interface';

function page() {
const router = useRouter();
const [products, setProducts] = useState<any[]>([]);
const hi = 'S';
const [products, setProducts] = useState<Product[]>([]);

const responsive = {
512: {
Expand All @@ -53,16 +43,16 @@ function page() {
useEffect(() => {
const get = async () => {
const response = await getMainPageProducts();

const clothes = response.map((item: any) => {
console.log('response', response);
const clothes = response.map((item: Product) => {
return item;
});
setProducts(clothes);
};

get();
}, []);
const items = products.map((item) => {
const items = products.map((item: Product) => {
return (
<div
onClick={() => router.push(`/product/detail/${item.productId}`)}
Expand All @@ -79,7 +69,8 @@ function page() {
</div>
);
});
const [selectedPage, setSelectedPage] = useRecoilState(selectedNavPage);
const [selectedPage, setSelectedPage] =
useRecoilState<string>(selectedNavPage);
const goProduct = () => {
setSelectedPage('์ œํ’ˆ ๋ณด๊ธฐ');
router.push('/product');
Expand Down
5 changes: 3 additions & 2 deletions src/app/login/kakaoLogin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import { kakaoLogin } from '@/api/requests';
import { useCookies } from 'react-cookie';
import { userInfoState } from '@/atom/states';
import { useRecoilState } from 'recoil';
import { UserInfoType } from '@/interface/interface';

function page() {
const [cookies, setCookie, removeCookie] = useCookies();
const router = useRouter();
const [userInfo, setUserInfo] = useRecoilState(userInfoState);
const [userInfo, setUserInfo] = useRecoilState<UserInfoType>(userInfoState);

const checkKakaoLogin = async () => {
const urlParams = new URLSearchParams(window.location.search);
Expand All @@ -25,7 +26,7 @@ function page() {
setUserInfo({
id: response.id,
userEmail: response.email,
uesrNickname: response.nickname,
userNickname: response.nickname,
});
alert('ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค ' + response.nickname + '๋‹˜');
router.push('/');
Expand Down
2 changes: 1 addition & 1 deletion src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function page() {
};

const [imageSrc, setImageSrc] = useState<string>(check_off.src);
const [isClicked, setIsClicked] = useState(false);
const [isClicked, setIsClicked] = useState<boolean>(false);

const handleClick = () => {
if (isClicked) {
Expand Down
7 changes: 4 additions & 3 deletions src/app/product/detail/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import { useRouter } from 'next/navigation';
import { useCookies } from 'react-cookie';
import { userInfoState } from '@/atom/states';
import { useRecoilState } from 'recoil';
import { selectedNavPage, requestProducts, Product } from '@/atom/states';
import { selectedNavPage, requestProducts } from '@/atom/states';
import { Product, HomeFitProduct } from '@/interface/interface';

function page() {
const [products, setProducts] = useState({
Expand Down Expand Up @@ -104,8 +105,8 @@ function page() {
const purchase = () => {
const confirm = window.confirm('ํ•ด๋‹น ์ƒํ’ˆ์„ ๋ฐ”๋กœ ๊ตฌ๋งคํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?');
if (confirm) {
if (userInfo.uesrNickname) {
const newProduct: Product = {
if (userInfo.userNickname) {
const newProduct: HomeFitProduct = {
homeFittingId: 0,
product: {
brand: products.brand,
Expand Down
32 changes: 8 additions & 24 deletions src/app/product/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
'use client';
import React, { useEffect, useState } from 'react';
import ContentBodyInfo from '@/components/guide/ContentBodyInfo';
import cloth_1 from '@/assets/images/mypick/cloth_1.png';
import styled from 'styled-components';
import { useRouter } from 'next/navigation';
import logo_guide from '@/assets/images/guide/logo_guide.png';
import Image from 'next/image';
import Banner from '@/components/common/Banner';
import {
getCategory,
getItemLatest,
Expand All @@ -15,22 +11,8 @@ import {
getItemSeen,
} from '@/api/requests';
import { flexBetween, flexCenter, flexColumn } from '@/styles/theme';
import { Product, CategoryType } from '@/interface/interface';

interface Product {
brand: string;
detail: string;
discountRate: number;
mainImageFile: {
imagePath: string;
imageKey: string;
isMainImage: boolean;
};
name: string;
price: number;
productId: number;
productState: string;
size: string;
}
function page() {
const router = useRouter();
const [categoryData, setCategoryData] = useState<any>({});
Expand Down Expand Up @@ -74,9 +56,11 @@ function page() {
};
useEffect(() => {
const fetchCategory = async () => {
const response: any = await getCategory();
const categoryMap = response.reduce((map: any, item: any) => {
const response: CategoryType[] = await getCategory();
console.log('category', response);
const categoryMap = response.reduce((map: any, item: CategoryType) => {
if (item.parentId === null) {
//map type ์ •์˜ํ•ด์•ผ ํ•จ
return map;
}

Expand Down Expand Up @@ -210,7 +194,7 @@ function page() {
.slice(index, index + 4)
.map((product, innerIndex) => (
<Products key={`${product.productId}_${innerIndex}`}>
<Product
<SoleProduct
onClick={() =>
router.push(`/product/detail/${product.productId}`)
}
Expand All @@ -222,7 +206,7 @@ function page() {
name={product.name}
price={product.price}
/>
</Product>
</SoleProduct>
</Products>
))}
</ProductWrapper>
Expand Down Expand Up @@ -256,7 +240,7 @@ const S = styled.div`
margin-left: 108px;
`;

const Product = styled.div`
const SoleProduct = styled.div`
${flexColumn}
align-items: center;
`;
Expand Down
4 changes: 2 additions & 2 deletions src/app/wardrobe/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function page() {

const [selectedDate, setselectedDate] = useState('');
const datePickerFormat = 'YYYY-MM-DD';
const selectedDateChange = (date) => {
const selectedDateChange = (date: any) => {
const formattedDate = dayjs(date).format(datePickerFormat);
setValue('returnDate', formattedDate);
};
Expand Down Expand Up @@ -351,7 +351,7 @@ function page() {
},
}}
minDate={dayjs(formattedDate)}
onChange={(newValue) => {
onChange={(newValue: any) => {
selectedDateChange(newValue);
}}
/>
Expand Down
22 changes: 4 additions & 18 deletions src/atom/states.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use client';
import { atom } from 'recoil';
import { recoilPersist } from 'recoil-persist';
import { HomeFitProduct, UserInfoType } from '@/interface/interface';

const { persistAtom } = recoilPersist();

export const keyword = atom<string>({
Expand Down Expand Up @@ -30,7 +32,7 @@ export const selectedSubscribePlan = atom<string>({
default: 'BASIC',
});

export const userInfoState = atom({
export const userInfoState = atom<UserInfoType>({
key: 'userInfo',
default: {
id: 0,
Expand All @@ -40,23 +42,7 @@ export const userInfoState = atom({
effects_UNSTABLE: [persistAtom],
});

export interface Product {
homeFittingId: number;
product: {
brand: string;
detail: string;
size: string;
price: number;
name: string;
mainImageFile: {
imagePath: string;
};
productId: number;
};
isChecked: boolean;
}

export const requestProducts = atom<Product[]>({
export const requestProducts = atom<HomeFitProduct[]>({
key: 'products',
default: [],
effects_UNSTABLE: [persistAtom],
Expand Down
3 changes: 2 additions & 1 deletion src/components/common/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import styled, { css } from 'styled-components';
import { ButtonType } from '@/interface/interface';

function Button({ content, num }: { content: string; num: string }) {
function Button({ content, num }: ButtonType) {
return <Show $num={num}>{content}</Show>;
}

Expand Down
57 changes: 57 additions & 0 deletions src/interface/interface.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
export interface Product {
brand: string;
detail: string;
discountRate: null;
mainImageFile: {
imagePath: string;
imageKey: string;
isMainImage: boolean;
};
name: string;
price: number;
productId: number;
productState: string;
size: string;
}

export interface SlideInDivProps {
inview: string;
}

export interface ButtonType {
content: string;
num: string;
}

export interface HomeFitProduct {
homeFittingId: number;
product: {
brand: string;
detail: string;
size: string;
price: number;
name: string;
mainImageFile: {
imagePath: string;
};
productId: number;
};
isChecked: boolean;
}

export interface UserInfoType {
id: number;
userEmail: string;
userNickname: string;
}

export interface CategoryType {
id: number;
name: string;
parentId: number;
parentName: string;
}

export interface DetailProduct {
//detail/[...slug] ์ฐธ๊ณ 
}

0 comments on commit cbb24e5

Please sign in to comment.