Spaces:
Paused
Paused
Download frontend/apps/internal/src/components/WorkspaceSettings.tsx from TeamError404/nexus: direct link, hf CLI and curl.
- Browser
- Download file 7 kB
-
https://huggingface.co/spaces/TeamError404/nexus/resolve/main/frontend/apps/internal/src/components/WorkspaceSettings.tsx
- Command line
-
hf download hf://spaces/TeamError404/nexus/frontend/apps/internal/src/components/WorkspaceSettings.tsx
-
curl -L -o WorkspaceSettings.tsx https://huggingface.co/spaces/TeamError404/nexus/resolve/main/frontend/apps/internal/src/components/WorkspaceSettings.tsx
7 kB
| import React, { useState } from 'react'; | |
| import { useUsers, useWorkspaces } from '@nexus/shared'; | |
| import styles from './WorkspaceSettings.module.css'; | |
| interface WorkspaceSettingsProps { | |
| workspaceId?: string; | |
| } | |
| export const WorkspaceSettings: React.FC<WorkspaceSettingsProps> = ({ workspaceId }) => { | |
| const { users, loading: usersLoading, addUser } = useUsers(workspaceId); | |
| const { workspaces } = useWorkspaces(); | |
| const [isModalOpen, setIsModalOpen] = useState(false); | |
| const [formData, setFormData] = useState({ email: '', fullName: '', role: 'customer_user', password: 'TemporaryPassword123!' }); | |
| const [formError, setFormError] = useState<string | null>(null); | |
| const [isSubmitting, setIsSubmitting] = useState(false); | |
| const currentWorkspace = workspaces.find(w => w.id === workspaceId) || workspaces[0]; | |
| const handleAddMember = async (e: React.FormEvent) => { | |
| e.preventDefault(); | |
| setIsSubmitting(true); | |
| setFormError(null); | |
| try { | |
| await addUser({ | |
| email: formData.email, | |
| full_name: formData.fullName, | |
| role: formData.role, | |
| password: formData.password | |
| }); | |
| setIsModalOpen(false); | |
| setFormData({ email: '', fullName: '', role: 'customer_user', password: 'TemporaryPassword123!' }); | |
| } catch (err: any) { | |
| setFormError(err.message); | |
| } finally { | |
| setIsSubmitting(false); | |
| } | |
| }; | |
| return ( | |
| <div className={styles.container}> | |
| <header className={styles.header}> | |
| <h1 className={styles.workspaceName}>{currentWorkspace?.name || 'Workspace Settings'}</h1> | |
| <p className={styles.description}> | |
| Manage your organization's identity, team, and security settings. | |
| Use this panel to control access and oversee your dedicated support environment. | |
| </p> | |
| </header> | |
| <section className={styles.teamSection}> | |
| <div className={styles.sectionHeader}> | |
| <h2 className={styles.sectionTitle}>Workspace Team</h2> | |
| <button className={styles.addBtn} onClick={() => setIsModalOpen(true)}> | |
| <span>+</span> Add Member | |
| </button> | |
| </div> | |
| <div className={styles.tableCard}> | |
| <table className={styles.table}> | |
| <thead> | |
| <tr> | |
| <th className={styles.th}>Member</th> | |
| <th className={styles.th}>Role</th> | |
| <th className={styles.th}>Status</th> | |
| <th className={styles.th}></th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| {usersLoading && users.length === 0 ? ( | |
| <tr><td colSpan={4} className={styles.td}>Synchronizing team data...</td></tr> | |
| ) : users.length === 0 ? ( | |
| <tr><td colSpan={4} className={styles.td}>No members found in this workspace.</td></tr> | |
| ) : ( | |
| users.map(user => ( | |
| <tr key={user.id}> | |
| <td className={styles.td}> | |
| <div className={styles.memberCell}> | |
| <div className={styles.avatar}>{user.full_name?.slice(0,1).toUpperCase() || user.email.slice(0,1).toUpperCase()}</div> | |
| <div className={styles.memberInfo}> | |
| <span className={styles.memberName}>{user.full_name}</span> | |
| <span className={styles.memberEmail}>{user.email}</span> | |
| </div> | |
| </div> | |
| </td> | |
| <td className={styles.td}> | |
| <span className={`${styles.roleBadge} ${user.role.includes('admin') ? styles.roleAdmin : ''}`}> | |
| {user.role.replace('_', ' ')} | |
| </span> | |
| </td> | |
| <td className={styles.td}> | |
| <div className={styles.statusCell}> | |
| <span className={styles.statusDot} /> | |
| Active Member | |
| </div> | |
| </td> | |
| <td className={styles.td} style={{ textAlign: 'right' }}> | |
| <button className={styles.actionBtn} style={{ background: 'none', border: 'none', cursor: 'pointer', color: '#94a3b8' }}>⋯</button> | |
| </td> | |
| </tr> | |
| )) | |
| )} | |
| </tbody> | |
| </table> | |
| </div> | |
| </section> | |
| {/* Add Member Modal */} | |
| {isModalOpen && ( | |
| <div className={styles.modalOverlay} onClick={() => setIsModalOpen(false)}> | |
| <div className={styles.modal} onClick={e => e.stopPropagation()}> | |
| <h2 className={styles.modalTitle}>Add Team Member</h2> | |
| <p className={styles.modalSub}>Grant workspace access to a new team member.</p> | |
| <form onSubmit={handleAddMember}> | |
| <div className={styles.formGroup}> | |
| <label className={styles.label}>Full Name</label> | |
| <input | |
| className={styles.input} | |
| placeholder="John Doe" | |
| required | |
| value={formData.fullName} | |
| onChange={e => setFormData({...formData, fullName: e.target.value})} | |
| /> | |
| </div> | |
| <div className={styles.formGroup}> | |
| <label className={styles.label}>Email Address</label> | |
| <input | |
| className={styles.input} | |
| type="email" | |
| placeholder="john@organization.com" | |
| required | |
| value={formData.email} | |
| onChange={e => setFormData({...formData, email: e.target.value})} | |
| /> | |
| </div> | |
| <div className={styles.formGroup}> | |
| <label className={styles.label}>Workspace Role</label> | |
| <select | |
| className={styles.select} | |
| value={formData.role} | |
| onChange={e => setFormData({...formData, role: e.target.value})} | |
| > | |
| <option value="customer_user">Customer User</option> | |
| <option value="customer_admin">Customer Admin</option> | |
| <option value="3sc_agent">SC Agent (Staff)</option> | |
| <option value="3sc_lead">SC Lead (Staff)</option> | |
| <option value="3sc_admin">Co-Admin (Staff)</option> | |
| </select> | |
| </div> | |
| {formError && <div className={styles.error}>{formError}</div>} | |
| <div className={styles.modalActions}> | |
| <button type="button" className={styles.cancelBtn} onClick={() => setIsModalOpen(false)}>Cancel</button> | |
| <button type="submit" className={styles.submitBtn} disabled={isSubmitting}> | |
| {isSubmitting ? 'Creating...' : 'Create Member'} | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| )} | |
| </div> | |
| ); | |
| }; | |