sendou.ink/app/components/FriendCodeInput.tsx
Kalle 72fa1f68c8
Season 3 SendouQ changes (#1674)
* Mode Map Pool picker component initial

* Component in settings

* Lottery initial

* Fix tests

* useTrusters as perf optimization

* unionAll -> union

* Fancy picker for tournaments

* Map pools memento

* FC's initial

* Friend code when registering for tournament

* FC in flows

* SHow FC in places

* Add catch in case

* Fix disabling

* Show ELO changed

* Wiggle MapPool button if already selected

* CSS vars typing

* Rechallenging

* Team (all) leaderboard

* Preview groups

* Fix chat width changing

* Solid reported weapons

* Clearer cancel requested header

* Dynamic revalidates

* spDiff from memento

* (Partly) Revert "Remove screen banning"

This reverts commit 076cabfbfa.

* Screen indicators in looking view

* FC i18n

* noscreen = 0

* E2E test

* E2E 2
2024-02-24 12:07:17 +02:00

39 lines
1.2 KiB
TypeScript

import { useFetcher } from "@remix-run/react";
import { useTranslation } from "react-i18next";
import { Input } from "~/components/Input";
import { Label } from "~/components/Label";
import { SubmitButton } from "~/components/SubmitButton";
import { FRIEND_CODE_REGEXP_PATTERN } from "~/features/sendouq/q-constants";
import { SENDOUQ_PAGE } from "~/utils/urls";
export function FriendCodeInput({ friendCode }: { friendCode?: string }) {
const fetcher = useFetcher();
const { t } = useTranslation(["common"]);
return (
<fetcher.Form method="post" action={SENDOUQ_PAGE}>
<div className="stack sm horizontal items-end">
<div>
<Label htmlFor="friendCode">{t("common:fc.title")}</Label>
{friendCode ? (
<div className="font-bold">SW-{friendCode}</div>
) : (
<Input
leftAddon="SW-"
id="friendCode"
name="friendCode"
pattern={FRIEND_CODE_REGEXP_PATTERN}
placeholder="1234-5678-9012"
/>
)}
</div>
{!friendCode ? (
<SubmitButton _action="ADD_FRIEND_CODE" state={fetcher.state}>
Save
</SubmitButton>
) : null}
</div>
</fetcher.Form>
);
}