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
37 changes: 22 additions & 15 deletions src/components/Post/PostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ export default function PostCard({
return (
<article
className={cn(
"grid p-5 md:p-6 lg:grid-cols-[1fr_346px] lg:gap-[31px] rounded-2xl",
"grid p-5 sm:p-6 lg:grid-cols-[1fr_346px] lg:gap-[31px] rounded-2xl",
backgroundColor,
backgroundColor === "#ffffff" && "border border-gray-20 shadow-sm",
)}
>
<div className="relative w-full overflow-hidden rounded-xl">
<div className="relative w-full overflow-hidden rounded-xl h-auto">
<img
src={imageUrl}
alt={name}
className="w-full h-[180px] object-cover md:h-[360px] lg:h-[308px]"
className="w-full h-[180px] object-cover sm:h-[360px] lg:h-full"
onError={(e) => {
e.currentTarget.onerror = null;
e.currentTarget.src = "/default-image.png";
Expand All @@ -71,40 +71,47 @@ export default function PostCard({
</div>
)}
</div>
<div className="flex flex-col justify-between mt-3 h-[251px] md:mt-4 md:h-[252px] lg:h-[292px]">
<div className="space-y-2 md:space-y-3">
<div className="flex flex-col justify-between mt-3 sm:mt-4 lg:h-auto">
<div className="space-y-2 sm:space-y-3 flex-1">
{!isShopInfo ? (
<>
<div className="flex flex-col gap-[2px]">
<p className="mb-2 text-primary body2-bold md:body1-bold">
<p className="mb-2 text-primary body2-bold sm:body1-bold">
시급
</p>
<div className="flex items-center gap-2">
<h2 className="text-[20px] font-bold md:text-[28px]">
<h2 className="text-[20px] font-bold sm:text-[28px]">
{hourlyPay?.toLocaleString()}원
</h2>
{!closed && (
<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">
<span className="inline-flex items-center gap-[2px] rounded-[20px] bg-primary px-3 py-1 text-[12px] font-normal leading-[16px] text-white sm:body2-bold">
{rateText}
<ArrowUp className="w-4 h-4 md:w-5 md:h-5" />
<ArrowUp className="w-4 h-4 sm:w-5 sm:h-5" />
</span>
)}
</div>
</div>
<div className="flex items-center gap-[6px] text-gray-50 sm:body2-regular md:body1-regular">
<Time className="w-4 h-4 md:w-5 md:h-5" />
<div className="flex items-center gap-[6px] text-gray-50 body2-regular sm:body1-regular">
<Time className="w-4 h-4 sm:w-5 sm:h-5" />
{timeRange}
</div>
</>
) : (
<p className="text-primary body2-bold md:body1-bold">식당</p>
<p className="text-primary body2-bold sm:body1-bold">식당</p>
)}
{isShopInfo && <h2 className="text-[28px] font-bold">{name}</h2>}
<div className="flex items-center gap-[6px] text-gray-50 sm:body2-regular md:body1-regular">
<Location className="w-4 h-4 md:w-5 md:h-5" />
<div className="flex items-center gap-[6px] text-gray-50 body2-regular sm:body1-regular">
<Location className="w-4 h-4 sm:w-5 sm:h-5" />
{address1}
</div>
<p className="text-black sm:body2-regular md:body1-regular">
<p
className={cn(
"body2-regular sm:body1-regular break-words",
description === "등록된 가게 정보가 없습니다."
? "text-gray-40"
: "text-black",
)}
>
{description}
</p>
</div>
Expand Down
57 changes: 53 additions & 4 deletions src/pages/ShopPage/ShopPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useMemo, useRef } from "react";
import { useCallback, useMemo, useRef, useEffect } from "react";

import { useNavigate } from "react-router-dom";

Expand All @@ -7,7 +7,9 @@ import EmptyStateCard from "@/components/EmptyStateCard";
import PostCard from "@/components/Post/PostCard";
import PostList from "@/components/Post/PostList";
import { ROUTES } from "@/constants/router";
import { useUserStore } from "@/hooks/useUserStore";
import { useShopData } from "@/pages/ShopPage/hooks/useShopData";
import { useModalStore } from "@/store/useModalStore";

export interface PostListItem {
id: string;
Expand All @@ -24,6 +26,8 @@ export interface PostListItem {

export default function ShopPage() {
const navigate = useNavigate();
const { openModal, closeModal } = useModalStore();
const { user } = useUserStore();

const {
shop,
Expand All @@ -36,6 +40,46 @@ export default function ShopPage() {
LIMIT,
} = useShopData();

useEffect(() => {
if (!user) {
openModal({
type: "alert",
message: "로그인 후에 이용 가능한 기능입니다.",
iconType: "warning",
buttons: [
{
label: "확인",
style: "white",
onClick: () => {
closeModal();
},
},
],
onClose: () => {
navigate(ROUTES.AUTH.SIGNIN);
},
});
} else if (user.type === "employee") {
openModal({
type: "alert",
message: "사장님 계정으로만 이용 가능한 기능입니다.",
iconType: "warning",
buttons: [
{
label: "확인",
style: "white",
onClick: () => {
closeModal();
},
},
],
onClose: () => {
navigate(ROUTES.PROFILE.ROOT);
},
});
}
}, [user, openModal, closeModal, navigate]);

const observer = useRef<IntersectionObserver | null>(null);

const postListData: PostListItem[] = useMemo(() => {
Expand All @@ -44,7 +88,7 @@ export default function ShopPage() {
return [...notices]
.sort(
(a, b) =>
new Date(b.startsAt).getTime() - new Date(a.startsAt).getTime(),
new Date(a.startsAt).getTime() - new Date(b.startsAt).getTime(),
)
.map((notice) => ({
id: notice.id,
Expand Down Expand Up @@ -79,7 +123,7 @@ export default function ShopPage() {

return (
<>
<section className="xl:w-[60.25rem] xl:mx-auto px-6 xl:px-[0px] py-[3.75rem]">
<section className="lg:w-[60.25rem] lg:mx-auto px-6 lg:px-[0px] py-[3.75rem]">
<h1 className="text-[1.75rem] font-bold mb-6">내 가게</h1>
{isShopLoading ? null : !shop ? (
<EmptyStateCard
Expand All @@ -90,6 +134,11 @@ export default function ShopPage() {
) : (
<PostCard
{...shop}
description={
shop.description && shop.description.trim() !== ""
? shop.description
: "등록된 가게 정보가 없습니다"
}
isShopInfo={true}
backgroundColor="bg-red-10"
buttons={
Expand Down Expand Up @@ -117,7 +166,7 @@ export default function ShopPage() {

{shop && (
<section className="flex-1 bg-gray-5">
<div className="xl:w-[60.25rem] mx-auto px-6 xl:px-[0px] pt-[3.75rem] pb-[7.5rem]">
<div className="lg:w-[60.25rem] mx-auto px-6 lg:px-[0px] pt-[3.75rem] pb-[7.5rem]">
<h1 className="text-[1.75rem] font-bold mb-8">등록한 공고</h1>

{isNoticeLoading ? null : notices.length === 0 ? (
Expand Down