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

deploy: v 1.0.0 #108

Open
wants to merge 83 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
b64b943
feat: api 폴더 추가
yooveloper Jun 24, 2023
fde755f
Merge pull request #2 from pick-time/feature/create-dir
yooveloper Jun 24, 2023
8991d4c
style: 전역 스타일 설정
blcklamb Jun 24, 2023
4c924e3
Icon, List 공통 컴포넌트 작업 (#8)
blcklamb Jun 24, 2023
17d42a7
feat : 공통컴포넌트_text_header (#11)
EllaSEON Jun 24, 2023
b7f24d1
Feature/init recoil,react query (#13)
yooveloper Jun 24, 2023
4e6f21f
build: eslint, prettier 확장자 json으로 변경
yooveloper Jun 25, 2023
86a18b5
feat: 선물 추가 기능 구현 (#15)
zwonkim Jun 25, 2023
a7e2eb0
Feature/공통 컴포넌트 Button, Input, Title 작업 (#14)
solar3070 Jun 25, 2023
6c6a817
style: 축하카드 만들기 컴포넌트 생성 (#18)
EllaSEON Jun 25, 2023
f7c159e
Feature/카카오톡 공유하기 기능 구현 (#23)
solar3070 Jun 25, 2023
c971ac7
feat: 인트로 페이지 구현 중 (#25)
yooveloper Jun 25, 2023
5cda1b1
Feature/Button, Input 컴포넌트 스타일 수정 (#27)
solar3070 Jun 25, 2023
6ebd6ac
리스트 페이지 UI completed (#28) closes #9
blcklamb Jun 25, 2023
0456155
fix: mockData import Fix
blcklamb Jun 25, 2023
bbff882
Feature/나만의 카드 만들기 (#30)
EllaSEON Jun 25, 2023
0d7bca9
Feature/링크 복사하기 기능 구현 (#31)
solar3070 Jun 25, 2023
8d6cf55
Feature/url 유효성 검사, util 파일 분리 (#33)
zwonkim Jun 25, 2023
e15b854
Feature/intro provider (#34)
yooveloper Jun 25, 2023
6024408
주는 사람 선물 확인 페이지 api (#35)
blcklamb Jun 25, 2023
45c90b2
fix: 타입 수정 (#36)
zwonkim Jun 25, 2023
202f6ca
Feature/주는 사람 완성 페이지 퍼블리싱 (#37)
solar3070 Jun 25, 2023
8772473
style : toggleBtn 구현 (#42)
EllaSEON Jun 25, 2023
da9a85b
SVG 추가, props case 수정 (#43)
blcklamb Jun 25, 2023
84609e9
Feature/intro consumer (#39)
yooveloper Jun 25, 2023
d05f530
Feature/받는 사람 선물 고른 결과 페이지 퍼블리싱 (#44)
solar3070 Jun 25, 2023
713657e
Feature/나만의 카드만들기 기능 구현 (#46)
EllaSEON Jun 25, 2023
c894187
Feature/받는 사람 선물 고른 페이지 API (#47)
solar3070 Jun 25, 2023
cafad76
Feature/선택한 선물 api 코드 수정 (#48)
solar3070 Jun 25, 2023
549f0ed
Feature/상품 정보 수정 모달 (#50)
zwonkim Jun 26, 2023
6941bf6
`GET /target/{targetId}`, `POST /target/{targetId}/` (#49)
blcklamb Jun 26, 2023
37cde02
build: 웹팩 프록시 설정 추가 (#51)
yooveloper Jun 26, 2023
82e0a7e
feat: 프록시 설정 및 Intro.tsx에 샘플 추가
yooveloper Jun 26, 2023
c4b095a
feat: 선물 고른 페이지 최종 API 연결 (#52)
solar3070 Jun 26, 2023
3fc4f30
feat: (#53)
yooveloper Jun 26, 2023
2120cef
feat:
yooveloper Jun 26, 2023
81044c3
Feature/consumer list api (#54)
blcklamb Jun 26, 2023
70998ee
Feature/ProviderCard에 이미지 보이기 (#55)
EllaSEON Jun 26, 2023
224f710
feat: exproess 서버 경로 배포 경로로 변경 및 로직 수정 (#56)
yooveloper Jun 26, 2023
0101759
익스프레스 포트 엔드포인트 변경
yooveloper Jun 26, 2023
bcff365
5151포트 제거
yooveloper Jun 26, 2023
69ef7a3
Feature/api error check (#57)
blcklamb Jun 26, 2023
ad659dd
액시오스 위드크레덴셜 추가
yooveloper Jun 26, 2023
e0cc80a
Feature/File 객체로 생성 (#58)
EllaSEON Jun 26, 2023
18b5c7a
포트 5151 수정
yooveloper Jun 26, 2023
35cc670
Feature/받는 사람 인트로 API 작업 (#60)
solar3070 Jun 26, 2023
e0a462a
Feature/api error check (#61)
blcklamb Jun 26, 2023
dbc81c6
Feature/카드 만들기 디자인 수정 (#62)
EllaSEON Jun 26, 2023
1da1491
Feature/모달창 스타일링 수정, url 에러메시지 추가 (#64)
zwonkim Jun 26, 2023
5d658a7
fix: List 관련 mock data 추가 (#66)
blcklamb Jun 26, 2023
fbb3b70
feat: 로딩 스피너 사용
solar3070 Jun 26, 2023
2f1f4a3
Feature/link detail (#65)
solar3070 Jun 26, 2023
aa996e6
Feature/List 스타일링 수정 (#67)
zwonkim Jun 26, 2023
58b2cc0
fix: 카카오톡 공유하기 이미지 경로 수정 (#68)
solar3070 Jun 26, 2023
0712133
fix: 주는 사람 없을 시 디폴트 이름 익명으로 지정
yooveloper Jun 26, 2023
fbf583a
style: 인트로 이미지 가운데 정렬 (#70)
solar3070 Jun 26, 2023
f7a3c37
Feature/style list (#69)
blcklamb Jun 26, 2023
c9f9ac2
style: 메인 이미지 svg로 변경 (#71)
solar3070 Jun 26, 2023
91e8510
Feature/style change (#73)
solar3070 Jun 26, 2023
dbac9d7
docs: 최종 리드미 수정
yooveloper Jun 26, 2023
0db47e5
docs: README 작성
yooveloper Jun 26, 2023
c62931b
Style/modal, giftList 컴포넌트 스타일 수정 (#79)
zwonkim Jul 13, 2023
86f793b
Feature/Divider 공통 컴포넌트 (#80)
solar3070 Jul 14, 2023
8dcf72c
feat: 변경된 API path 반영 (#81)
solar3070 Jul 16, 2023
63eab94
Feature/coupon UI (#82)
blcklamb Jul 17, 2023
5d9fb9c
fix: proxy 설정 (#83)
blcklamb Jul 21, 2023
c879b57
Feature/addGift API 연결 (#86)
zwonkim Jul 21, 2023
3d9c5ba
불필요한 파일 삭제 (#88)
zwonkim Jul 21, 2023
3bb87bb
Refactor/list component (#89)
blcklamb Jul 21, 2023
bf234af
fix: api endpoint 수정 (#91)
blcklamb Jul 21, 2023
ac86670
Feature/카카오 공유 버튼 추가 (#92)
solar3070 Jul 21, 2023
031fc72
선물 목록 불러오기, 선물 삭제 api 연결 (#93)
zwonkim Jul 21, 2023
3b93dee
fix: withCredentials 없앰
yooveloper Jul 23, 2023
c3e8a23
Feature/editGiftItem 개별 선물 수정 api (#96)
zwonkim Jul 30, 2023
e4a6e46
Feature/consumer radio button (#97)
blcklamb Aug 6, 2023
83a5bc9
Feature/주는 사람 Intro API 연결 (#100)
solar3070 Aug 17, 2023
131251f
받는 사람 페이지 미완성 컴포넌트 보강, 랜덤 선택 페이지 추가 (#103)
zwonkim Oct 17, 2023
3dddd7f
resultType 분리, provider 타입 지정 (#104)
zwonkim Oct 17, 2023
a981382
랜덤 선물 페이지 예외처리 (#105)
zwonkim Oct 24, 2023
576e2ac
Fix/provider 씬의 누락된 기능 추가 (#106)
blcklamb Oct 24, 2023
540db56
Fix/copy link (#107)
blcklamb Oct 24, 2023
8a3180c
style: header zindex (#109)
blcklamb Oct 24, 2023
d2497ac
Fix/style & docs (#110)
blcklamb Oct 26, 2023
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
Prev Previous commit
Next Next commit
Fix/provider 씬의 누락된 기능 추가 (#106)
* chore: mock data 삭제

* style: 쿠폰 만들기 버튼 중앙정렬

* style: dimmed 레이아웃
- 제대로 header가 가려지지 않고 상단에 빈틈이 생겨서 수정
- zIndex, height

* feat: headerWithButton

* fix: coupon create and post
- put base64 URL into File object
- remove list props in List.tsx

* feat: api <postCoupon>, <updateTarget>
- updateTarget api에서 request 형태를 바꿀 수 없어서 query에 coupon, gift list를 줄지어서 결합한 형태의 로직 추가
- axios로 되어 있던 부분 mutation으로 분리 완료

* fix: style attribute naming
- cabab to camel

* feat: 완료 플로우 연결 및 확인 페이지 완성
- provider가 데이터 작성 후 완료하는 플로우 연결
- 데이터 확인하는 페이지에서 쿠폰 render 추가

* fix: complie error via eslint
blcklamb authored Oct 24, 2023
commit 576e2ac67e0f95b3573770af4b2064385d2b73f6
59 changes: 59 additions & 0 deletions src/api/provider.ts
Original file line number Diff line number Diff line change
@@ -21,6 +21,44 @@ export const postTarget = async ({
return response.data;
};

// 타겟 업데이트 = 카드, <선물, 쿠폰> 목록 확정
interface UpdateTargetRequest {
targetId: number;
cardMessage: string; // 카드 텍스트
file: File | null; // 카드 이미지 파일
giftList?: number[];
couponList?: number[];
}

export const updateTarget = async (query: UpdateTargetRequest) => {
const { targetId, giftList, couponList, file } = query;
const formData = new FormData();
if (file) formData.append("file", file);

const giftListQuery = giftList?.reduce((str, giftId, idx) => {
if (idx === 0) return `giftList=${giftId}`;
return `${str}&giftList=${giftId}`;
}, "");

const couponListQuery = couponList?.reduce((str, couponId, idx) => {
if (idx === 0) return `couponList=${couponId}`;
return `${str}&couponList=${couponId}`;
}, "");

// eslint-disable-next-line no-nested-ternary
const combineQuery = couponListQuery
? giftListQuery
? `${giftListQuery}&${couponListQuery}`
: `${couponListQuery}`
: `${giftListQuery}`;

const response = await axios.post(
`${process.env.REACT_APP_BASE_URL}/target/${targetId}?${combineQuery}`,
formData,
);
return response.data;
};

// 선물 조회
export const getGiftList = async (targetId: number): Promise<Result> => {
const response = await axios.get<Result>(
@@ -62,3 +100,24 @@ export const putGiftItem = async (formData: FormData): Promise<Result> => {
);
return response.data;
};

interface PostCouponRequest {
couponForm: FormData;
targetId: number;
}

export const postCouponItem = async ({
couponForm,
targetId,
}: PostCouponRequest): Promise<Result> => {
const response = await axios.post<Result>(
`${process.env.REACT_APP_BASE_URL}/coupon?targetId=${targetId}`,
couponForm,
{
headers: {
"Content-Type": "multipart/form-data",
},
},
);
return response.data;
};
68 changes: 68 additions & 0 deletions src/components/common/HeaderWithButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import styled from "styled-components";
import Icon from "./Icon";
import COLOR from "style/color";

interface HeaderWithButtonProps {
onClickBackBtn: () => void;
onClickCompleteBtn?: () => void;
completeBtnDisabled?: boolean;
}

const HeaderWithButton = ({
onClickBackBtn,
onClickCompleteBtn,
completeBtnDisabled,
}: HeaderWithButtonProps) => {
return (
<LogoWrapper>
<IconButton onClick={onClickBackBtn}>
<Icon name="left-arrow" width={24} height={24} />
</IconButton>
<Icon name="logo-header" width={113} height={26} />
{onClickCompleteBtn && (
<CompleteButton
onClick={onClickCompleteBtn}
disabled={completeBtnDisabled}
>
완료
</CompleteButton>
)}
</LogoWrapper>
);
};

export default HeaderWithButton;

const LogoWrapper = styled.header`
display: flex;
width: 68rem;
align-items: center;
justify-content: space-around;
padding: 1rem 12rem;
background: ${COLOR.WHITE};
z-index: 1;
`;

const IconButton = styled.button`
all: unset;
width: 5.4rem;
`;

const CompleteButton = styled.button`
all: unset;

padding: 0.7rem 1.4rem 0.8rem 1.4rem;
display: inline-flex;
align-items: flex-start;

border-radius: 0.8rem;
background-color: ${COLOR.PURPLE};

color: ${COLOR.WHITE};
font-size: 1.4rem;
font-weight: bold;

:disabled {
background-color: #e9d7fe;
}
`;
1 change: 1 addition & 0 deletions src/components/common/Icon.tsx
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ export type IconName =
| "empty-heart"
| "error-gift"
| "gift-edit"
| "left-arrow"
| "logo-header"
| "logo-large"
| "logo-intro-provider"
8 changes: 8 additions & 0 deletions src/components/common/IconLoader.tsx
Original file line number Diff line number Diff line change
@@ -625,6 +625,14 @@ const IconLoader = () => (
d="M18.5 9.885s.5 1.726.5 4.615c0 2.889-.389 5.417-.778 5.778-.389.361-3.11.722-6.222.722-3.111 0-5.833-.361-6.222-.722C5.388 19.917 5 17.389 5 14.5s.5-4.615.5-4.615m13 0c.307-.017.518-.034.611-.052.445-.083.889-.666.889-1.333 0-.667-.444-1.25-.889-1.333C18.667 7.083 15.556 7 12 7c-3.556 0-6.667.083-7.111.167C4.444 7.25 4 7.833 4 8.5c0 .667.444 1.25.889 1.333.093.018.304.035.611.052m13 0c-1.158.063-3.69.115-6.5.115s-5.342-.052-6.5-.115m6.366-3.035c.549-2.049 3.696-5.598 5.196-3 1.5 2.598-3.147 3.55-5.196 3Zm.196 0c-.549-2.049-3.696-5.598-5.196-3-1.5 2.598 3.147 3.55 5.196 3Z"
/>
</symbol>
<symbol id="left-arrow" width="24" height="24" fill="none">
<path
fill="#000"
fillRule="evenodd"
d="M16.707 3.293a1 1 0 0 1 0 1.414L9.414 12l7.293 7.293a1 1 0 0 1-1.414 1.414l-8-8a1 1 0 0 1 0-1.414l8-8a1 1 0 0 1 1.414 0Z"
clipRule="evenodd"
/>
</symbol>
</defs>
</svg>
);
10 changes: 4 additions & 6 deletions src/components/common/List.tsx
Original file line number Diff line number Diff line change
@@ -4,11 +4,10 @@ import COLOR from "style/color";
import { GiftList } from "types/giftList.type";
import { CouponList as TCouponList } from "types/couponList.type";
import CouponList from "./CouponList";
import mockCouponList from "data/couponData";
import giftData from "data/giftData";
// import mockCouponList from "data/couponData";
// import giftData from "data/giftData";

interface ListProps {
listData: GiftList[];
giftList?: GiftList[];
couponList?: TCouponList[];
type?: "default" | "editable" | "likable";
@@ -20,9 +19,8 @@ interface ListProps {

function List({
// eslint-disable-next-line @typescript-eslint/no-unused-vars
listData,
giftList = giftData,
couponList = mockCouponList,
giftList,
couponList,
type = "likable",
selectedGiftId,
onClickClose,
6 changes: 3 additions & 3 deletions src/components/common/ModalFrameCoupon.tsx
Original file line number Diff line number Diff line change
@@ -26,16 +26,16 @@ export default ModalFrameCoupon;

const ModalDim = styled.div`
position: absolute;
z-index: 1;
top: 0;
z-index: 2;
top: -2rem;
left: 0;
background-color: #00000066;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
height: 110%;
`;
const Wrapper = styled.div`
position: absolute;
2 changes: 1 addition & 1 deletion src/components/provider/ProviderCard.tsx
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ const CardWrapper = styled.div`
flex-direction: column;
justify-content: center;
align-items: center;
margin: 4rem 2.6rem 4rem 2.6rem;
margin: 4rem 0rem;
border: 1px dashed #d3c9e7;
border-radius: 10px;
`;
9 changes: 1 addition & 8 deletions src/components/provider/ProviderGiftList.tsx
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ import { GiftList } from "types/giftList.type";
import EditGiftModal from "./EditGiftModal";
// import giftList from "data/giftData";
import { useParams } from "react-router-dom";
import mockCouponList from "data/couponData";
import useGift from "hooks/queries/useGift";

export default function ProviderGiftList() {
@@ -15,8 +14,6 @@ export default function ProviderGiftList() {
getGift: { isLoading, data },
} = useGift(Number(targetId));

// 시현용
const [listData, setListData] = useState<GiftList[]>([]);
const [editedGiftId, setEditedGiftId] = useState<number>();

const handleDelete = (giftId: number) => {
@@ -31,19 +28,15 @@ export default function ProviderGiftList() {
<>
{data && (
<List
// TODO: listData 삭제
listData={listData}
giftList={data.giftList}
// TODO: 실데이터로 교체
couponList={mockCouponList}
couponList={data.couponList}
type="editable"
onClickClose={handleDelete}
onClickEdit={handleEdit}
/>
)}
{data && editedGiftId && (
<EditGiftModal
// listData={response}
giftList={data.giftList}
editedGiftId={editedGiftId}
setEditedGiftId={setEditedGiftId}
41 changes: 19 additions & 22 deletions src/components/provider/coupon/CreateCouponModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/no-array-index-key */
import ModalFrameCoupon from "components/common/ModalFrameCoupon";
import Text from "components/common/Text";
import styled from "styled-components";
@@ -14,8 +13,8 @@ import { useRecoilState, useResetRecoilState, useSetRecoilState } from "recoil";
import { useCallback, useRef, useState } from "react";
import { toPng } from "html-to-image";
import Loading from "components/common/Loading";
import axios from "axios";
import { useParams } from "react-router-dom";
import useCoupon from "hooks/queries/useCoupon";

const BASIC_IMAGE_GRADIENT = [
"linear-gradient(133deg, #52ccff 0%, #5448e8 100%)",
@@ -48,28 +47,24 @@ function CreateCouponModal({ setCloseCouponModal }: CreateCouponModalProps) {
const onChangeCouponMessage = (e: React.ChangeEvent<HTMLInputElement>) => {
setCouponMessage(e.target.value);
};
const { addCoupon } = useCoupon(Number(targetId));

// TODO: mutate로 custom hook 분리 예정
const onClickSubmit = async (png: string) => {
const formData = new FormData();
formData.append("file", png);
try {
if (targetId) {
const params = new URLSearchParams({ targetId }).toString();
await axios.post(
`${process.env.REACT_APP_BASE_URL}/coupon?${params}`,
{ formData },
{
headers: {
"Content-Type": "multipart/form-data",
charset: "utf-8",
},
},
);
}
} catch (err) {
console.error(err);
}
const randomId = (): string => {
const uint32 = window.crypto.getRandomValues(new Uint32Array(1))[0];
return uint32.toString(16);
};
await fetch(png)
.then(res => res.blob())
.then(blob => {
const file = new File([blob], `custom-coupon-${randomId()}.png`, {
type: "image/png",
});
formData.append("file", file);
});

addCoupon.mutate({ couponForm: formData, targetId: Number(targetId) });
};

const onClickCouponToPNG = useCallback(async () => {
@@ -91,10 +86,12 @@ function CreateCouponModal({ setCloseCouponModal }: CreateCouponModalProps) {

const onClickImageUpload = (event: React.ChangeEvent<HTMLInputElement>) => {
const file = event.target.files?.[0];

if (file) {
const formData = new FormData();
formData.append("file", file);
const imageUrl = URL.createObjectURL(file);

setBackImageCustomURL(imageUrl); // 이미지 화면에 렌더링 하기
setInputInfo({ ...inputInfo, file }); // 전역 상태에 저장
}
@@ -127,7 +124,7 @@ function CreateCouponModal({ setCloseCouponModal }: CreateCouponModalProps) {
{BASIC_IMAGE_GRADIENT.map((basic, idx) => {
return (
<BasicImage
key={idx}
key={BASIC_IMAGE_GRADIENT[idx]}
background={basic}
onClick={() => setBackImageURL(basic)}
/>
10 changes: 8 additions & 2 deletions src/components/provider/coupon/OpenModalButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState } from "react";
import CustomButton from "components/provider/coupon/CustomButton";
import CreateCouponModal from "components/provider/coupon/CreateCouponModal";
import styled from "styled-components";

function OpenModalButton() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -13,13 +14,18 @@ function OpenModalButton() {
setOpenCouponModal(false);
};
return (
<>
<Wrapper>
<CustomButton onClick={onClickOpenModal} />
{openCouponModal && (
<CreateCouponModal setCloseCouponModal={onClickCloseModal} />
)}
</>
</Wrapper>
);
}

export default OpenModalButton;

const Wrapper = styled.div`
display: flex;
justify-content: center;
`;
49 changes: 0 additions & 49 deletions src/data/consumerResultData.ts

This file was deleted.

18 changes: 0 additions & 18 deletions src/data/couponData.ts

This file was deleted.

36 changes: 0 additions & 36 deletions src/data/giftData.ts

This file was deleted.

12 changes: 12 additions & 0 deletions src/hooks/queries/useCoupon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { postCouponItem } from "api/provider";
import { useMutation, useQueryClient } from "react-query";

const useCoupon = (targetId: number) => {
const queryClient = useQueryClient();
const addCoupon = useMutation(postCouponItem, {
onSuccess: () => queryClient.invalidateQueries(["gift", targetId]),
});
return { addCoupon };
};

export default useCoupon;
6 changes: 5 additions & 1 deletion src/hooks/queries/usePostTarget.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

고생하셨습니다 🥺

Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { postTarget } from "api/provider";
import { postTarget, updateTarget } from "api/provider";
import { useMutation } from "react-query";

export const usePostTarget = () => {
return useMutation(postTarget);
};

export const useUpdateTarget = () => {
return useMutation(updateTarget);
};

export default usePostTarget;
8 changes: 3 additions & 5 deletions src/pages/Confirm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-nested-ternary */
/* eslint-disable @typescript-eslint/no-unused-vars */

import { useGetResult } from "hooks/queries/useResult";
import { Result } from "types/result.type";
import Button from "components/common/Button";
import Header from "components/common/Header";
import ListComponent from "components/common/List";
@@ -11,8 +10,6 @@ import { useParams, useNavigate } from "react-router-dom";
import COLOR from "style/color";
import styled from "styled-components";

type User = Pick<Result, "providerName" | "consumerName">;

function Confirm() {
const { targetId } = useParams();
const navigate = useNavigate();
@@ -41,7 +38,8 @@ function Confirm() {
고르신 선물 확인해 주세요!
</Title>
</TitleWrapper>
<ListComponent listData={data?.giftList} type="default" />
<ListComponent giftList={data?.giftList} type="default" />
<ListComponent couponList={data?.couponList} type="default" />
</>
)}
<ButtonWrapper>
45 changes: 43 additions & 2 deletions src/pages/Gift.tsx
Original file line number Diff line number Diff line change
@@ -2,13 +2,54 @@ import styled from "styled-components";
import ProviderGiftForm from "components/provider/ProviderGiftForm";
import ProviderGiftList from "components/provider/ProviderGiftList";
import ProviderCard from "components/provider/ProviderCard";
import Header from "components/common/Header";
import OpenModalButton from "components/provider/coupon/OpenModalButton";
import HeaderWithButton from "components/common/HeaderWithButton";
import { useNavigate, useParams } from "react-router-dom";
import { useUpdateTarget } from "hooks/queries/usePostTarget";
import { useRecoilValue } from "recoil";
import { FileInputState, cardInputState } from "stores/cardAtom";
import useGift from "hooks/queries/useGift";

export default function Gift() {
const { targetId } = useParams();
const navigate = useNavigate();
const cardInput = useRecoilValue(cardInputState);
const cardFile = useRecoilValue(FileInputState);

const { mutate } = useUpdateTarget();

const { getGift } = useGift(Number(targetId));

const onSubmitSelectResult = async () => {
try {
if (targetId) {
const postData = {
targetId: +targetId,
cardMessage: cardInput.cardText,
file: cardFile,
giftList: getGift.data?.giftList.reduce((a: number[], ele) => {
a.push(ele.giftId);
return a;
}, []),
couponList: getGift.data?.couponList.reduce((a: number[], ele) => {
a.push(ele.couponId);
return a;
}, []),
};
mutate(postData);
navigate(`/result/${targetId}`);
}
} catch (err) {
console.error(err);
alert("죄송합니다. 잠시 후 다시 시도해주세요.");
}
};
return (
<>
<Header />
<HeaderWithButton
onClickBackBtn={() => navigate("/")}
onClickCompleteBtn={() => onSubmitSelectResult()}
/>
<BodyWrapper>
<ProviderCard />
<ProviderGiftForm />
2 changes: 1 addition & 1 deletion src/pages/GiftForConsumer.tsx
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ function GiftForConsumer() {

setPickedFinalId(randomId);
setIsRandom(false);

navigate(`/random/${targetId}/gift`, { state: resultIdArray });
};