All files / pages/admin/CreateUser/components TypeSelector.tsx

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

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 363x 3x             3x 10x   10x         10x             21x                     3x  
import React, { useRef } from "react";
import { Select } from "antd";
 
interface SelectorProps {
  value?: string;
  onChange?: (value: string) => void;
}
 
const TypeSelector: React.FC<SelectorProps> = ({ value, onChange }) => {
  const dropdownRef = useRef<HTMLDivElement | null>(null);
 
  const userTypeOptions = [
    { label: "Staff", value: "USER" },
    { label: "Admin", value: "ADMIN" },
  ];
 
  return (
    <Select
      value={value}
      defaultValue="USER"
      onChange={onChange}
      style={{ maxWidth: 400 }}
      dropdownRender={(menu) => (
        <>
          <div ref={dropdownRef} style={{ maxHeight: 108, overflowY: "auto" }}>
            {menu}
          </div>
        </>
      )}
      options={userTypeOptions}
    />
  );
};
 
export default TypeSelector;