UNPKG

naim-firebase-auth-wrapper

Version:

React components and hooks for Firebase Authentication and Firestore with Mantine UI

39 lines 1.76 kB
'use client'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useState } from 'react'; import { TextInput, Button, Paper, Title, Stack } from '@mantine/core'; import { useAuth } from '../hooks/useAuth'; import { createOrganization } from '../services/firestore'; export const CreateOrganization = ({ onSuccess, onError }) => { const { user } = useAuth(); const [name, setName] = useState(''); const [loading, setLoading] = useState(false); const handleSubmit = async (e) => { e.preventDefault(); if (!user || !name.trim()) return; setLoading(true); try { const orgId = await createOrganization({ name: name.trim(), ownerId: user.uid, members: [{ userId: user.uid, role: 'owner', joinedAt: new Date() }] }); onSuccess?.(orgId); setName(''); } catch (error) { console.error('Error creating organization:', error); onError?.(error); } finally { setLoading(false); } }; return (_jsxs(Paper, { radius: "md", p: "xl", withBorder: true, children: [_jsx(Title, { order: 2, mb: "md", children: "Create Organization" }), _jsx("form", { onSubmit: handleSubmit, children: _jsxs(Stack, { children: [_jsx(TextInput, { required: true, label: "Organization Name", placeholder: "Enter organization name", value: name, onChange: (e) => setName(e.target.value) }), _jsx(Button, { type: "submit", loading: loading, disabled: !name.trim(), children: "Create" })] }) })] })); }; //# sourceMappingURL=CreateOrganization.js.map