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
4 changes: 2 additions & 2 deletions src/api/employer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/features/my-shop/shopForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
18 changes: 14 additions & 4 deletions src/pages/my-shop/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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();
Expand Down
Loading