Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix create group and my group bug #43

Merged
merged 1 commit into from
Mar 3, 2024
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
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
Loading