Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions web/src/app/(main)/report/page.tsx

This file was deleted.

56 changes: 56 additions & 0 deletions web/src/app/(stack)/report/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"use client";

import { useReportForm } from "@/features/report/lib/hook/useReportForm";
import { FailureModal } from "@/features/report/ui/FailureModal";
import { ReportForm } from "@/features/report/ui/ReportForm";
import { SuccessModal } from "@/features/report/ui/SuccessModal";
import { CTA, TransitionLayout } from "@/shared/ui";

export default function ReportPage() {
const {
location,
setLocation,
name,
setName,
recommendedMenu,
setRecommendedMenu,
reason,
setReason,
seatTypes,
setSeatTypes,
isSuccessModalOpen,
setIsSuccessModalOpen,
isFailureModalOpen,
setIsFailureModalOpen,
handleSubmit,
} = useReportForm();

return (
<TransitionLayout>
<ReportForm
location={location}
setLocation={setLocation}
name={name}
setName={setName}
recommendedMenu={recommendedMenu}
setRecommendedMenu={setRecommendedMenu}
reason={reason}
setReason={setReason}
seatTypes={seatTypes}
setSeatTypes={setSeatTypes}
/>
<div className="fixed bottom-0 left-0 w-full bg-white">
<CTA
primaryLabel="μ œλ³΄ν•˜κΈ°"
onPrimary={handleSubmit}
primaryDisabled={
!location || !name || !recommendedMenu || reason.length < 5 || seatTypes.length === 0
}
/>
</div>

<SuccessModal isOpen={isSuccessModalOpen} onClose={() => setIsSuccessModalOpen(false)} />
<FailureModal isOpen={isFailureModalOpen} onClose={() => setIsFailureModalOpen(false)} />
</TransitionLayout>
);
}
8 changes: 8 additions & 0 deletions web/src/features/report/api/reportApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { axiosInstance } from "@/shared/config";
import type { ReportRequestBody } from "./types";

export const postReport = async (body: ReportRequestBody) => {
const response = await axiosInstance.post("/api/v1/report", body);

return response;
};
12 changes: 12 additions & 0 deletions web/src/features/report/api/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { SeatTypes } from "@/entities/storeList/api";

export interface ReportRequestBody {
location: string;
name: string;
seatType: SeatTypes[];
paymentMethods: string[];
menuCategories: string[];
recommendedMenu: string;
reason: string;
memberId: number;
}
16 changes: 16 additions & 0 deletions web/src/features/report/api/useReportMutation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useMutation } from "@tanstack/react-query";
import type { ApiResponse } from "@/shared/model";
import { postReport } from "./reportApi";

interface UseReportMutationOptions {
onSuccess?: (data: ApiResponse<unknown>) => void;
onError?: (error: Error) => void;
}

export const useReportMutation = ({ onSuccess, onError }: UseReportMutationOptions = {}) => {
return useMutation({
mutationFn: postReport,
onSuccess,
onError,
});
};
61 changes: 61 additions & 0 deletions web/src/features/report/lib/hook/useReportForm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { useState } from "react";
import type { SeatTypes } from "@/entities/storeList/api";
import { useUserState } from "@/entities/user";
import { useReportMutation } from "@/features/report/api/useReportMutation";

export const useReportForm = () => {
const { userState } = useUserState();

const [location, setLocation] = useState("");
const [name, setName] = useState("");
const [recommendedMenu, setRecommendedMenu] = useState("");
const [reason, setReason] = useState("");
const [seatTypes, setSeatTypes] = useState<SeatTypes[]>([]);
const [isSuccessModalOpen, setIsSuccessModalOpen] = useState(false);
const [isFailureModalOpen, setIsFailureModalOpen] = useState(false);

const { mutate: reportMutate } = useReportMutation({
onSuccess: () => {
setIsSuccessModalOpen(true);
},
onError: () => {
setIsFailureModalOpen(true);
},
});

const handleSubmit = () => {
if (!userState.memberId) {
alert("둜그인이 ν•„μš”ν•©λ‹ˆλ‹€.");
return;
}

reportMutate({
location,
name,
seatType: seatTypes,
paymentMethods: [],
menuCategories: [],
recommendedMenu,
reason,
memberId: userState.memberId,
});
};

return {
location,
setLocation,
name,
setName,
recommendedMenu,
setRecommendedMenu,
reason,
setReason,
seatTypes,
setSeatTypes,
isSuccessModalOpen,
setIsSuccessModalOpen,
isFailureModalOpen,
setIsFailureModalOpen,
handleSubmit,
};
};
36 changes: 36 additions & 0 deletions web/src/features/report/ui/FailureModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Image from "next/image";
import Character from "@/shared/lib/assets/png/character/basic.png";
import { Icon, Modal } from "@/shared/ui";

interface FailureModalProps {
isOpen: boolean;
onClose: () => void;
}

export function FailureModal({ isOpen, onClose }: FailureModalProps) {
return (
<Modal isOpen={isOpen} onOpenChange={onClose} title={""} description={""}>
<div className="flex min-w-[260px] flex-col items-center justify-center gap-6 rounded-lg bg-white p-4">
<button type="button" className="mb-[-24px] flex h-5 w-full justify-end" onClick={onClose}>
<Icon name="close" size={24} className="cursor-pointer text-gray400" />
</button>
<Image src={Character} alt="character" width={120} height={120} />
<div className="flex flex-col gap-2">
<span className="whitespace-pre-line text-center text-gray900 text-subtitle1">
식당 μ œλ³΄μ— μ‹€νŒ¨ν–ˆμ–΄μš”
</span>
<span className="whitespace-pre-line text-center text-gray700 text-body2-regular">
λ‹€μ‹œ μ‹œλ„ν•΄ μ£Όμ„Έμš”.
</span>
</div>
<button
type="button"
onClick={onClose}
className="flex h-[51px] w-full items-center justify-center rounded-[8px] bg-primary400 py-[14px]"
>
<span className="text-body1-semibold text-gray0">확인</span>
</button>
</div>
</Modal>
);
}
92 changes: 92 additions & 0 deletions web/src/features/report/ui/ReportForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
"use client";

