Spaces:
Paused
Paused
File size: 30,830 Bytes
0e37978 9483939 8ad9c72 9483939 5eb4857 9483939 fdde098 9483939 fdde098 5eb4857 b1473eb 5eb4857 9b23c2b f3a0c24 5eb4857 9b23c2b b1473eb 5eb4857 f3a0c24 5eb4857 9b23c2b b1473eb 235f8ef 5eb4857 b1473eb 5eb4857 b1473eb 235f8ef 5eb4857 b1473eb 5eb4857 b595698 5eb4857 0e37978 5eb4857 9483939 fb1a28a 9483939 5eb4857 9483939 a4e1f80 9483939 b1473eb 9483939 33ef5cd 5eb4857 a4e1f80 fb1a28a a4e1f80 9b23c2b a4e1f80 9b23c2b a4e1f80 9b23c2b a4e1f80 9b23c2b a6dd232 9b23c2b a4e1f80 9b23c2b a4e1f80 9b23c2b a4e1f80 9b23c2b a4e1f80 9b23c2b a4e1f80 9b23c2b a4e1f80 b1473eb 5eb4857 33ef5cd 9483939 fb1a28a 9483939 33ef5cd 812037a fb1a28a 812037a 9483939 5eb4857 30b6833 b1473eb 9483939 633bcc2 9483939 fb1a28a 633bcc2 9483939 633bcc2 9483939 633bcc2 5eb4857 33ef5cd 5eb4857 9483939 b1473eb 9483939 5eb4857 9483939 5eb4857 fb1a28a b1473eb 33ef5cd 5eb4857 9483939 5eb4857 9483939 5eb4857 9483939 5eb4857 9483939 b595698 5eb4857 b1473eb fb1a28a b1473eb b595698 b1473eb fb1a28a b1473eb 5eb4857 b1473eb eddb8ae b1473eb eddb8ae b1473eb eddb8ae b1473eb eddb8ae b1473eb eddb8ae b1473eb eddb8ae b1473eb fb1a28a b1473eb eddb8ae b1473eb eddb8ae b1473eb eddb8ae 9483939 b1473eb 9483939 eddb8ae 9483939 8ad9c72 eddb8ae 8ad9c72 b1473eb eddb8ae b1473eb eddb8ae b1473eb fb1a28a b1473eb eddb8ae b1473eb eddb8ae b1473eb eddb8ae b1473eb 9483939 b1473eb eddb8ae 8ad9c72 b1473eb eddb8ae b1473eb fb1a28a 5eb4857 b1473eb eddb8ae b1473eb fb1a28a b1473eb eddb8ae b1473eb eddb8ae b1473eb eddb8ae b1473eb 5eb4857 9483939 b1473eb 9483939 5eb4857 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | import React, { useState } from 'react';
import { api, useWorkspace, useUsers } from '@nexus/shared';
import {
UserPlus,
Shield,
ShieldCheck,
X,
Mail,
Lock,
Users,
RefreshCcw,
ChevronDown
} from 'lucide-react';
const COLORS = {
brand: "var(--primary)",
border: "var(--border-subtle)",
bg: "var(--bg-card)",
text: "var(--text-main)",
muted: "var(--text-muted)",
success: "var(--success)",
error: "var(--error)",
};
const TEAM_OPTIONS = ["ENGINEERING", "FINANCE", "SUCCESS", "ACCOUNT", "SECURITY", "COMPLIANCE", "GENERAL", "OTHER"];
export const WorkspaceView: React.FC<{ user: any }> = ({ user }) => {
const { workspace, loading: workspaceLoading, refresh: refreshWorkspace } = useWorkspace();
const { users: members, loading: usersLoading, refresh: refreshUsers, addUser, loaded: usersLoaded } = useUsers();
// Branding State
const [brandingLogo, setBrandingLogo] = useState(workspace?.branding?.logo_url || '');
const [brandingColor, setBrandingColor] = useState(workspace?.branding?.colors?.primary || '#7c3aed');
const [brandingSubmitting, setBrandingSubmitting] = useState(false);
// Synchronize state when workspace loads
React.useEffect(() => {
if (workspace?.branding) {
setBrandingLogo(workspace.branding.logo_url || '');
setBrandingColor(workspace.branding.colors?.primary || '#7c3aed');
}
}, [workspace]);
// Provisioning State
const [modalType, setModalType] = useState<'create' | 'edit' | null>(null);
const [editingUser, setEditingUser] = useState<any>(null);
const [form, setForm] = useState({ email: '', full_name: '', password: '', role: 'customer_user', team: 'GENERAL' });
const [submitting, setSubmitting] = useState(false);
const isAdmin = user.role.includes('admin');
const isInitialLoading = (workspaceLoading && !workspace) || (usersLoading && !usersLoaded);
const handleUpdateBranding = async () => {
setBrandingSubmitting(true);
try {
await api.patch('/workspace/', {
workspace_id: workspace?.id,
branding: {
...workspace?.branding,
logo_url: brandingLogo,
colors: {
...workspace?.branding?.colors,
primary: brandingColor
}
}
});
sessionStorage.removeItem('nexus_active_ws_v1');
await refreshWorkspace(workspace?.id);
} catch (err) {
console.error("Branding update failed:", err);
} finally {
setBrandingSubmitting(false);
}
};
const handleProvision = async (e: React.FormEvent) => {
e.preventDefault();
setSubmitting(true);
try {
if (modalType === 'edit' && editingUser) {
await api.patch(`/users/${editingUser.id}/`, {
full_name: form.full_name,
role: form.role,
team: form.team
});
} else {
await addUser(form);
}
setForm({ email: '', full_name: '', password: '', role: 'customer_user', team: 'GENERAL' });
setModalType(null);
setEditingUser(null);
refreshUsers();
} catch (err) {
console.error("Provisioning failed:", err);
} finally {
setSubmitting(false);
}
};
const openEdit = (m: any) => {
setEditingUser(m);
setForm({
email: m.email,
full_name: m.full_name,
password: '', // Hidden in edit
role: m.role,
team: m.team || 'GENERAL'
});
setModalType('edit');
};
const removeMember = async (memberId: string) => {
if (!window.confirm("Are you sure you want to revoke this member's access? They will be marked as deactivated in this workspace.")) return;
try {
await api.delete(`/users/${memberId}/`);
refreshUsers();
} catch (err) {
console.error("Failed to remove member:", err);
}
};
if (isInitialLoading) return (
<div style={{ padding: 120, textAlign: 'center', background: 'var(--bg-dark)', height: '100vh' }}>
<div className="spin" style={{ width: 40, height: 40, border: '3px solid var(--primary)', borderTopColor: 'transparent', borderRadius: '50%', marginInline: 'auto', marginBottom: 24 }} />
<div className="metadata" style={{ fontSize: 13, letterSpacing: '0.2em', fontWeight: 900, color: 'var(--text-muted)' }}>INITIALIZING WORKSPACE...</div>
</div>
);
return (
<div style={{ padding: "80px 64px", maxWidth: 1600, margin: "0 auto", fontFamily: "var(--font-sans)", background: "var(--bg-dark)", minHeight: "100vh" }}>
{/* Main Header */}
<div style={{ marginBottom: 80, position: 'relative' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 16, marginBottom: 12 }}>
<div style={{ width: 32, height: 2, background: 'var(--primary)' }} />
<div className="metadata" style={{ color: 'var(--primary)', letterSpacing: '0.2em', fontWeight: 900 }}>WORKSPACE OVERVIEW</div>
</div>
<h1 style={{ fontSize: 48, fontWeight: 800, color: COLORS.text, marginBottom: 20, fontFamily: 'var(--font-heading)', letterSpacing: '-0.04em' }}>{workspace?.name?.toUpperCase()}</h1>
<p style={{ color: COLORS.muted, fontSize: 20, fontWeight: 500, maxWidth: 900, lineHeight: 1.6 }}>Manage your organization's team members, roles, and access permissions from this central dashboard.</p>
</div>
{/* Identity & Branding Section (Admin Only) */}
{isAdmin && (
<div style={{ marginBottom: 64 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 16, marginBottom: 32 }}>
<div style={{ padding: 12, borderRadius: 12, background: 'var(--bg-hover)', border: '1px solid var(--border-subtle)', color: 'var(--primary)' }}>
<ShieldCheck size={24} />
</div>
<h2 style={{ fontSize: 28, fontWeight: 800, color: COLORS.text, margin: 0, fontFamily: "var(--font-heading)", letterSpacing: '-0.02em' }}>Identity & Branding</h2>
</div>
<div className="glass-card" style={{ background: "var(--bg-card)", border: `1.5px solid var(--border-subtle)`, borderRadius: 32, padding: 40, boxShadow: "var(--shadow-2xl)" }}>
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 40, alignItems: 'start' }}>
<div style={{ display: 'flex', flexDirection: 'column', gap: 24 }}>
<div>
<label className="metadata" style={{ marginBottom: 12, display: 'block', fontWeight: 800, letterSpacing: '0.05em', fontSize: 10, color: COLORS.muted }}>BRANDING LOGO URL</label>
<div style={{ display: 'flex', gap: 16 }}>
<input
value={brandingLogo}
onChange={e => setBrandingLogo(e.target.value)}
className="input-focus"
placeholder="https://example.com/logo.png"
style={{ flex: 1, padding: "18px 24px", borderRadius: 16, border: `1.5px solid var(--border-subtle)`, fontSize: 16, outline: "none", background: "var(--bg-dark)", color: COLORS.text, boxSizing: "border-box", fontWeight: 600 }}
/>
<div style={{ width: 58, height: 58, borderRadius: 16, background: 'var(--bg-dark)', border: '1.5px solid var(--border-subtle)', display: 'flex', alignItems: 'center', justifyContent: 'center', overflow: 'hidden' }}>
{brandingLogo ? (
<img src={brandingLogo} alt="Logo" style={{ maxWidth: '80%', maxHeight: '80%', objectFit: 'contain' }} />
) : (
<Users size={20} style={{ opacity: 0.2 }} />
)}
</div>
</div>
</div>
<div>
<label className="metadata" style={{ marginBottom: 12, display: 'block', fontWeight: 800, letterSpacing: '0.05em', fontSize: 10, color: COLORS.muted }}>OFFICIAL WORKSPACE NAME</label>
<input
defaultValue={workspace?.name}
onBlur={async (e) => {
if (e.target.value && e.target.value !== workspace?.name) {
try {
await api.patch('/workspace/', { name: e.target.value });
sessionStorage.removeItem('nexus_active_ws_v1');
refreshWorkspace(workspace?.id);
} catch (err) { console.error(err); }
}
}}
className="input-focus"
placeholder="e.g. ACME CORP"
style={{ width: "100%", padding: "18px 24px", borderRadius: 16, border: `1.5px solid var(--border-subtle)`, fontSize: 16, outline: "none", background: "var(--bg-dark)", color: COLORS.text, boxSizing: "border-box", fontWeight: 700, fontFamily: 'var(--font-heading)' }}
/>
</div>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 24 }}>
<div>
<label className="metadata" style={{ marginBottom: 12, display: 'block', fontWeight: 800, letterSpacing: '0.05em', fontSize: 10, color: COLORS.muted }}>WORKSPACE THEME COLOR</label>
<div style={{ display: 'flex', alignItems: 'center', gap: 16, background: 'var(--bg-dark)', padding: '8px 16px', borderRadius: 16, border: '1.5px solid var(--border-subtle)' }}>
<input
type="color"
value={brandingColor}
onChange={e => {
setBrandingColor(e.target.value);
document.documentElement.style.setProperty('--primary', e.target.value);
document.documentElement.style.setProperty('--banner-gradient', `linear-gradient(135deg, ${e.target.value} 0%, ${e.target.value}dd 100%)`);
}}
style={{ width: 42, height: 42, border: 'none', borderRadius: 10, cursor: 'pointer', background: 'none' }}
/>
<input
value={brandingColor}
onChange={e => {
setBrandingColor(e.target.value);
if (e.target.value.startsWith('#') && e.target.value.length === 7) {
document.documentElement.style.setProperty('--primary', e.target.value);
}
}}
style={{ background: 'none', border: 'none', color: COLORS.text, fontSize: 16, fontWeight: 700, outline: 'none', width: 100, textTransform: 'uppercase', fontFamily: 'var(--font-mono)' }}
/>
</div>
</div>
<button
onClick={handleUpdateBranding}
disabled={brandingSubmitting}
className="hover-lift"
style={{
width: '100%',
padding: "18px",
background: "var(--primary)",
color: "var(--bg-card)",
border: "none",
borderRadius: 18,
fontSize: 14,
fontWeight: 900,
cursor: brandingSubmitting ? "wait" : "pointer",
textTransform: 'uppercase',
letterSpacing: '0.1em',
boxShadow: '0 10px 25px var(--primary-glow)',
fontFamily: "var(--font-heading)",
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: 12,
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
opacity: brandingSubmitting ? 0.7 : 1
}}
>
{brandingSubmitting ? <RefreshCcw size={18} className="spin" /> : <ShieldCheck size={18} />}
{brandingSubmitting ? "Saving Branding..." : "Save Identity Changes"}
</button>
</div>
</div>
<div style={{ marginTop: 32, padding: '16px 24px', background: 'var(--bg-dark)', borderRadius: 16, border: '1px solid var(--border-subtle)', display: 'flex', alignItems: 'center', gap: 12 }}>
<Shield size={16} color="var(--primary)" />
<span style={{ fontSize: 12, color: COLORS.muted, fontWeight: 500 }}>Identity changes sync across all member portals and analytical reports in real-time.</span>
</div>
</div>
</div>
)}
<div style={{ gap: 64, alignItems: "start" }}>
{/* Member Directory Section */}
<div style={{ width: "100%" }}>
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 40 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
<div style={{ padding: 12, borderRadius: 12, background: 'var(--bg-hover)', border: '1px solid var(--border-subtle)', color: 'var(--primary)' }}>
<Users size={24} />
</div>
<h2 style={{ fontSize: 28, fontWeight: 800, color: COLORS.text, margin: 0, fontFamily: "var(--font-heading)", letterSpacing: '-0.02em' }}>Workspace Members</h2>
<button
onClick={() => refreshUsers()}
disabled={usersLoading}
className="hover-lift"
style={{
background: usersLoading ? 'var(--bg-dark)' : 'var(--primary-glow)',
border: `1.5px solid ${usersLoading ? 'var(--border-subtle)' : 'var(--primary-glow)'}`,
color: 'var(--primary)',
width: 40, height: 40, borderRadius: 12,
display: 'flex', alignItems: 'center', justifyContent: 'center',
cursor: usersLoading ? 'wait' : 'pointer',
transition: 'all 0.3s'
}}
title="Bypass Cache & Refresh List"
>
<RefreshCcw size={18} className={usersLoading ? "spin" : ""} />
</button>
</div>
{isAdmin ? (
<button
onClick={() => {
setForm({ email: '', full_name: '', password: '', role: 'customer_user', team: 'GENERAL' });
setModalType('create');
}}
className="hover-lift"
style={{
padding: "16px 36px",
background: "var(--primary)",
color: "var(--bg-card)",
border: "none",
borderRadius: 18,
fontSize: 14,
fontWeight: 900,
cursor: "pointer",
textTransform: 'uppercase',
letterSpacing: '0.1em',
boxShadow: '0 10px 25px var(--primary-glow)',
fontFamily: "var(--font-heading)",
display: 'flex',
alignItems: 'center', gap: 12
}}
>
<UserPlus size={18} /> Add Member
</button>
) : (
<div className="metadata" style={{ display: 'flex', alignItems: 'center', gap: 10, padding: "12px 24px", background: "var(--bg-card)", borderRadius: 14, fontSize: 11, border: '1.5px solid var(--border-subtle)', fontWeight: 900 }}>
<Shield size={14} /> ADMIN RESTRICTION ACTIVE
</div>
)}
</div>
<div className="glass-card" style={{ background: "var(--bg-card)", border: `1.5px solid var(--border-subtle)`, borderRadius: 32, overflow: "hidden", boxShadow: "var(--shadow-2xl)" }}>
<table style={{ width: "100%", borderCollapse: "collapse", textAlign: "left" }}>
<thead>
<tr style={{ background: "var(--bg-dark)", borderBottom: `1.5px solid var(--border-subtle)` }}>
<th className="metadata" style={{ padding: "28px 32px", fontSize: 10, letterSpacing: '0.15em', fontWeight: 900 }}>MEMBER INFO</th>
<th className="metadata" style={{ padding: "28px 32px", fontSize: 10, letterSpacing: '0.15em', fontWeight: 900, width: 220 }}>ACCESS ROLE</th>
<th className="metadata" style={{ padding: "28px 32px", fontSize: 10, letterSpacing: '0.15em', fontWeight: 900 }}>STATUS</th>
<th className="metadata" style={{ padding: "28px 32px", fontSize: 10, letterSpacing: '0.15em', fontWeight: 900, textAlign: "right" }}>ACTIONS</th>
</tr>
</thead>
<tbody>
{members.map(member => (
<tr key={member.id} className="hover-lift" style={{ borderBottom: `1.5px solid var(--border-subtle)`, transition: 'all 0.3s cubic-bezier(0.19, 1, 0.22, 1)' }}>
<td style={{ padding: "32px" }}>
<div style={{ display: "flex", alignItems: "center", gap: 20 }}>
<div style={{ width: 52, height: 52, borderRadius: 16, background: "var(--bg-dark)", border: '1.5px solid var(--border-subtle)', display: "flex", alignItems: "center", justifyContent: "center", fontWeight: 900, fontSize: 18, color: COLORS.brand, fontFamily: 'var(--font-heading)' }}>
{member.full_name[0].toUpperCase()}
</div>
<div>
<div style={{ fontSize: 17, fontWeight: 700, color: COLORS.text, fontFamily: 'var(--font-heading)' }}>{member.full_name}</div>
<div className="numeric" style={{ fontSize: 13, color: COLORS.muted, fontWeight: 600, letterSpacing: '0.02em', marginTop: 4 }}>{member.email}</div>
</div>
</div>
</td>
<td style={{ padding: "32px" }}>
<span style={{ fontSize: 10, fontWeight: 900, color: COLORS.brand, background: "var(--primary-glow)", padding: "6px 14px", borderRadius: 10, letterSpacing: '0.1em', fontFamily: "var(--font-heading)", border: '1px solid var(--primary)' }}>
{member.role.replace('_', ' ').toUpperCase()}
</span>
</td>
<td style={{ padding: "32px" }}>
<div style={{ display: "flex", alignItems: "center", gap: 12 }}>
<div style={{
width: 10, height: 10, borderRadius: "50%",
background: member.is_active ? COLORS.success : COLORS.muted,
boxShadow: member.is_active ? "0 0 12px var(--success)" : "none"
}} />
<span style={{
fontSize: 13, fontWeight: 700,
color: member.is_active ? COLORS.success : COLORS.muted,
textTransform: "uppercase", letterSpacing: "0.1em", fontFamily: 'var(--font-heading)'
}}>
{member.is_active ? "ACTIVE" : "DEACTIVATED"}
</span>
</div>
</td>
<td style={{ padding: "32px", textAlign: "right" }}>
<div style={{ display: 'flex', gap: 12, justifyContent: 'flex-end' }}>
{isAdmin && (
<button
onClick={() => openEdit(member)}
className="hover-lift"
style={{ background: "var(--primary-glow)", border: "1.5px solid var(--border-subtle)", color: "var(--primary)", fontSize: 10, fontWeight: 900, cursor: "pointer", letterSpacing: "0.15em", padding: '10px 18px', borderRadius: 12, fontFamily: 'var(--font-heading)' }}
>
EDIT
</button>
)}
{isAdmin && member.id !== user.id && member.is_active && (
<button
onClick={() => removeMember(member.id)}
className="hover-lift"
style={{ background: "var(--error-glow)", border: "1.5px solid var(--border-subtle)", color: COLORS.error, fontSize: 10, fontWeight: 900, cursor: "pointer", letterSpacing: "0.15em", padding: '10px 18px', borderRadius: 12, fontFamily: 'var(--font-heading)' }}
>
REVOKE
</button>
)}
</div>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
{modalType && (
<div style={{ position: 'fixed', top: 0, left: 0, width: '100vw', height: '100vh', background: 'rgba(0,0,0,0.85)', backdropFilter: 'blur(10px)', zIndex: 1000, display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 24 }}>
<div className="glass-card" style={{
background: "var(--bg-card)",
width: 'calc(100% - 48px)',
maxWidth: 540,
padding: "36px 40px",
borderRadius: 32,
border: `1.5px solid var(--border-subtle)`,
boxShadow: "0 40px 100px rgba(0,0,0,0.6)",
animation: 'appear 0.4s cubic-bezier(0.16, 1, 0.3, 1)',
position: 'relative',
maxHeight: '85vh',
overflowY: 'auto',
display: 'flex',
flexDirection: 'column'
}}>
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 28, flexShrink: 0 }}>
<div>
<div className="metadata" style={{ color: 'var(--primary)', marginBottom: 4, fontWeight: 900, letterSpacing: '0.15em', fontSize: 10 }}>MEMBER REGISTRATION</div>
<h3 style={{ margin: 0, fontSize: 22, fontWeight: 800, fontFamily: 'var(--font-heading)', letterSpacing: '-0.02em', color: COLORS.text }}>
{modalType === 'edit' ? 'Update Member Profile' : 'Invite New Member'}
</h3>
</div>
<button
onClick={() => setModalType(null)}
className="hover-lift"
style={{ background: "var(--bg-dark)", border: "1.5px solid var(--border-subtle)", width: 36, height: 36, borderRadius: "50%", display: "flex", alignItems: "center", justifyContent: "center", cursor: "pointer", color: COLORS.text, transition: 'all 0.3s' }}
>
<X size={16} />
</button>
</div>
<form onSubmit={handleProvision} style={{ display: "flex", flexDirection: "column", gap: 24 }}>
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 24 }}>
<div>
<label className="metadata" style={{ marginBottom: 10, display: 'block', fontWeight: 800, letterSpacing: '0.05em', fontSize: 10, color: COLORS.muted }}>FULL NAME</label>
<input
required
value={form.full_name}
onChange={e => setForm({...form, full_name: e.target.value})}
placeholder="e.g. John Doe"
className="input-focus"
style={{ width: "100%", padding: "16px 20px", borderRadius: 14, border: `1.5px solid var(--border-subtle)`, fontSize: 15, outline: "none", background: "var(--bg-dark)", color: COLORS.text, boxSizing: "border-box", fontWeight: 600 }}
/>
</div>
<div>
<label className="metadata" style={{ marginBottom: 10, display: 'block', fontWeight: 800, letterSpacing: '0.05em', fontSize: 10, color: COLORS.muted }}>DEPT. TEAM</label>
<div className="select-wrapper">
<select
value={form.team}
onChange={e => setForm({...form, team: e.target.value})}
className="nexus-select"
>
{TEAM_OPTIONS.map(t => <option key={t} value={t}>{t}</option>)}
</select>
<ChevronDown size={14} className="select-chevron" />
</div>
</div>
</div>
<div>
<label className="metadata" style={{ marginBottom: 10, display: 'block', fontWeight: 800, letterSpacing: '0.05em', fontSize: 10, color: COLORS.muted }}>EMAIL ADDRESS</label>
<div style={{ position: 'relative' }}>
<Mail size={16} style={{ position: 'absolute', left: 18, top: '50%', transform: 'translateY(-50%)', color: 'var(--primary)', opacity: 0.5 }} />
<input
required
type="email"
disabled={modalType === 'edit'}
value={form.email}
onChange={e => setForm({...form, email: e.target.value})}
placeholder="user@example.com"
className="input-focus"
style={{ width: "100%", padding: "16px 20px 16px 48px", borderRadius: 14, border: `1.5px solid var(--border-subtle)`, fontSize: 15, outline: "none", background: "var(--bg-dark)", color: modalType === 'edit' ? COLORS.muted : COLORS.text, boxSizing: "border-box", fontWeight: 600 }}
/>
</div>
</div>
{modalType === 'create' && (
<div>
<label className="metadata" style={{ marginBottom: 10, display: 'block', fontWeight: 800, letterSpacing: '0.05em', fontSize: 10, color: COLORS.muted }}>ACCOUNT PASSWORD</label>
<div style={{ position: 'relative' }}>
<Lock size={16} style={{ position: 'absolute', left: 18, top: '50%', transform: 'translateY(-50%)', color: 'var(--primary)', opacity: 0.5 }} />
<input
required
type="password"
value={form.password}
onChange={e => setForm({...form, password: e.target.value})}
placeholder="••••••••••••"
className="input-focus"
style={{ width: "100%", padding: "16px 20px 16px 48px", borderRadius: 14, border: `1.5px solid var(--border-subtle)`, fontSize: 15, outline: "none", background: "var(--bg-dark)", color: COLORS.text, boxSizing: "border-box", fontWeight: 600 }}
/>
</div>
</div>
)}
<div>
<label className="metadata" style={{ marginBottom: 10, display: 'block', fontWeight: 800, letterSpacing: '0.05em', fontSize: 10, color: COLORS.muted }}>ACCESS ROLE</label>
<div className="select-wrapper">
<select
value={form.role}
onChange={e => setForm({...form, role: e.target.value})}
className="nexus-select"
>
<option value="customer_user">Standard User</option>
<option value="customer_admin">Workspace Admin</option>
</select>
<ChevronDown size={14} className="select-chevron" />
</div>
</div>
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16, marginTop: 8, flexShrink: 0 }}>
<button
type="button"
onClick={() => setModalType(null)}
style={{ padding: "18px", background: "var(--bg-dark)", border: "1.5px solid var(--border-subtle)", borderRadius: 16, color: COLORS.text, fontWeight: 900, cursor: "pointer", textTransform: 'uppercase', letterSpacing: '0.1em', fontSize: 13 }}
>
Cancel
</button>
<button
type="submit"
disabled={submitting}
className="hover-lift"
style={{
padding: "18px",
background: "var(--primary)",
color: "var(--bg-card)",
border: "none",
borderRadius: 16,
fontWeight: 900,
cursor: submitting ? "wait" : "pointer",
textTransform: 'uppercase',
letterSpacing: '0.15em',
boxShadow: '0 10px 30px var(--primary-glow)',
fontFamily: "var(--font-heading)",
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: 12,
fontSize: 14
}}
>
{submitting ? <RefreshCcw size={18} className="spin" /> : <ShieldCheck size={18} />}
{submitting ? "SYNC..." : modalType === 'edit' ? "Save" : "Create"}
</button>
</div>
</form>
</div>
</div>
)}
</div>
<style>{`
@keyframes appear {
from { opacity: 0; transform: scale(0.95) translateY(20px); }
to { opacity: 1; transform: scale(1) translateY(0); }
}
.spin { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.input-focus:focus {
border-color: var(--primary) !important;
box-shadow: 0 0 0 4px var(--primary-glow) !important;
}
`}</style>
</div>
);
};
|