34 lines
997 B
TypeScript
34 lines
997 B
TypeScript
import { usePage } from "@inertiajs/react";
|
|
import EnumSelect from "./EnumSelect";
|
|
import { LaravelEnum } from "@/back/types/global";
|
|
import str from "@/hooks/use-string";
|
|
import useTrans from "@/hooks/use-translations";
|
|
|
|
interface Props {
|
|
name: string;
|
|
selected: number;
|
|
required: boolean;
|
|
label: string;
|
|
setData: (name: string, value: number | null) => void;
|
|
}
|
|
|
|
const StaticRouteSelect = (props: Props) => {
|
|
const { name, selected, required, label, setData } = props;
|
|
const contactFormRoutes = usePage().props.contactFormRoutes as LaravelEnum|null;
|
|
|
|
if (!contactFormRoutes) return str(useTrans('back.static_route.no_route_defined')).ucFirst().value();
|
|
|
|
return (
|
|
<EnumSelect
|
|
name={name}
|
|
label={label}
|
|
placeholder="Select value"
|
|
selected={selected}
|
|
options={contactFormRoutes}
|
|
setData={setData}
|
|
required={required}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export default StaticRouteSelect;
|