diff --git a/src/api/employer.ts b/src/api/employer.ts index 314c4b9..31f4454 100644 --- a/src/api/employer.ts +++ b/src/api/employer.ts @@ -23,8 +23,8 @@ export async function putShop(shopId: string, body: RegisterFormData) { return data; } -export async function getNotice(shopId: string) { - const { data } = await axios.get(`/shops/${shopId}/notices`); +export async function getNotice(shopId: string, params?: { offset?: number; limit?: number }) { + const { data } = await axios.get(`/shops/${shopId}/notices`, { params }); return data; } diff --git a/src/components/features/my-shop/shopForm.tsx b/src/components/features/my-shop/shopForm.tsx index 211649d..7858bef 100644 --- a/src/components/features/my-shop/shopForm.tsx +++ b/src/components/features/my-shop/shopForm.tsx @@ -62,16 +62,16 @@ const ShopForm = ({ mode, initialData, onSubmit }: ShopFromProps) => { }; const validateForm = () => { - if (mode === 'register') + if (mode === 'register') { return ( !formData.name || !formData.category || !formData.address1 || !formData.address2 || !formData.originalHourlyPay || - !formData.image || - !formData.imageUrl + (!formData.image && !formData.imageUrl) ); + } return false; }; diff --git a/src/pages/my-shop/index.tsx b/src/pages/my-shop/index.tsx index 0b94c53..7430a4d 100644 --- a/src/pages/my-shop/index.tsx +++ b/src/pages/my-shop/index.tsx @@ -1,4 +1,4 @@ -import { getShop } from '@/api/employer'; +import { getNotice, getShop } from '@/api/employer'; import { Frame } from '@/components/layout'; import { Button, Notice } from '@/components/ui'; import useAuth from '@/hooks/useAuth'; @@ -8,14 +8,24 @@ import { useEffect, useState } from 'react'; const Myshop = () => { const { user } = useAuth(); const [shopData, setShopData] = useState({}); + const [shopNotice, setShopNotice] = useState({}); useEffect(() => { const get = async () => { - if (user?.shop) { - const res = await getShop(user.shop.item.id); - const { description, ...rest } = res.item; + if (!user?.shop) return; + try { + const [shopRes, noticeRes] = await Promise.all([ + getShop(user.shop.item.id), + getNotice(user.shop.item.id, { offset: 0, limit: 6 }), + ]); + + const { description, ...rest } = shopRes.item; const formattedShopData = { ...rest, shopDescription: description }; setShopData(formattedShopData); + setShopNotice(noticeRes); + //console.log('공고 조회:', noticeRes); + } catch (error) { + alert(error); } }; get();