-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from naya-h2/design/post-v2
✨ feat: post 자동저장 기능 추가
- Loading branch information
Showing
19 changed files
with
318 additions
and
82 deletions.
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
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,22 @@ | ||
import { useEffect, useState } from "react"; | ||
import { useFunnel } from "@/hooks/useFunnel"; | ||
import useGetWindowWidth from "@/hooks/useGetWindowWidth"; | ||
import { PostStepNameType } from "@/types/index"; | ||
import PostFunnel from "./PostFunnel"; | ||
import PostPc from "./PostPc"; | ||
|
||
const POST_STEPS: PostStepNameType[] = ["행사 대상", "행사 정보", "특전 정보", "상세 설명"]; | ||
|
||
const PostContent = () => { | ||
const { Funnel, Step, setStep, currentStep } = useFunnel<PostStepNameType>(POST_STEPS); | ||
const [isPc, setIsPc] = useState(false); | ||
const { isPc: isPcSize } = useGetWindowWidth(); | ||
|
||
useEffect(() => { | ||
setIsPc(isPcSize); | ||
}, [isPcSize]); | ||
|
||
return <>{isPc ? <PostPc /> : <PostFunnel Funnel={Funnel} Step={Step} setStep={setStep} currentStep={currentStep} />}</>; | ||
}; | ||
|
||
export default PostContent; |
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,49 @@ | ||
import { Dispatch, SetStateAction } from "react"; | ||
import { useFormContext } from "react-hook-form"; | ||
import { PostStepNameType } from "@/types/index"; | ||
import DetailInfo from "./DetailInfo"; | ||
import MainInfo from "./MainInfo"; | ||
import StarInfo from "./StarInfo"; | ||
import SubInfo from "./SubInfo"; | ||
|
||
const POST_STEPS: PostStepNameType[] = ["행사 대상", "행사 정보", "특전 정보", "상세 설명"]; | ||
|
||
interface Props { | ||
Funnel: any; | ||
Step: any; | ||
setStep: Dispatch<SetStateAction<PostStepNameType>>; | ||
currentStep: PostStepNameType; | ||
} | ||
|
||
const PostFunnel = ({ Funnel, Step, setStep, currentStep }: Props) => { | ||
const { getValues } = useFormContext(); | ||
|
||
const handlePrevClick = () => { | ||
currentStep === POST_STEPS[0] ? window.history.back() : setStep(POST_STEPS[POST_STEPS.indexOf(currentStep) - 1]); | ||
}; | ||
|
||
const handleNextClick = () => { | ||
const userInput = getValues(); | ||
localStorage.setItem("post", JSON.stringify(userInput)); | ||
return setStep(POST_STEPS[POST_STEPS.indexOf(currentStep) + 1]); | ||
}; | ||
|
||
return ( | ||
<Funnel> | ||
<Step name={POST_STEPS[0]}> | ||
<StarInfo onNextStep={handleNextClick} /> | ||
</Step> | ||
<Step name={POST_STEPS[1]}> | ||
<MainInfo onNextStep={handleNextClick} onPrevStep={handlePrevClick} /> | ||
</Step> | ||
<Step name={POST_STEPS[2]}> | ||
<SubInfo onNextStep={handleNextClick} onPrevStep={handlePrevClick} /> | ||
</Step> | ||
<Step name={POST_STEPS[3]}> | ||
<DetailInfo onPrevStep={handlePrevClick} /> | ||
</Step> | ||
</Funnel> | ||
); | ||
}; | ||
|
||
export default PostFunnel; |
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 classNames from "classnames"; | ||
import { ReactNode } from "react"; | ||
import { useFormContext } from "react-hook-form"; | ||
import Button from "@/components/button"; | ||
import { useStore } from "@/store/index"; | ||
import FunnelTitle from "./FunnelTitle"; | ||
import DetailInput from "./_inputs/DetailInput"; | ||
import MainInput from "./_inputs/MainInput"; | ||
import StarInput from "./_inputs/StarInput"; | ||
import SubInput from "./_inputs/SubInput"; | ||
|
||
const PostPc = () => { | ||
const { watch } = useFormContext(); | ||
const { isCheck } = useStore((state) => ({ isCheck: state.isWarningCheck })); | ||
const { address, artists, groupId, eventType, placeName, startDate, endDate } = watch(); | ||
const isDisabled = !(artists.length > 0 && address && artists && groupId && eventType && placeName && startDate && endDate) || !isCheck; | ||
|
||
return ( | ||
<div className="flex max-w-[68.8rem] flex-col gap-32 pb-120"> | ||
<p className="text-14 font-600 text-gray-500">행사 등록하기</p> | ||
<div className="flex flex-col gap-56"> | ||
<TitleLayout> | ||
<FunnelTitle step="행사 대상" isRequired /> | ||
<StarInput /> | ||
</TitleLayout> | ||
<TitleLayout> | ||
<FunnelTitle step="행사 정보" isRequired /> | ||
<MainInput /> | ||
</TitleLayout> | ||
<TitleLayout> | ||
<FunnelTitle step="특전 정보" /> | ||
<SubInput /> | ||
</TitleLayout> | ||
<TitleLayout isLast> | ||
<FunnelTitle step="상세 설명" /> | ||
<DetailInput /> | ||
</TitleLayout> | ||
<Button size="xl" isSubmit isDisabled={isDisabled}> | ||
작성완료 | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PostPc; | ||
|
||
interface Props { | ||
children: ReactNode; | ||
isLast?: boolean; | ||
} | ||
|
||
const TitleLayout = ({ children, isLast = false }: Props) => { | ||
return <section className={classNames("flex flex-col gap-24 border-b border-gray-50 pb-32", { "!border-none !pb-0": isLast })}>{children}</section>; | ||
}; |
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
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.