Skip to content

Commit

Permalink
Merge pull request #38 from Project-Unifest/feature/introduce-queue-f…
Browse files Browse the repository at this point in the history
…eature

Feature/introduce queue feature
  • Loading branch information
algoORgoal authored Sep 9, 2024
2 parents 158c13a + 3517163 commit 073326e
Show file tree
Hide file tree
Showing 20 changed files with 101 additions and 97 deletions.
8 changes: 8 additions & 0 deletions mocks/api/constants/booths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@ export const booths: Booth[] = [
price: 5000,
imgUrl:
"https://content.foodspring.co.kr/vendor/1781/images/101_4100052181_r.png",
menuStatus: null,
},
{
id: 1,
name: "타코야끼",
price: 4500,
imgUrl:
"https://thenaum.cdn-nhncommerce.com/data/goods/18/01/03/1000001570/1000001570_add3_023.jpg",
menuStatus: null,
},
{
id: 2,
name: "닭강정",
price: 6000,
imgUrl:
"https://gwchild114.firstmall.kr/data/goods/1/2021/06/42952_tmp_bfbe39f750e2db665da61b3a2e3c74697887large.png",
menuStatus: null,
},
],
enabled: false,
Expand All @@ -71,34 +74,39 @@ export const booths: Booth[] = [
price: 6000,
imgUrl:
"https://gwchild114.firstmall.kr/data/goods/1/2021/06/42952_tmp_bfbe39f750e2db665da61b3a2e3c74697887large.png",
menuStatus: null,
},
{
id: 1,
name: "파전",
price: 12000,
imgUrl:
"https://recipe1.ezmember.co.kr/cache/recipe/2021/10/06/fc673b15bc044419eba3f16c02981bd01.jpg",
menuStatus: null,
},
{
id: 2,
name: "콘치즈",
price: 5000,
imgUrl:
"https://roout.co.kr/m/p/u/CuAhLhz/labels/category%3A%EC%BD%98%EC%B9%98%EC%A6%88/i/HWBqoVuw1Qg.jpg",
menuStatus: null,
},
{
id: 3,
name: "소주",
price: 5000,
imgUrl:
"https://img.khan.co.kr/news/2022/02/18/l_2022021801002225800200181.jpg",
menuStatus: null,
},
{
id: 4,
name: "주",
price: 5000,
imgUrl:
"https://health.chosun.com/site/data/img_dir/2015/08/11/2015081101302_0.jpg",
menuStatus: null,
},
],
enabled: true,
Expand Down
8 changes: 8 additions & 0 deletions mocks/api/constants/members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,23 @@ export const member: Member = {
price: 5000,
imgUrl:
"https://content.foodspring.co.kr/vendor/1781/images/101_4100052181_r.png",
menuStatus: null,
},
{
id: 1,
name: "타코야끼",
price: 4500,
imgUrl:
"https://thenaum.cdn-nhncommerce.com/data/goods/18/01/03/1000001570/1000001570_add3_023.jpg",
menuStatus: null,
},
{
id: 2,
name: "닭강정",
price: 6000,
imgUrl:
"https://gwchild114.firstmall.kr/data/goods/1/2021/06/42952_tmp_bfbe39f750e2db665da61b3a2e3c74697887large.png",
menuStatus: null,
},
],
enabled: false,
Expand All @@ -74,34 +77,39 @@ export const member: Member = {
price: 6000,
imgUrl:
"https://gwchild114.firstmall.kr/data/goods/1/2021/06/42952_tmp_bfbe39f750e2db665da61b3a2e3c74697887large.png",
menuStatus: null,
},
{
id: 1,
name: "파전",
price: 12000,
imgUrl:
"https://recipe1.ezmember.co.kr/cache/recipe/2021/10/06/fc673b15bc044419eba3f16c02981bd01.jpg",
menuStatus: null,
},
{
id: 2,
name: "콘치즈",
price: 5000,
imgUrl:
"https://roout.co.kr/m/p/u/CuAhLhz/labels/category%3A%EC%BD%98%EC%B9%98%EC%A6%88/i/HWBqoVuw1Qg.jpg",
menuStatus: null,
},
{
id: 3,
name: "소주",
price: 5000,
imgUrl:
"https://img.khan.co.kr/news/2022/02/18/l_2022021801002225800200181.jpg",
menuStatus: null,
},
{
id: 4,
name: "주",
price: 5000,
imgUrl:
"https://health.chosun.com/site/data/img_dir/2015/08/11/2015081101302_0.jpg",
menuStatus: null,
},
],
enabled: true,
Expand Down
16 changes: 10 additions & 6 deletions src/entities/booth/ui/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ import {
import Link from "next/link";

import React, { ReactNode } from "react";
import { number, string } from "zod";

type ItemPropsType = Pick<Booth, "name"> &
Partial<Pick<Booth, "description" | "location" | "id">> & {
editButton: ReactNode;
deleteButton: ReactNode;
switchButton: ReactNode;
};
interface ItemPropsType {
id: number;
name: string;
description: string;
location: string;
editButton: ReactNode;
deleteButton: ReactNode;
switchButton: ReactNode;
}

export function Item({
id,
Expand Down
10 changes: 5 additions & 5 deletions src/features/menu/ui/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ import { useAuthStore } from "@/src/shared/model/provider/auth-store-provider";
import useAuthFetch from "@/src/shared/model/auth/useAuthFetchList";
import { MenuItemState } from "@/src/shared/model/store/booth-edit-store";
import { useBoothEditStore } from "@/src/shared/model/provider/booth-edit-store.provider";
import { MenuItem } from "@/src/shared/lib/types";
import { Product } from "@/src/shared/lib/types";

interface MenuItemPropsType {
boothId: number;
id: number;
name: string;
price: number;
imgUrl?: string;
state: MenuItemState;
edit: (id: number, menuProp: Partial<MenuItem>) => void;
menuStatus: MenuItemState | null;
edit: (id: number, menuProp: Partial<Product>) => void;
add: () => void;
remove: (id: number) => void;
}
Expand All @@ -39,7 +39,7 @@ export function MenuCard({
name,
price,
imgUrl,
state,
menuStatus,
add,
remove,
edit,
Expand All @@ -48,7 +48,7 @@ export function MenuCard({
const deleteAuthMemuItem = useAuthFetch(deleteMenuItem);

const canBeRegistered = Boolean(
state === MenuItemState.DRAFT && name && price,
menuStatus === MenuItemState.DRAFT && name && price,
);

const handleChangeImage = async (event: ChangeEvent<HTMLInputElement>) => {
Expand Down
7 changes: 3 additions & 4 deletions src/features/queue/ui/EnterButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import React from "react";
// TODO add handleClick event handler function

interface EnterButtonPropsType {
id: number;
onEnter: (id: number) => void | Promise<void>;
onEnter: () => void | Promise<void>;
}

export default function Enter({ id, onEnter }: EnterButtonPropsType) {
export default function EnterButton({ onEnter }: EnterButtonPropsType) {
const handleClick = () => {
onEnter(id);
onEnter();
};
return (
<Button size="square" state="outlined" shape="circle" onClick={handleClick}>
Expand Down
7 changes: 3 additions & 4 deletions src/features/queue/ui/NotifyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { Button } from "@/src/shared/ui/button";
import React from "react";

interface NotifyButtonPropsType {
id: number;
onNotify: (waitingId: number) => void | Promise<void>;
onNotify: () => void | Promise<void>;
}

export default function NotifyButton({ id, onNotify }: NotifyButtonPropsType) {
export default function NotifyButton({ onNotify }: NotifyButtonPropsType) {
const handleClick = () => {
onNotify(id);
onNotify();
};

return (
Expand Down
6 changes: 3 additions & 3 deletions src/features/queue/ui/QueueTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import React, { useState } from "react";

interface QueueTabsPropsType {
activatedTab?: string;
onToggle: (tab: string) => void;
onToggle: (tab: "active" | "completed" | "canceled") => void;
}

export default function QueueTabs({
activatedTab,
onToggle,
}: QueueTabsPropsType) {
const handleValueChange = (value: string) => {
const handleValueChange = (value: "active" | "completed" | "canceled") => {
onToggle(value);
};

return (
<Tabs
defaultValue="queue"
value={activatedTab}
onValueChange={handleValueChange}
onValueChange={handleValueChange as any}
>
<TabsList>
<TabsTrigger value="active">웨이팅</TabsTrigger>
Expand Down
13 changes: 12 additions & 1 deletion src/pages/booths/booth-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@ import PINContainer from "@/src/widgets/queue/ui/pin-container";
import React from "react";

interface BoothDetailPropsType {
booth: Booth;
booth: {
id: number;
name: string;
description: string;
location: string;
enabled: boolean;
};
}

export default function BoothDetail({ booth }: BoothDetailPropsType) {
// TODO change component to loading state
if (!booth) {
return <>페이지가 비어있어요.</>;
}

return (
<>
<div className="mb-3">
Expand Down
13 changes: 4 additions & 9 deletions src/shared/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MenuItemState } from "../model/store/booth-edit-store";

export interface Product {
menuStatus?: MenuItemState;
menuStatus: MenuItemState | null;
id: number;
name: string;
price: number;
Expand All @@ -27,8 +27,9 @@ export interface Member {
id?: number;
email: string;
phoneNum: string;
booths: Booth[];
booths: (Required<Pick<Booth, "id" | "description">> & Omit<Booth, "id">)[];
schoolId: number;
memberRole: string;
}

export const BoothCategory = {
Expand All @@ -44,13 +45,7 @@ export type BoothCategoryKeys =
(typeof BoothCategory)[keyof typeof BoothCategory];

export type BoothList = Booth[];
export interface MenuItem {
id: number;
name: string;
price: number;
imgUrl?: string;
state: MenuItemState;
}

export enum AnimatedPathSegment {
SET_NAME = "set-name",
SET_CATEGORY = "set-category",
Expand Down
18 changes: 11 additions & 7 deletions src/shared/model/store/booth-details-draft-store.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { devtools, persist } from "zustand/middleware";
import { createStore } from "zustand/vanilla";
import { Booth, BoothCategory } from "../../lib/types";
import {
Booth,
BoothCategory,
BoothCategoryKeys,
Product,
} from "../../lib/types";
import { MenuItemState } from "./booth-edit-store";
import { MenuItem } from "../../lib/types";

export interface Position {
latitude: number;
Expand All @@ -15,13 +19,13 @@ export type BoothDetailsDraftActions = {
initialize: (booth: Booth) => void;
setField: (boothProps: Partial<BoothDetailsDraftState>) => void;
editName: (newName: string) => void;
editCategory: (newCategory: BoothCategory) => void;
editCategory: (newCategory: BoothCategoryKeys) => void;
editDescription: (newDescription: string) => void;
editPosition: (newPosition: Position) => void;
editThumbnail: (url: string) => void;
reset: () => void;
addMenuItem: () => void;
editMenuItem: (id: number, menuProp: Partial<MenuItem>) => void;
editMenuItem: (id: number, menuProp: Partial<Product>) => void;
removeMenuItem: (id: number) => void;
};

Expand All @@ -44,7 +48,7 @@ export const defaultInitState = {
latitude: CampusPosition.latitude,
longitude: CampusPosition.longitude,
menus: [],
} satisfies BoothDetailsDraftState;
} satisfies Omit<BoothDetailsDraftState, "id">;

export const createBoothDetailsDraftStore =
process.env.NODE_ENV === "development"
Expand Down Expand Up @@ -79,7 +83,7 @@ export const createBoothDetailsDraftStore =
id: crypto.getRandomValues(new Uint32Array(1))[0],
name: "",
price: 0,
state: MenuItemState.DRAFT,
menuStatus: MenuItemState.DRAFT,
},
],
})),
Expand Down Expand Up @@ -127,7 +131,7 @@ export const createBoothDetailsDraftStore =
id: crypto.getRandomValues(new Uint32Array(1))[0],
name: "",
price: 0,
state: MenuItemState.DRAFT,
menuStatus: MenuItemState.DRAFT,
},
],
})),
Expand Down
4 changes: 2 additions & 2 deletions src/shared/model/store/booth-draft-store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { devtools, persist } from "zustand/middleware";
import { createStore } from "zustand/vanilla";
import { Booth, BoothCategory } from "../../lib/types";
import { Booth, BoothCategory, BoothCategoryKeys } from "../../lib/types";

export interface Position {
latitude: number;
Expand All @@ -11,7 +11,7 @@ export type BoothDraftState = Booth;

export type BoothDraftActions = {
editName: (newName: string) => void;
editCategory: (newCategory: BoothCategory) => void;
editCategory: (newCategory: BoothCategoryKeys) => void;
editDescription: (newDescription: string) => void;
editPosition: (newPosition: Position) => void;
reset: () => void;
Expand Down
Loading

1 comment on commit 073326e

@github-actions
Copy link

Choose a reason for hiding this comment

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

Deploy preview for unifest-web-deployment ready!

✅ Preview
https://unifest-web-deployment-k266vpnft-algoorgoals-projects.vercel.app

Built with commit 073326e.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.