import { observer } from "mobx-react"; import React from "react"; import { useTranslation } from "react-i18next"; import { toast } from "sonner"; import { AvatarSize } from "~/components/Avatar"; import CollectionIcon from "~/components/Icons/CollectionIcon"; import InputSelect, { Option } from "~/components/InputSelect"; import TeamLogo from "~/components/TeamLogo"; import useCurrentTeam from "~/hooks/useCurrentTeam"; import usePolicy from "~/hooks/usePolicy"; import useRequest from "~/hooks/useRequest"; import useStores from "~/hooks/useStores"; import Label from "./Label"; type Props = { /** Collection ID to select by default. */ defaultCollectionId?: string | null; /** Callback to be called when a collection is selected. */ onSelect: (collectionId: string | null) => void; }; const SelectLocation = ({ defaultCollectionId, onSelect }: Props) => { const { t } = useTranslation(); const team = useCurrentTeam(); const { collections, policies } = useStores(); const can = usePolicy(team); const { loading, error } = useRequest( React.useCallback(async () => { if (!collections.isLoaded) { await collections.fetchAll({ limit: 100, }); } }, [collections]) ); const workspaceOption: Option | null = can.createTemplate ? { label: (