import { SearchWayItemType } from "@/app/_lib/data/search";
import { mRequest } from "@/app/_lib/request";
import { useRequest } from "ahooks";
import { Checkbox, Space } from "antd";
import { useMemo } from "react";

export default function SearchSelect({ value, onChange }: { value?: string[]; onChange?: (e: any) => void }) {
    const { data } = useRequest(() => mRequest<{
        list: SearchWayItemType[]
    }>('GET', '/api/search?page=1&pageSize=999'))
    const options = useMemo(() => {
        return data?.list.map(val => ({
            label: val.fullName,
            value: val._id
        }))
    }, [data])

    return (
        <Checkbox.Group
            value={value}
            options={options}
            onChange={onChange}
        />
    )
}