Spaces:
Paused

dushyantsingh0 commited on
Commit
f3bcb44
·
1 Parent(s): 55be46c

backend stabilisation

Browse files
frontend/apps/internal/src/components/WorkspaceSettings.module.css CHANGED
@@ -409,3 +409,88 @@
409
  border-radius: 4px;
410
  border: 1px solid var(--border-subtle);
411
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  border-radius: 4px;
410
  border: 1px solid var(--border-subtle);
411
  }
412
+
413
+ /* Branding Section */
414
+ .brandingSection {
415
+ margin-bottom: 48px;
416
+ background: var(--bg-card);
417
+ border: 1px solid var(--border-subtle);
418
+ border-radius: 12px;
419
+ padding: 32px;
420
+ box-shadow: 0 4px 20px rgba(0,0,0,0.03);
421
+ }
422
+
423
+ .brandingGrid {
424
+ display: grid;
425
+ grid-template-columns: 1fr 1fr;
426
+ gap: 32px;
427
+ margin-top: 24px;
428
+ }
429
+
430
+ .brandingItem {
431
+ display: flex;
432
+ flex-direction: column;
433
+ gap: 12px;
434
+ }
435
+
436
+ .logoPreview {
437
+ width: 48px;
438
+ height: 48px;
439
+ border-radius: 8px;
440
+ background: var(--bg-hover);
441
+ border: 1px solid var(--border-subtle);
442
+ display: flex;
443
+ align-items: center;
444
+ justify-content: center;
445
+ overflow: hidden;
446
+ flex-shrink: 0;
447
+ }
448
+
449
+ .logoPreview img {
450
+ max-width: 80%;
451
+ max-height: 80%;
452
+ object-fit: contain;
453
+ }
454
+
455
+ .colorPicker {
456
+ display: flex;
457
+ align-items: center;
458
+ gap: 12px;
459
+ }
460
+
461
+ .colorInput {
462
+ width: 48px;
463
+ height: 48px;
464
+ padding: 0;
465
+ border: 1px solid var(--border-subtle);
466
+ border-radius: 8px;
467
+ background: none;
468
+ cursor: pointer;
469
+ overflow: hidden;
470
+ }
471
+
472
+ .colorValue {
473
+ flex: 1;
474
+ font-family: var(--font-mono);
475
+ font-size: 14px;
476
+ font-weight: 600;
477
+ color: var(--text-main);
478
+ background: var(--bg-hover);
479
+ padding: 12px;
480
+ border-radius: 8px;
481
+ border: 1px solid var(--border-subtle);
482
+ outline: none;
483
+ text-transform: uppercase;
484
+ }
485
+
486
+ .brandingFooter {
487
+ margin-top: 24px;
488
+ padding-top: 24px;
489
+ border-top: 1px solid var(--border-subtle);
490
+ display: flex;
491
+ align-items: center;
492
+ gap: 12px;
493
+ color: var(--text-muted);
494
+ font-size: 12px;
495
+ font-weight: 500;
496
+ }
frontend/apps/internal/src/components/WorkspaceSettings.tsx CHANGED
@@ -1,6 +1,6 @@
1
  import React, { useState, useRef, useEffect } from 'react';
2
- import { useUsers, useWorkspaces, type User } from '@nexus/shared';
3
- import { MoreHorizontal, Edit3, Trash2, AlertCircle, RefreshCcw } from 'lucide-react';
4
  import styles from './WorkspaceSettings.module.css';
5
 
