fix: Applied fix for name, the oracle team sharing, sentinel client list visibility

This commit is contained in:
Sagnik
2026-04-19 17:07:12 +05:30
parent 269591a3cc
commit d886e4a669
20 changed files with 940 additions and 109 deletions

View File

@@ -21,7 +21,7 @@ import {
getVelocityToken,
isAdminRole,
normalizeVelocityRole,
type VelocityUserProfile,
resolveVelocityFirstName,
} from '@/lib/velocityPlatformClient';
import {
@@ -52,8 +52,8 @@ export const MODULE_ROUTES: Array<{
{ id: 'sentinel', path: '/sentinel', title: 'The Sentinel', component: Sentinel },
{ id: 'inventory', path: '/inventory', title: 'Inventory', component: Inventory },
{ id: 'catalyst', path: '/catalyst', title: 'The Catalyst', component: Catalyst },
{ id: 'settings', path: '/settings', title: 'Settings', component: Settings },
{ id: 'crm', path: '/crm', title: 'CRM', component: CRM },
{ id: 'settings', path: '/settings', title: 'Settings', component: Settings },
{ id: 'admin', path: '/admin', title: 'Admin', component: AdminPage, adminOnly: true },
];
@@ -98,7 +98,7 @@ function MainLayout() {
const currentRoute = availableRoutes.find((r) => r.path === location.pathname);
const pageTitle = currentRoute?.title ?? 'Velocity';
const roleLabel = formatRoleLabel(user?.role);
const userLabel = user?.name?.trim() || user?.id || 'Authenticated User';
const userLabel = user?.name?.trim() || user?.fullName?.trim() || user?.email?.trim() || user?.id || 'Authenticated User';
const initials = userLabel
.split(/\s+/)
.filter(Boolean)
@@ -187,7 +187,13 @@ function MainLayout() {
<span>Settings</span>
</DropdownMenuItem>
<DropdownMenuSeparator className="bg-white/10" />
<DropdownMenuItem className="text-red-400 focus:text-red-400 focus:bg-red-500/10 cursor-pointer" onClick={() => logout()}>
<DropdownMenuItem
className="text-red-400 focus:text-red-400 focus:bg-red-500/10 cursor-pointer"
onClick={() => {
clearVelocityToken();
logout();
}}
>
<LogOut className="mr-2 h-4 w-4" />
<span>Log out</span>
</DropdownMenuItem>
@@ -237,7 +243,7 @@ function MainLayout() {
// ── Root App ──────────────────────────────────────────────────────────────────
function App() {
const { isAuthenticated, login, logout } = useStore();
const { isAuthenticated, login, logout, user } = useStore();
const [authBootstrapped, setAuthBootstrapped] = useState(false);
useEffect(() => {
@@ -257,9 +263,18 @@ function App() {
void getVelocityMe()
.then((me) => {
if (cancelled) return;
const resolvedEmail = me.email?.trim() || user?.email?.trim() || undefined;
const resolvedFullName = me.full_name?.trim() || user?.fullName?.trim() || undefined;
login({
id: me.user_id,
name: resolveVelocityDisplayName(me),
name: resolveVelocityFirstName({
...me,
email: resolvedEmail ?? null,
full_name: resolvedFullName ?? null,
}),
fullName: resolvedFullName,
email: resolvedEmail,
avatar: me.avatar_url?.trim() || user?.avatar?.trim() || undefined,
role: normalizeVelocityRole(me.role),
});
setAuthBootstrapped(true);
@@ -286,9 +301,18 @@ function App() {
void getVelocityMe()
.then((me) => {
if (cancelled) return;
const resolvedEmail = me.email?.trim() || user?.email?.trim() || undefined;
const resolvedFullName = me.full_name?.trim() || user?.fullName?.trim() || undefined;
login({
id: me.user_id,
name: resolveVelocityDisplayName(me),
name: resolveVelocityFirstName({
...me,
email: resolvedEmail ?? null,
full_name: resolvedFullName ?? null,
}),
fullName: resolvedFullName,
email: resolvedEmail,
avatar: me.avatar_url?.trim() || user?.avatar?.trim() || undefined,
role: normalizeVelocityRole(me.role),
});
})
@@ -301,7 +325,7 @@ function App() {
return () => {
cancelled = true;
};
}, [authBootstrapped, isAuthenticated, login, logout]);
}, [authBootstrapped, isAuthenticated, login, logout, user]);
if (!authBootstrapped) {
return (
@@ -363,17 +387,3 @@ function formatRoleLabel(role: string | undefined) {
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
.join(' ');
}
function resolveVelocityDisplayName(profile: VelocityUserProfile) {
const fullName = profile.full_name?.trim();
if (fullName) {
return fullName;
}
const email = profile.email?.trim();
if (email) {
return email;
}
return profile.user_id;
}