Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

AutoSettleDaysField.tsx

33 lines920 Bytes

1import { useGT, plural, part } from "gt-react-native";
2import {
3 MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
4 MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
5} from "@t3tools/contracts";
6import type { ComponentProps } from "react";
7import { NumberField } from "../../../components/ui/NumberField";
8​
9export type AutoSettleDaysFieldProps = Pick<
10 ComponentProps<typeof NumberField>,
11 "value" | "onValueChange" | "disabled"
12>;
13​
14export function AutoSettleDaysField(props: AutoSettleDaysFieldProps) {
15 const gt = useGT();
16 return (
17 <NumberField
18 {...props}
19 min={MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS}
20 max={MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS}
21 label={gt`Days before auto-settle`}
22 formatValue={(value) =>
23 gt`${plural(
24 { count: value },
25 {
26 one: part`${{ count: value }} day`,
27 other: part`${{ count: value }} days`,
28 },
29 )}`
30 }
31 />
32 );