gear-orders/web/vite/src/SubOrderSets.tsx

46 lines
1.3 KiB
TypeScript
Raw Normal View History

2026-01-29 21:30:51 +00:00
import React from "react";
2026-03-08 18:44:59 +00:00
import { Params, useLoaderData, useParams, Link } from "react-router";
import { OrderSetProps, OrderSets } from "./OrderSets";
2026-03-14 21:17:41 +00:00
import { ProfileVerification } from "./ProfileVerification";
import { Title } from "@mantine/core";
2026-01-29 21:30:51 +00:00
export const subOrderSetsLoader = async ({
params: { username },
}: {
params: Params<string>;
}) => fetch(`/api/orders/${username}/sets`).then((response) => response.json());
2026-01-29 21:30:51 +00:00
export const SubOrderSets: React.FC = () => {
const { username: sub_username } = useParams();
const orderSets = useLoaderData<OrderSetProps["orderSets"]>();
2026-01-30 19:15:20 +00:00
2026-03-14 21:17:41 +00:00
const [profile, setProfile] = React.useState<UserProfile | null>(null);
React.useEffect(() => {
fetch(`/api/subs/${sub_username}`)
.then((response) => response.json())
.then(setProfile);
}, [sub_username]);
2026-01-29 21:30:51 +00:00
return (
2026-03-14 21:17:41 +00:00
<>
<OrderSets
username={sub_username}
orderSets={orderSets}
linkBack={<Link to={`/dashboard/`}>Return to dashboard</Link>}
/>
{profile ? (
<>
<Title order={1} mb="md">
Sub Profile
</Title>
<ProfileVerification
username={sub_username}
verify_mastodon_favorite={profile.verify_mastodon_favorite}
verify_delay={profile.verify_delay}
/>
</>
) : null}
</>
2026-01-29 21:30:51 +00:00
);
};