diff --git a/app/[locale]/[id]/_components/HighlineHeader.tsx b/app/[locale]/[id]/_components/HighlineHeader.tsx index 829ee26..5ad627d 100644 --- a/app/[locale]/[id]/_components/HighlineHeader.tsx +++ b/app/[locale]/[id]/_components/HighlineHeader.tsx @@ -4,8 +4,8 @@ import { MapPinIcon } from "lucide-react"; import { useTranslations } from "next-intl"; import { useEffect, useRef, useState } from "react"; -import type { Highline } from "@/app/actions/getHighline"; import { RegistryEntry } from "@/app/[locale]/[id]/_components/RegistryEntry"; +import type { Highline } from "@/app/actions/getHighline"; import { Button } from "@/components/ui/button"; import { CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { cn } from "@/lib/utils"; diff --git a/app/[locale]/[id]/_components/RegistryEntry.tsx b/app/[locale]/[id]/_components/RegistryEntry.tsx index d370bf3..a979b64 100644 --- a/app/[locale]/[id]/_components/RegistryEntry.tsx +++ b/app/[locale]/[id]/_components/RegistryEntry.tsx @@ -40,6 +40,7 @@ import MultiSelectFormField from "./witness-select"; const formSchema = z.object({ instagram: z .string() + .trim() .startsWith("@", "O usuário deve começar com @") .min(3, "Deve conter ao menos 3 caracteres"), cadenas: z.number().nonnegative(), @@ -92,6 +93,19 @@ export const RegistryEntry = ({ highlineId, highlineDistance }: Props) => { }, }); + useEffect(() => { + async function setUsername() { + const { + data: { session }, + } = await supabase.auth.getSession(); + entryForm.setValue( + "instagram", + session?.user.user_metadata["username"] || "" + ); + } + setUsername(); + }, [supabase.auth, entryForm]); + const watchCadenas = entryForm.watch("cadenas"); const watchFullLines = entryForm.watch("full_lines"); @@ -184,7 +198,10 @@ export const RegistryEntry = ({ highlineId, highlineDistance }: Props) => { name="instagram" render={({ field }) => ( - Instagram + Highliner + + {t("instagram.description")} +