From 9317fb5da6acfc2cb9f952fa7bf55e031d810116 Mon Sep 17 00:00:00 2001 From: Johnson Mao Date: Sun, 3 Mar 2024 21:51:11 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20create=20group=20and=20my?= =?UTF-8?q?=20group=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Group/Form/useGroupForm.jsx | 6 ++---- components/Profile/MyGroup/LoadingCard.jsx | 1 - components/Profile/MyGroup/index.jsx | 15 ++++++++------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/components/Group/Form/useGroupForm.jsx b/components/Group/Form/useGroupForm.jsx index c6ca4dbd..766545a6 100644 --- a/components/Group/Form/useGroupForm.jsx +++ b/components/Group/Form/useGroupForm.jsx @@ -32,7 +32,7 @@ const DEFAULT_VALUES = { }; const rules = { - userId: z.string(), + userId: z.string().optional(), title: z.string().min(1, '請輸入標題').max(50, '請勿輸入超過 50 字'), file: z.any(), photoURL: z.string(), @@ -40,9 +40,7 @@ const rules = { category: z .array(z.enum(categoriesOptions.map(({ value }) => value))) .min(1, '請選擇學習領域'), - area: z - .array(z.enum(areasOptions.map(({ name }) => name))) - .min(1, '請選擇地點'), + area: z.array(z.string()).min(1, '請選擇地點'), time: z.string().max(50, '請勿輸入超過 50 字'), partnerStyle: z.string().max(50, '請勿輸入超過 50 字'), partnerEducationStep: z diff --git a/components/Profile/MyGroup/LoadingCard.jsx b/components/Profile/MyGroup/LoadingCard.jsx index 76554a52..86f6051c 100644 --- a/components/Profile/MyGroup/LoadingCard.jsx +++ b/components/Profile/MyGroup/LoadingCard.jsx @@ -11,7 +11,6 @@ import { StyledTitle, StyledTime, StyledFlex, - StyledStatus, } from './GroupCard.styled'; function LoadingCard() { diff --git a/components/Profile/MyGroup/index.jsx b/components/Profile/MyGroup/index.jsx index 903ea46c..36c362a3 100644 --- a/components/Profile/MyGroup/index.jsx +++ b/components/Profile/MyGroup/index.jsx @@ -1,7 +1,6 @@ import { Fragment } from 'react'; import { Box, Typography } from '@mui/material'; -import { useRouter } from 'next/router'; -import { useDispatch, useSelector } from 'react-redux'; +import { useSelector } from 'react-redux'; import { GROUP_API_URL } from '@/redux/actions/group'; import useFetch from '@/hooks/useFetch'; import GroupCard from './GroupCard'; @@ -9,15 +8,16 @@ import LoadingCard from './LoadingCard'; import { StyledDivider } from './GroupCard.styled'; const MyGroup = () => { + const me = useSelector((state) => state.user); const { data, isFetching, refetch } = useFetch( - `${GROUP_API_URL}/user/${'65a7e0300604d7c3f4641bf9'}`, + `${GROUP_API_URL}/user/${me?._id}`, ); return ( { 我的揪團 - + {isFetching ? ( - ) : ( - Array.isArray(data?.data) && + ) : Array.isArray(data?.data) && data.data.length ? ( data.data.map((item, index) => ( {index > 0 && } )) + ) : ( + 趕快發起屬於你的揪團吧~ )}