import type { Dispatch, SetStateAction } from "react";
import type { SeatTypes } from "@/entities/storeList/api";
import { FilterSection, Input, InputReview } from "@/shared/ui";

const SEAT_TYPE_MAP: Record<SeatTypes, string> = {
CUBICLE: "칸막이",
BAR_TABLE: "λ°” μ’Œμ„",
FOR_ONE: "1인석",
FOR_TWO: "2인석",
FOR_FOUR: "4인석",
};

interface ReportFormProps {
location: string;
setLocation: Dispatch<SetStateAction<string>>;
name: string;
setName: Dispatch<SetStateAction<string>>;
recommendedMenu: string;
setRecommendedMenu: Dispatch<SetStateAction<string>>;
reason: string;
setReason: Dispatch<SetStateAction<string>>;
seatTypes: SeatTypes[];
setSeatTypes: Dispatch<SetStateAction<SeatTypes[]>>;
}

export const ReportForm = ({
location,
setLocation,
name,
setName,
recommendedMenu,
setRecommendedMenu,
reason,
setReason,
seatTypes,
setSeatTypes,
}: ReportFormProps) => {
const handleSeatTypesChange = (selectedLabels: string[]) => {
const newSeatTypes = selectedLabels.map(
(label) => Object.entries(SEAT_TYPE_MAP).find(([, v]) => v === label)?.[0] as SeatTypes,
);
setSeatTypes(newSeatTypes);
};

return (
<div className="flex min-h-screen flex-col gap-y-[36px] bg-white p-[20px] pb-[100px]">
<div className="flex flex-col gap-y-[8px]">
<span className="text-subtitle1">κ°€κ²Œ μœ„μΉ˜</span>
<Input
label=""
placeholder="μ–΄λŠ 지역에 μžˆλ‚˜μš”? ex) 강남역"
value={location}
onChange={setLocation}
/>
</div>
<div className="flex flex-col gap-y-[8px]">
<span className="text-subtitle1">κ°€κ²Œ 정보</span>
<Input label="" placeholder="κ°€κ²Œ 이름이 λ¬΄μ—‡μΈκ°€μš”?" value={name} onChange={setName} />
</div>
<div className="flex flex-col gap-y-[8px]">
<span className="text-subtitle1">μΆ”μ²œ 메뉴</span>
<Input
label=""
placeholder="μΆ”μ²œ 메뉴λ₯Ό μ μ–΄μ£Όμ„Έμš”."
value={recommendedMenu}
onChange={setRecommendedMenu}
/>
</div>
<div className="flex flex-col gap-y-[8px]">
<span className="text-subtitle1">식당 μΆ”μ²œ 이유</span>
<InputReview
label=""
placeholder="μΆ”μ²œ 이유λ₯Ό μ μ–΄μ£Όμ„Έμš”."
value={reason}
onChange={(e) => setReason(e.target.value)}
/>
</div>
<div className="flex flex-col gap-y-[8px]">
<span className="text-subtitle1">μ’Œμ„ ν˜•νƒœ</span>
<FilterSection
label=""
isMultiple={true}
options={Object.values(SEAT_TYPE_MAP)}
selectedItems={seatTypes.map((type) => SEAT_TYPE_MAP[type])}
onChange={handleSeatTypesChange}
/>
</div>
</div>
);
};
44 changes: 44 additions & 0 deletions web/src/features/report/ui/SuccessModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import Image from "next/image";
import { useRouter } from "next/navigation";
import Character from "@/shared/lib/assets/png/character/basic.png";
import { Icon, Modal } from "@/shared/ui";

interface SuccessModalProps {
isOpen: boolean;
onClose: () => void;
}

export function SuccessModal({ isOpen, onClose }: SuccessModalProps) {
const router = useRouter();

const handleConfirm = () => {
onClose();
router.push("/mypage");
};

return (
<Modal isOpen={isOpen} onOpenChange={onClose} title={""} description={""}>
<div className="flex min-w-[260px] flex-col items-center justify-center gap-6 rounded-lg bg-white p-4">
<button type="button" className="mb-[-24px] flex h-5 w-full justify-end" onClick={onClose}>
<Icon name="close" size={24} className="cursor-pointer text-gray400" />
</button>
<Image src={Character} alt="character" width={120} height={120} />
<div className="flex flex-col gap-2">
<span className="whitespace-pre-line text-center text-gray900 text-subtitle1">
식당을 μ œλ³΄ν–ˆμ–΄μš”
</span>
<span className="whitespace-pre-line text-center text-gray700 text-body2-regular">
μ œλ³΄ν•΄μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€.
</span>
</div>
<button
type="button"
onClick={handleConfirm}
className="flex h-[51px] w-full items-center justify-center rounded-[8px] bg-primary400 py-[14px]"
>
<span className="text-body1-semibold text-gray0">μ™„λ£Œν•˜κΈ°</span>
</button>
</div>
</Modal>
);
}
7 changes: 7 additions & 0 deletions web/src/shared/config/routeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ export const ROUTE_CONFIG: Record<string, RouteConfig> = {
title: "정보 μˆ˜μ • μ œμ•ˆ",
},
},
"/report": {
group: "stack",
transition: "drill",
header: {
title: "혼λ°₯ 식당 제보",
},
},
};

/**
Expand Down