Skip to content

Commit

Permalink
🐛 fix create group and my group bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnsonMao committed Mar 3, 2024
1 parent 93cdc72 commit 9317fb5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
6 changes: 2 additions & 4 deletions components/Group/Form/useGroupForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ 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(),
photoAlt: z.string(),
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
Expand Down
1 change: 0 additions & 1 deletion components/Profile/MyGroup/LoadingCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
StyledTitle,
StyledTime,
StyledFlex,
StyledStatus,
} from './GroupCard.styled';

function LoadingCard() {
Expand Down
15 changes: 8 additions & 7 deletions components/Profile/MyGroup/index.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
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';
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 (
<Box
sx={{
backgroundColor: '#ffffff',
width: '672px',
maxWidth: '672px',
borderRadius: '16px',
padding: '36px 40px',
display: 'flex',
Expand All @@ -29,17 +29,18 @@ const MyGroup = () => {
<Typography sx={{ fontSize: '22px', color: '#536166', fontWeight: 700 }}>
我的揪團
</Typography>
<Box width="560px">
<Box maxWidth="560px">
{isFetching ? (
<LoadingCard />
) : (
Array.isArray(data?.data) &&
) : Array.isArray(data?.data) && data.data.length ? (
data.data.map((item, index) => (
<Fragment key={item._id}>
{index > 0 && <StyledDivider />}
<GroupCard {...item} refetch={refetch} />
</Fragment>
))
) : (
<Typography py={7.5}>趕快發起屬於你的揪團吧~</Typography>
)}
</Box>
</Box>
Expand Down

0 comments on commit 9317fb5

Please sign in to comment.