All files / packages/app/features/add-peer add-peer-screen.tsx

100% Statements 7/7
100% Branches 0/0
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                        10x 22x 22x 22x   22x     1x       22x                    
import React from "react";
 
import { useTranslation } from "react-i18next";
 
import { PageHeader } from "~app/components/page-header";
import { NavigationContext } from "~app/contexts/navigation-context";
import { EmailVerificationCard } from "~app/features/email-verification/email-verification-card";
import type { TRPCMutationOutput } from "~app/trpc";
import { BackLink } from "~components/back-link";
 
import { AddPeerForm } from "./add-peer-form";
 
export const AddPeerScreen = () => {
	const { t } = useTranslation("peers");
	const { useNavigate } = React.use(NavigationContext);
	const navigate = useNavigate();
 
	const onSuccess = React.useCallback<
		(response: TRPCMutationOutput<"peers.add">) => void
	>(
		({ id }) => navigate({ to: "/peers/$id", params: { id }, replace: true }),
		[navigate],
	);
 
	return (
		<>
			<PageHeader startContent={<BackLink to="/peers" />}>
				{t("add.header")}
			</PageHeader>
			<EmailVerificationCard />
			<AddPeerForm onSuccess={onSuccess} />
		</>
	);
};