-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
407 additions
and
61 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,80 @@ | ||
import { FC, useEffect, useState } from "react"; | ||
import { BasketMenuType, MenuType } from "../../types/menu"; | ||
import { useSession } from "../../context/basketContext"; | ||
|
||
interface IProps { | ||
basketIdx: number; | ||
menuIdx: number; | ||
menuPrice: number; | ||
menuName: string; | ||
menuImage: string; | ||
orderDetailCount: number; | ||
menuTemperature?: string | null; | ||
menuSize?: string | null; | ||
} | ||
|
||
const BasketMenu: FC<IProps> = ({ | ||
basketIdx, | ||
menuIdx, | ||
menuName, | ||
menuPrice, | ||
menuImage, | ||
orderDetailCount, | ||
menuTemperature, | ||
menuSize, | ||
}) => { | ||
const { removeBasket, plusMenu, minusMenu } = useSession(); | ||
|
||
const clickMinus = () => { | ||
if (orderDetailCount <= 1) { | ||
return; | ||
} | ||
minusMenu(basketIdx); | ||
}; | ||
|
||
const clickPlus = () => { | ||
plusMenu(basketIdx); | ||
}; | ||
|
||
return ( | ||
<div className="pl-2 py-2 pr-1 flex flex-col justify-center w-64 h-20 bg-starbucksBeige rounded-lg"> | ||
<div className="flex justify-end"> | ||
<img | ||
className="flex w-3 h-3 cursor-pointer bg-black rounded-lg" | ||
src="./../../public/img/closeWhite.png" | ||
onClick={() => removeBasket(basketIdx)} | ||
/> | ||
</div> | ||
<div className="flex w-full"> | ||
<img className="w-14 h-16 rounded-xl" src={menuImage} /> | ||
<div className="pl-2 py-1 flex flex-col justify-between w-full"> | ||
<p className="flex text-sm line-clamp-1">{menuName}</p> | ||
<div className="flex w-full justify-between"> | ||
<p className="text-sm"> | ||
{(menuPrice * orderDetailCount).toLocaleString()}원 | ||
</p> | ||
<div className="flex"> | ||
<div | ||
className="flex justify-center items-center w-5 h-5 border-2 border-gray-200 bg-white cursor-pointer" | ||
onClick={() => clickMinus()} | ||
> | ||
- | ||
</div> | ||
<div className="flex justify-center items-center w-5 h-5 border-2 border-gray-200"> | ||
{orderDetailCount} | ||
</div> | ||
<div | ||
className="flex justify-center items-center w-5 h-5 border-2 border-gray-200 bg-white cursor-pointer" | ||
onClick={() => clickPlus()} | ||
> | ||
+ | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default BasketMenu; |
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,30 @@ | ||
import { FC } from "react"; | ||
import { BasketMenuType, MenuType } from "../../types/menu"; | ||
import BasketMenu from "../molecules/BasketMenu"; | ||
|
||
interface IProps { | ||
basketList?: BasketMenuType[]; | ||
} | ||
|
||
const BasketCard: FC<IProps> = ({ basketList }) => { | ||
return ( | ||
<div> | ||
<ul className="py-2 pl-4 pr-2 flex-row grid grid-cols-2 h-[26vh] gap-3 overflow-y-scroll"> | ||
{basketList?.map((menu: BasketMenuType) => ( | ||
<li key={menu.basketIdx}> | ||
<BasketMenu | ||
basketIdx={menu.basketIdx} | ||
menuIdx={menu.menuIdx} | ||
menuPrice={menu.menuPrice} | ||
menuName={menu.menuName} | ||
menuImage={menu.menuImage} | ||
orderDetailCount={menu.orderDetailCount} | ||
/> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default BasketCard; |
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.