|
| 1 | +import { cn } from "@/utils/cn"; |
| 2 | +import { formatTimeRange } from "@/utils/datetime"; |
| 3 | +import { getPayRateText } from "@/utils/payRate"; |
| 4 | +import { Location, Time, ArrowUp } from "@/assets/icon"; |
| 5 | + |
| 6 | +interface PostCardProps { |
| 7 | + name: string; |
| 8 | + imageUrl: string; |
| 9 | + address1: string; |
| 10 | + description: string; |
| 11 | + originalHourlyPay?: number; |
| 12 | + hourlyPay?: number; |
| 13 | + startsAt?: string; |
| 14 | + workhour?: number; |
| 15 | + isShopInfo?: boolean; |
| 16 | + backgroundColor?: string; |
| 17 | + buttons?: React.ReactNode; |
| 18 | +} |
| 19 | + |
| 20 | +export default function PostCard({ |
| 21 | + name, |
| 22 | + imageUrl, |
| 23 | + address1, |
| 24 | + description, |
| 25 | + hourlyPay, |
| 26 | + originalHourlyPay, |
| 27 | + startsAt, |
| 28 | + workhour, |
| 29 | + isShopInfo = false, |
| 30 | + backgroundColor = "#ffffff", |
| 31 | + buttons = null, |
| 32 | +}: PostCardProps) { |
| 33 | + const { rateText } = getPayRateText(hourlyPay, originalHourlyPay); |
| 34 | + |
| 35 | + const timeRange = |
| 36 | + startsAt && workhour !== undefined |
| 37 | + ? formatTimeRange(startsAt, workhour) |
| 38 | + : ""; |
| 39 | + |
| 40 | + return ( |
| 41 | + <article |
| 42 | + className={cn( |
| 43 | + "grid p-5 md:p-6 lg:grid-cols-[1fr_346px] lg:gap-[31px] rounded-2xl", |
| 44 | + backgroundColor, |
| 45 | + backgroundColor === "#ffffff" && "border border-gray-20 shadow-sm", |
| 46 | + )} |
| 47 | + > |
| 48 | + <div className="w-full overflow-hidden rounded-xl"> |
| 49 | + <img |
| 50 | + src={imageUrl} |
| 51 | + alt={name} |
| 52 | + className="w-full h-[180px] object-cover md:h-[360px] lg:h-[308px]" |
| 53 | + /> |
| 54 | + </div> |
| 55 | + <div className="flex flex-col justify-between mt-3 h-[251px] md:mt-4 md:h-[252px] lg:h-[292px]"> |
| 56 | + <div className="space-y-2 md:space-y-3"> |
| 57 | + {!isShopInfo ? ( |
| 58 | + <> |
| 59 | + <div className="flex flex-col gap-[2px]"> |
| 60 | + <p className="text-primary body2-bold md:body1-bold">시급</p> |
| 61 | + <div className="flex items-center gap-2"> |
| 62 | + <h2 className="text-[20px] font-bold md:text-[28px]"> |
| 63 | + {hourlyPay?.toLocaleString()}원 |
| 64 | + </h2> |
| 65 | + <span className="inline-flex items-center gap-[2px] rounded-[20px] bg-primary px-3 py-1 text-[12px] font-normal leading-[16px] text-white md:body2-bold"> |
| 66 | + {rateText} |
| 67 | + <ArrowUp className="w-4 h-4 md:w-5 md:h-5" /> |
| 68 | + </span> |
| 69 | + </div> |
| 70 | + </div> |
| 71 | + <div className="flex items-center gap-[6px] text-gray-50 body2-regular md:body1-regular"> |
| 72 | + <Time className="w-4 h-4 md:w-5 md:h-5" /> |
| 73 | + {timeRange} |
| 74 | + </div> |
| 75 | + </> |
| 76 | + ) : ( |
| 77 | + <p className="text-primary body2-bold md:body1-bold">식당</p> |
| 78 | + )} |
| 79 | + {isShopInfo && <h2 className="text-[28px] font-bold">{name}</h2>} |
| 80 | + <div className="flex items-center gap-[6px] text-gray-50 body2-regular md:body1-regular"> |
| 81 | + <Location className="w-4 h-4 md:w-5 md:h-5" /> |
| 82 | + {address1} |
| 83 | + </div> |
| 84 | + <p className="text-black body2-regular md:body1-regular"> |
| 85 | + {description} |
| 86 | + </p> |
| 87 | + </div> |
| 88 | + {buttons && <div className="flex gap-2 mt-3">{buttons}</div>} |
| 89 | + </div> |
| 90 | + </article> |
| 91 | + ); |
| 92 | +} |
0 commit comments