mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-29 16:30:24 +08:00
26 lines
663 B
TypeScript
26 lines
663 B
TypeScript
import { Select, SelectProps } from "@chakra-ui/react";
|
|
import { forwardRef } from "react";
|
|
import { ElementOf } from "src/types/utils";
|
|
|
|
export const roles = ["general", "admin", "banned"] as const;
|
|
export type Role = ElementOf<typeof roles>;
|
|
|
|
type RoleSelectProps = Omit<SelectProps, "defaultValue"> & {
|
|
defaultValue?: Role;
|
|
value?: Role;
|
|
};
|
|
|
|
export const RoleSelect = forwardRef<HTMLSelectElement, RoleSelectProps>((props, ref) => {
|
|
return (
|
|
<Select {...props} ref={ref}>
|
|
{roles.map((role) => (
|
|
<option value={role} key={role}>
|
|
{role}
|
|
</option>
|
|
))}
|
|
</Select>
|
|
);
|
|
});
|
|
|
|
RoleSelect.displayName = "RoleSelect";
|