import React, { useState } from 'react'; import { authenticationService, organizationService } from '@/_services'; import AlertDialog from '@/_ui/AlertDialog'; import { toast } from 'react-hot-toast'; import { useTranslation } from 'react-i18next'; export const CreateOrganization = ({ showCreateOrg, setShowCreateOrg }) => { const [isCreating, setIsCreating] = useState(false); const [newOrgName, setNewOrgName] = useState(''); const { t } = useTranslation(); const createOrganization = () => { if (!(newOrgName && newOrgName.trim())) { toast.error('Workspace name can not be empty.', { position: 'top-center', }); return; } setIsCreating(true); organizationService.createOrganization(newOrgName).then( (data) => { setIsCreating(false); authenticationService.updateCurrentUserDetails(data); window.location.href = ''; }, () => { setIsCreating(false); toast.error('Error while creating workspace', { position: 'top-center', }); } ); }; return ( setShowCreateOrg(false)} title={t('header.organization.createWorkspace', 'Create workspace')} >
setNewOrgName(e.target.value)} className="form-control" placeholder={t('header.organization.workspaceName', 'workspace name')} disabled={isCreating} maxLength={25} />
); };