diff --git a/components/freeagents/FAModal.tsx b/components/freeagents/FAModal.tsx index 429630900..2c2a71188 100644 --- a/components/freeagents/FAModal.tsx +++ b/components/freeagents/FAModal.tsx @@ -3,6 +3,7 @@ import { Checkbox, CheckboxGroup, FormControl, + FormErrorMessage, FormHelperText, FormLabel, HStack, @@ -88,6 +89,8 @@ const FAModal: React.FC = ({ onClose, post }) => { onClose(); }; + console.log("ep", errors.playstyles); + return ( @@ -129,26 +132,33 @@ const FAModal: React.FC = ({ onClose, post }) => { Roles - ( - - - - Frontline - - - Support - - - Backline - - - - )} - /> + + + ( + + + + Frontline + + + Support + + + Backline + + + + )} + /> + {/* @ts-ignore */} + + {errors.playstyles?.message} + + Can you voice chat? diff --git a/lib/validators/fapost.ts b/lib/validators/fapost.ts index d763419b1..25cd8fe7d 100644 --- a/lib/validators/fapost.ts +++ b/lib/validators/fapost.ts @@ -3,7 +3,7 @@ import * as z from "zod"; export const FA_POST_CONTENT_LIMIT = 2000; export const freeAgentPostSchema = z.object({ - playstyles: z.array(z.enum(["FRONTLINE", "MIDLINE", "BACKLINE"])), + playstyles: z.array(z.enum(["FRONTLINE", "MIDLINE", "BACKLINE"])).min(1), canVC: z.enum(["YES", "NO", "MAYBE"]), content: z.string().max(FA_POST_CONTENT_LIMIT), }); diff --git a/pages/freeagents.tsx b/pages/freeagents.tsx index 9c4223980..dafeadb69 100644 --- a/pages/freeagents.tsx +++ b/pages/freeagents.tsx @@ -46,6 +46,7 @@ const FreeAgentsPage = () => { state, dispatch, } = useFreeAgents(); + const [user] = useUser(); const router = useRouter(); const postRef = useRef(null); const [modalIsOpen, setModalIsOpen] = useState(false); @@ -112,6 +113,9 @@ const FreeAgentsPage = () => { key={post.id} post={post} isLiked={false} + canLike={ + !!user && post.user.discordId !== user.discordId && !!usersPost + } postRef={post.id === idToScrollTo ? postRef : undefined} /> ))} @@ -128,14 +132,15 @@ const playstyleToEmoji = { const FreeAgentCard = ({ post, isLiked, + canLike, postRef, }: { post: Unpacked; isLiked: boolean; + canLike: boolean; postRef?: RefObject; }) => { const { themeColorShade } = useMyTheme(); - const [user] = useUser(); const handleClick = async () => { await sendData("PUT", "/api/freeagents/like", { likedId: post.id }); @@ -218,7 +223,7 @@ const FreeAgentCard = ({ )} - {user && post.user.discordId !== user.discordId && false && ( + {canLike && (