diff --git a/app/db/tables.ts b/app/db/tables.ts index a65999620..d7cd91859 100644 --- a/app/db/tables.ts +++ b/app/db/tables.ts @@ -6,6 +6,7 @@ import type { Selectable, Updateable, } from "kysely"; +import type { AssociationIdentifier } from "~/features/associations/associations-constants"; import type { AssociationVisibility } from "~/features/associations/associations-types"; import type { tags } from "~/features/calendar/calendar-constants"; import type { CalendarFilters } from "~/features/calendar/calendar-types"; @@ -721,7 +722,7 @@ export interface TournamentTeam { avatarImgId: number | null; isLooking: Generated; isPlaceholder: Generated; - lfgVisibility: JSONColumnTypeNullable; + lfgVisibility: JSONColumnTypeNullable; lfgNote: string | null; } diff --git a/app/features/tournament-lfg/actions/to.$id.looking.server.ts b/app/features/tournament-lfg/actions/to.$id.looking.server.ts index 7b1e89408..c256e5277 100644 --- a/app/features/tournament-lfg/actions/to.$id.looking.server.ts +++ b/app/features/tournament-lfg/actions/to.$id.looking.server.ts @@ -9,7 +9,7 @@ import { import { assertUnreachable } from "~/utils/types"; import { idObject } from "~/utils/zod"; import * as TournamentLFGRepository from "../TournamentLFGRepository.server"; -import { lookingSchema } from "../tournament-lfg-schemas.server"; +import { lookingSchema } from "../tournament-lfg-schemas"; import { survivingTeamId } from "../tournament-lfg-utils"; // xxx: prevent actions in certain cases? like when tournament has started @@ -64,6 +64,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => { tournamentId, userId: user.id, isStayAsSub: data.stayAsSub ?? false, + lfgNote: data.note ?? undefined, }); } @@ -171,25 +172,19 @@ export const action = async ({ request, params }: ActionFunctionArgs) => { break; } - case "UPDATE_NOTE": { + case "UPDATE_GROUP": { const ownGroup = await findOwnGroup(); if (!ownGroup) return null; await TournamentLFGRepository.updateTeamNote({ teamId: ownGroup.id, - value: data.value, + value: data.note ?? null, }); - break; - } - case "UPDATE_STAY_AS_SUB": { - const ownGroup = await findOwnGroup(); - if (!ownGroup) return null; - await TournamentLFGRepository.updateStayAsSub({ teamId: ownGroup.id, userId: user.id, - value: data.value, + value: data.stayAsSub ?? false, }); break; diff --git a/app/features/tournament-lfg/components/LFGGroupCard.module.css b/app/features/tournament-lfg/components/LFGGroupCard.module.css index ed9b6798a..85d70b412 100644 --- a/app/features/tournament-lfg/components/LFGGroupCard.module.css +++ b/app/features/tournament-lfg/components/LFGGroupCard.module.css @@ -62,10 +62,6 @@ min-height: 24px; } -.noteTextarea { - height: 4rem !important; -} - .vcIcon { height: 15px; stroke-width: 2; diff --git a/app/features/tournament-lfg/components/LFGGroupCard.tsx b/app/features/tournament-lfg/components/LFGGroupCard.tsx index e7cd589e0..1ad2ad43f 100644 --- a/app/features/tournament-lfg/components/LFGGroupCard.tsx +++ b/app/features/tournament-lfg/components/LFGGroupCard.tsx @@ -15,10 +15,11 @@ import { StarFilledIcon } from "~/components/icons/StarFilled"; import { SubmitButton } from "~/components/SubmitButton"; import type { Pronouns } from "~/db/tables"; import { useUser } from "~/features/auth/core/user"; +import { SendouForm } from "~/form/SendouForm"; import { languagesUnified } from "~/modules/i18n/config"; import type { MainWeaponId } from "~/modules/in-game-lists/types"; import { navIconUrl, userPage } from "~/utils/urls"; -import { TOURNAMENT_LFG } from "../tournament-lfg-constants"; +import { updateGroupFormSchema } from "../tournament-lfg-schemas"; import styles from "./LFGGroupCard.module.css"; export type LFGGroupMember = { @@ -47,7 +48,6 @@ export type LFGGroup = { usersRole: "OWNER" | "MANAGER" | "REGULAR" | null; }; -// xxx: "cancel" & "save" buttons off export function LFGGroupCard({ group, action, @@ -59,10 +59,15 @@ export function LFGGroupCard({ }) { const { t } = useTranslation(["common", "q"]); const fetcher = useFetcher(); + const user = useUser(); const isOwnGroup = group.id === ownGroup?.id; const showActions = isOwnGroup && group.usersRole === "OWNER"; + const currentMember = user + ? group.members.find((m) => m.id === user.id) + : undefined; + return (
{group.teamName ? ( @@ -84,7 +89,11 @@ export function LFGGroupCard({ ))} {isOwnGroup ? ( - + ) : null} {action && (ownGroup?.usersRole === "OWNER" || ownGroup?.usersRole === "MANAGER") ? ( @@ -170,20 +179,29 @@ function LFGGroupMemberRow({ function LFGTeamNote({ note, editable, + isStayAsSub, }: { note: string | null; editable: boolean; + isStayAsSub: boolean; }) { const { t } = useTranslation(["common", "q"]); const [editing, setEditing] = React.useState(false); // biome-ignore lint/correctness/useExhaustiveDependencies(note): when note updates exit editing mode + // biome-ignore lint/correctness/useExhaustiveDependencies(isStayAsSub): when isStayAsSub updates exit editing mode React.useEffect(() => { setEditing(false); - }, [note]); + }, [note, isStayAsSub]); if (editing) { - return setEditing(false)} />; + return ( + setEditing(false)} + /> + ); } if (note) { @@ -217,38 +235,23 @@ function LFGTeamNote({ ); } -function LFGAddNoteForm({ +function LFGEditGroupForm({ note, + isStayAsSub, stopEditing, }: { note: string | null; + isStayAsSub: boolean; stopEditing: () => void; }) { - const fetcher = useFetcher(); - const textareaRef = React.useRef(null); const { t } = useTranslation(["common"]); - const [value, setValue] = React.useState(note ?? ""); - - const newValueLegal = value.length <= TOURNAMENT_LFG.PUBLIC_NOTE_MAX_LENGTH; - - React.useEffect(() => { - if (!textareaRef.current) return; - textareaRef.current.focus(); - textareaRef.current.selectionStart = textareaRef.current.selectionEnd = - textareaRef.current.value.length; - }, []); return ( - -