UNPKG

@payloadcms/plugin-multi-tenant

Version:
43 lines (42 loc) 1.36 kB
'use client'; import { jsx as _jsx } from "react/jsx-runtime"; import { getTranslation } from '@payloadcms/translations'; import { SelectInput, useTranslation } from '@payloadcms/ui'; import React from 'react'; import { useTenantSelection } from '../../providers/TenantSelectionProvider/index.client.js'; import './index.scss'; export const TenantSelector = ({ label, viewType })=>{ const { options, selectedTenantID, setTenant } = useTenantSelection(); const { i18n } = useTranslation(); const handleChange = React.useCallback((option)=>{ if (option && 'value' in option) { setTenant({ id: option.value, refresh: true }); } else { setTenant({ id: undefined, refresh: true }); } }, [ setTenant ]); if (options.length <= 1) { return null; } return /*#__PURE__*/ _jsx("div", { className: "tenant-selector", children: /*#__PURE__*/ _jsx(SelectInput, { isClearable: viewType === 'list', label: getTranslation(label, i18n), name: "setTenant", onChange: handleChange, options: options, path: "setTenant", value: selectedTenantID }) }); }; //# sourceMappingURL=index.js.map