6
  interface WorkspaceSettingsProps {
@@ -10,6 +10,7 @@ interface WorkspaceSettingsProps {
10
  export const WorkspaceSettings: React.FC<WorkspaceSettingsProps> = ({ workspaceId }) => {
11
  const { users, loading: usersLoading, addUser, updateUser, deleteUser, refresh } = useUsers(workspaceId);
12
  const { workspaces } = useWorkspaces();
 
13
 
14
  const [isModalOpen, setIsModalOpen] = useState(false);
15
  const [formData, setFormData] = useState({
@@ -27,6 +28,19 @@ export const WorkspaceSettings: React.FC<WorkspaceSettingsProps> = ({ workspaceI
27
  const [deletingUser, setDeletingUser] = useState<User | null>(null);
28
  const menuRef = useRef<HTMLDivElement>(null);
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  useEffect(() => {
31
  const handleClickOutside = (event: MouseEvent) => {
32
  if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
@@ -37,7 +51,26 @@ export const WorkspaceSettings: React.FC<WorkspaceSettingsProps> = ({ workspaceI
37
  return () => document.removeEventListener('mousedown', handleClickOutside);
38
  }, []);
39
 
40
- const currentWorkspace = workspaces.find(w => w.id === workspaceId) || workspaces[0];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  const handleAddMember = async (e: React.FormEvent) => {
43
  e.preventDefault();
@@ -112,6 +145,66 @@ export const WorkspaceSettings: React.FC<WorkspaceSettingsProps> = ({ workspaceI
112
  </p>
113
  </header>
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  <section className={styles.teamSection}>
116
  <div className={styles.sectionHeader}>
117
  <h2 className={styles.sectionTitle}>Workspace Team</h2>
 
1
  import React, { useState, useRef, useEffect } from 'react';
2
+ import { useUsers, useWorkspaces, type User, api, useWorkspace } from '@nexus/shared';
3
+ import { MoreHorizontal, Edit3, Trash2, AlertCircle, RefreshCcw, Shield, Palette, Image } from 'lucide-react';
4
  import styles from './WorkspaceSettings.module.css';
5
 
6
  interface WorkspaceSettingsProps {
 
10
  export const WorkspaceSettings: React.FC<WorkspaceSettingsProps> = ({ workspaceId }) => {
11
  const { users, loading: usersLoading, addUser, updateUser, deleteUser, refresh } = useUsers(workspaceId);
12
  const { workspaces } = useWorkspaces();
13
+ const { workspace: activeWs, refresh: refreshActiveWs } = useWorkspace();
14
 
15
  const [isModalOpen, setIsModalOpen] = useState(false);
16
  const [formData, setFormData] = useState({
 
28
  const [deletingUser, setDeletingUser] = useState<User | null>(null);
29
  const menuRef = useRef<HTMLDivElement>(null);
30
 
31
+ // Branding State
32
+ const [brandingLogo, setBrandingLogo] = useState('');
33
+ const [brandingColor, setBrandingColor] = useState('#7c3aed');
34
+
35
+ const currentWorkspace = workspaces.find(w => w.id === workspaceId) || workspaces[0];
36
+
37
+ useEffect(() => {
38
+ if (currentWorkspace?.branding) {
39
+ setBrandingLogo(currentWorkspace.branding.logo_url || '');
40
+ setBrandingColor(currentWorkspace.branding.colors?.primary || '#7c3aed');
41
+ }
42
+ }, [currentWorkspace]);
43
+
44
  useEffect(() => {
45
  const handleClickOutside = (event: MouseEvent) => {
46
  if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
 
51
  return () => document.removeEventListener('mousedown', handleClickOutside);
52
  }, []);
53
 
54
+ const handleUpdateBranding = async () => {
55
+ if (!currentWorkspace) return;
56
+ try {
57
+ await api.patch('/workspace/', {
58
+ branding: {
59
+ ...currentWorkspace.branding,
60
+ logo_url: brandingLogo,
61
+ colors: {
62
+ ...currentWorkspace.branding?.colors,
63
+ primary: brandingColor
64
+ }
65
+ }
66
+ });
67
+ // Invalidate caches
68
+ sessionStorage.removeItem('nexus_active_ws_v1');
69
+ refreshActiveWs();
70
+ } catch (err) {
71
+ console.error("Failed to update branding:", err);
72
+ }
73
+ };
74
 
75
  const handleAddMember = async (e: React.FormEvent) => {
76
  e.preventDefault();
 
145
  </p>
146
  </header>
147
 
148
+ {workspaceId !== 'all' && currentWorkspace && (
149
+ <section className={styles.brandingSection}>
150
+ <div className={styles.sectionHeader}>
151
+ <h2 className={styles.sectionTitle}>Identity & Branding</h2>
152
+ </div>
153
+
154
+ <div className={styles.brandingGrid}>
155
+ <div className={styles.brandingItem}>
156
+ <label className={styles.label}>
157
+ <Image size={14} style={{ marginRight: 8, verticalAlign: 'middle' }} />
158
+ Workspace Logo URL
159
+ </label>
160
+ <div style={{ display: 'flex', gap: 12 }}>
161
+ <input
162
+ className={styles.input}
163
+ value={brandingLogo}
164
+ onChange={e => setBrandingLogo(e.target.value)}
165
+ onBlur={handleUpdateBranding}
166
+ placeholder="https://example.com/logo.png"
167
+ />
168
+ <div className={styles.logoPreview}>
169
+ {brandingLogo ? (
170
+ <img src={brandingLogo} alt="Logo" />
171
+ ) : (
172
+ <Image size={20} style={{ opacity: 0.2 }} />
173
+ )}
174
+ </div>
175
+ </div>
176
+ </div>
177
+
178
+ <div className={styles.brandingItem}>
179
+ <label className={styles.label}>
180
+ <Palette size={14} style={{ marginRight: 8, verticalAlign: 'middle' }} />
181
+ Primary Brand Color
182
+ </label>
183
+ <div className={styles.colorPicker}>
184
+ <input
185
+ type="color"
186
+ className={styles.colorInput}
187
+ value={brandingColor}
188
+ onChange={e => setBrandingColor(e.target.value)}
189
+ onBlur={handleUpdateBranding}
190
+ />
191
+ <input
192
+ className={styles.colorValue}
193
+ value={brandingColor}
194
+ onChange={e => setBrandingColor(e.target.value)}
195
+ onBlur={handleUpdateBranding}
196
+ />
197
+ </div>
198
+ </div>
199
+ </div>
200
+
201
+ <div className={styles.brandingFooter}>
202
+ <Shield size={16} />
203
+ Changes propagate across customer and internal portals immediately.
204
+ </div>
205
+ </section>
206
+ )}
207
+
208
  <section className={styles.teamSection}>
209
  <div className={styles.sectionHeader}>
210
  <h2 className={styles.sectionTitle}>Workspace Team</h2>