Workspace white screen error resolved, issue was when we migrated from the local SQLite database to the Client-Server architecture during Phase 2, we didn't implement backend endpoints for adding, updating, or deleting users. Because the app.jsx file had nowhere to send those requests, the buttons didn't do anything

This commit is contained in:
NPS Agent
2026-05-11 15:23:49 +09:30
parent d959c89d5f
commit 39d26be447
7 changed files with 128 additions and 8 deletions
+38 -1
View File
@@ -235,7 +235,7 @@ function App() {
setAuthed(false);
setShowSettings(false);
}}
onSwitchUser={async (id) => {
onSwitchUser={async (id) => {
try {
await api.login(id, "password123");
setMeId(id);
@@ -244,6 +244,43 @@ function App() {
alert("Failed to switch user");
}
}}
onCreateUser={async (u) => {
try {
const id = u.name.split(' ')[0].toLowerCase() + Math.floor(Math.random()*100);
await api.createUser({
id,
name: u.name,
role: u.role,
hue: Math.floor(Math.random() * 360),
initials: u.name.split(' ').map(s=>s[0]).join('').slice(0,2).toUpperCase(),
account_type: u.account_type,
password: "password123"
});
await api.addAudit({ actor: meId, action: 'user_created', summary: 'Added ' + u.name + ' (' + (u.account_type||'standard') + ')', target: id });
} catch(e) {
console.error(e);
alert("Failed to create user: " + e.message);
}
}}
onDeleteUser={async (id) => {
try {
const u = userMap[id];
await api.deleteUser(id);
await api.addAudit({ actor: meId, action: 'user_deleted', summary: 'Removed ' + (u?u.name:id), target: null });
} catch(e) {
console.error(e);
alert("Failed to delete user");
}
}}
onUpdateUserRole={async (id, edits) => {
try {
await api.updateUser(id, edits);
await api.addAudit({ actor: meId, action: 'user_updated', summary: 'Updated ' + (userMap[id]?userMap[id].name:id) + ' permissions', target: null });
} catch(e) {
console.error(e);
alert("Failed to update user");
}
}}
/>
)}