diff --git a/src/assets/icon/index.ts b/src/assets/icon/index.ts index 7b44892..0d92395 100644 --- a/src/assets/icon/index.ts +++ b/src/assets/icon/index.ts @@ -2,6 +2,7 @@ import Active from "./active.svg?react"; import ArrowLeft from "./arrow-left.svg?react"; import ArrowRight from "./arrow-right.svg?react"; import ArrowUp from "./arrow-up.svg?react"; +import ArrowUpBold from "./arrow-up-bold.svg?react"; import Camera from "./camera.svg?react"; import Check from "./check.svg?react"; import Close from "./close.svg?react"; @@ -16,6 +17,7 @@ import Time from "./time.svg?react"; export { ArrowUp, + ArrowUpBold, ArrowLeft, ArrowRight, Close, diff --git a/src/components/Post/Post.tsx b/src/components/Post/Post.tsx index 6f495cf..8567a40 100644 --- a/src/components/Post/Post.tsx +++ b/src/components/Post/Post.tsx @@ -1,25 +1,8 @@ import { cn } from "@/utils/cn"; import { Link } from "react-router-dom"; import { formatTimeRange, isPastDate } from "@/utils/datetime"; -import IconTime from "@/assets/icon/time.svg?react"; -import IconLocation from "@/assets/icon/location.svg?react"; -import IconArrow from "@/assets/icon/arrow-up.svg?react"; -import IconArrowBold from "@/assets/icon/arrow-up-bold.svg?react"; - -const getPayRateText = ( - hourlyPay: number, - originalPay: number, -): { - rawRate: number; - displayRate: number; - rateText: string; -} => { - const rawRate = ((hourlyPay - originalPay) / originalPay) * 100; - const displayRate = Math.min(Math.round(rawRate), 100); - const rateText = `기존 시급보다 ${displayRate}%`; - - return { rawRate, displayRate, rateText }; -}; +import { getPayRateText } from "@/utils/payRate"; +import { Location, Time, ArrowUp, ArrowUpBold } from "@/assets/icon"; interface PostProps { name: string; @@ -76,11 +59,11 @@ export default function Post({

{name}

- +

- + {address1}

@@ -102,8 +85,8 @@ export default function Post({ )} > {rateText} - - + + )} diff --git a/src/components/Post/PostCard.tsx b/src/components/Post/PostCard.tsx new file mode 100644 index 0000000..0084fb3 --- /dev/null +++ b/src/components/Post/PostCard.tsx @@ -0,0 +1,92 @@ +import { cn } from "@/utils/cn"; +import { formatTimeRange } from "@/utils/datetime"; +import { getPayRateText } from "@/utils/payRate"; +import { Location, Time, ArrowUp } from "@/assets/icon"; + +interface PostCardProps { + name: string; + imageUrl: string; + address1: string; + description: string; + originalHourlyPay?: number; + hourlyPay?: number; + startsAt?: string; + workhour?: number; + isShopInfo?: boolean; + backgroundColor?: string; + buttons?: React.ReactNode; +} + +export default function PostCard({ + name, + imageUrl, + address1, + description, + hourlyPay, + originalHourlyPay, + startsAt, + workhour, + isShopInfo = false, + backgroundColor = "#ffffff", + buttons = null, +}: PostCardProps) { + const { rateText } = getPayRateText(hourlyPay, originalHourlyPay); + + const timeRange = + startsAt && workhour !== undefined + ? formatTimeRange(startsAt, workhour) + : ""; + + return ( +
+
+ {name} +
+
+
+ {!isShopInfo ? ( + <> +
+

시급

+
+

+ {hourlyPay?.toLocaleString()}원 +

+ + {rateText} + + +
+
+
+
+ + ) : ( +

식당

+ )} + {isShopInfo &&

{name}

} +
+ + {address1} +
+

+ {description} +

+
+ {buttons &&
{buttons}
} +
+
+ ); +} diff --git a/src/styles/theme.css b/src/styles/theme.css index 24cfea8..aaa9762 100644 --- a/src/styles/theme.css +++ b/src/styles/theme.css @@ -23,5 +23,9 @@ --color-green-10: #d4f7d4; --color-green-20: #20a81e; + --color-violet: #5534da; + + --color-primary: #ea3c12; + --color-kakao: #fee500; } diff --git a/src/utils/payRate.ts b/src/utils/payRate.ts new file mode 100644 index 0000000..44297f6 --- /dev/null +++ b/src/utils/payRate.ts @@ -0,0 +1,28 @@ +/** + * 시급 인상률 계산 유틸리티 + * @param hourlyPay 현재 시급 + * @param originalPay 기존 시급 + * @returns { rawRate, displayRate, rateText } + */ +export const getPayRateText = ( + hourlyPay?: number, + originalPay?: number, +): { + rawRate: number; + displayRate: number; + rateText: string; +} => { + if (hourlyPay === undefined || originalPay === undefined) { + return { + rawRate: 0, + displayRate: 0, + rateText: "", + }; + } + + const rawRate = ((hourlyPay - originalPay) / originalPay) * 100; + const displayRate = Math.min(Math.round(rawRate), 100); + const rateText = `기존 시급보다 ${displayRate}%`; + + return { rawRate, displayRate, rateText }; +};