mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-09 04:02:40 -05:00
fapost should have at least one playstyle
This commit is contained in:
parent
4efd7f8d27
commit
9bc5600922
|
|
@ -3,6 +3,7 @@ import {
|
|||
Checkbox,
|
||||
CheckboxGroup,
|
||||
FormControl,
|
||||
FormErrorMessage,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
HStack,
|
||||
|
|
@ -88,6 +89,8 @@ const FAModal: React.FC<Props> = ({ onClose, post }) => {
|
|||
onClose();
|
||||
};
|
||||
|
||||
console.log("ep", errors.playstyles);
|
||||
|
||||
return (
|
||||
<Modal isOpen onClose={onClose} size="xl" closeOnOverlayClick={false}>
|
||||
<ModalOverlay>
|
||||
|
|
@ -129,26 +132,33 @@ const FAModal: React.FC<Props> = ({ onClose, post }) => {
|
|||
<FormLabel htmlFor="playstyles">
|
||||
<Trans>Roles</Trans>
|
||||
</FormLabel>
|
||||
<Controller
|
||||
name="playstyles"
|
||||
control={control}
|
||||
defaultValue={[]}
|
||||
render={({ onChange, value }) => (
|
||||
<CheckboxGroup value={value} onChange={onChange}>
|
||||
<HStack>
|
||||
<Checkbox value="FRONTLINE">
|
||||
<Trans>Frontline</Trans>
|
||||
</Checkbox>
|
||||
<Checkbox value="MIDLINE">
|
||||
<Trans>Support</Trans>
|
||||
</Checkbox>
|
||||
<Checkbox value="BACKLINE">
|
||||
<Trans>Backline</Trans>
|
||||
</Checkbox>
|
||||
</HStack>
|
||||
</CheckboxGroup>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormControl isInvalid={!!errors.playstyles}>
|
||||
<Controller
|
||||
name="playstyles"
|
||||
control={control}
|
||||
defaultValue={[]}
|
||||
render={({ onChange, value }) => (
|
||||
<CheckboxGroup value={value} onChange={onChange}>
|
||||
<HStack>
|
||||
<Checkbox value="FRONTLINE">
|
||||
<Trans>Frontline</Trans>
|
||||
</Checkbox>
|
||||
<Checkbox value="MIDLINE">
|
||||
<Trans>Support</Trans>
|
||||
</Checkbox>
|
||||
<Checkbox value="BACKLINE">
|
||||
<Trans>Backline</Trans>
|
||||
</Checkbox>
|
||||
</HStack>
|
||||
</CheckboxGroup>
|
||||
)}
|
||||
/>
|
||||
{/* @ts-ignore */}
|
||||
<FormErrorMessage>
|
||||
{errors.playstyles?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
<FormLabel htmlFor="canVC" mt={4}>
|
||||
<Trans>Can you voice chat?</Trans>
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ const FreeAgentsPage = () => {
|
|||
state,
|
||||
dispatch,
|
||||
} = useFreeAgents();
|
||||
const [user] = useUser();
|
||||
const router = useRouter();
|
||||
const postRef = useRef<HTMLDivElement>(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<GetAllFreeAgentPostsData>;
|
||||
isLiked: boolean;
|
||||
canLike: boolean;
|
||||
postRef?: RefObject<HTMLDivElement>;
|
||||
}) => {
|
||||
const { themeColorShade } = useMyTheme();
|
||||
const [user] = useUser();
|
||||
|
||||
const handleClick = async () => {
|
||||
await sendData("PUT", "/api/freeagents/like", { likedId: post.id });
|
||||
|
|
@ -218,7 +223,7 @@ const FreeAgentCard = ({
|
|||
<Markdown value={post.user.profile.bio} smallHeaders />
|
||||
</SubTextCollapse>
|
||||
)}
|
||||
{user && post.user.discordId !== user.discordId && false && (
|
||||
{canLike && (
|
||||
<IconButton
|
||||
color="red.500"
|
||||
aria-label="Like"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user