feat(Makefile): patch Layout.jsx queryKey for local development feat(frontend-web): mock base44 client for local development with role switching feat(frontend-web): add event assignment modal with conflict detection and bulk assign feat(frontend-web): add client dashboard with key metrics and quick actions feat(frontend-web): add layout component with role-based navigation feat(frontend-web): update various pages to use "@/components" alias feat(frontend-web): update create event page with ai assistant toggle feat(frontend-web): update dashboard page with new components feat(frontend-web): update events page with quick assign popover feat(frontend-web): update invite vendor page with hover card feat(frontend-web): update messages page with conversation list and message thread feat(frontend-web): update operator dashboard page with new components feat(frontend-web): update partner management page with new components feat(frontend-web): update permissions page with new components feat(frontend-web): update procurement dashboard page with new components feat(frontend-web): update smart vendor onboarding page with new components feat(frontend-web): update staff directory page with new components feat(frontend-web): update teams page with new components feat(frontend-web): update user management page with new components feat(frontend-web): update vendor compliance page with new components feat(frontend-web): update main.jsx to include react query provider feat: add vendor marketplace page feat: add global import fix to prepare-export script feat: add patch-layout-query-key script to fix query key feat: update patch-base44-client script to use a more robust method
100 lines
3.3 KiB
JavaScript
100 lines
3.3 KiB
JavaScript
const fs = require('fs');
|
||
const path = require('path');
|
||
|
||
const projectRoot = path.resolve(__dirname, '..');
|
||
const clientFilePath = path.join(projectRoot, 'frontend-web', 'src', 'api', 'base44Client.js');
|
||
|
||
const patchedMock = `// import { createClient } from '@base44/sdk';
|
||
|
||
// --- MIGRATION MOCK ---
|
||
// This mock completely disables the Base44 SDK to allow for local development.
|
||
// It also simulates user roles for the RoleSwitcher component.
|
||
|
||
const MOCK_USER_KEY = 'krow_mock_user_role';
|
||
|
||
// Default mock user data
|
||
const DEFAULT_MOCK_USER = {
|
||
id: "mock-user-123",
|
||
email: "dev@example.com",
|
||
full_name: "Dev User",
|
||
// 'role' is the Base44 default, 'user_role' is our custom field
|
||
role: "admin",
|
||
user_role: "admin", // Default role for testing
|
||
profile_picture: "https://i.pravatar.cc/150?u=a042581f4e29026024d",
|
||
};
|
||
|
||
// Function to get the current mock user state
|
||
const getMockUser = () => {
|
||
try {
|
||
const storedRole = localStorage.getItem(MOCK_USER_KEY);
|
||
if (storedRole) {
|
||
return { ...DEFAULT_MOCK_USER, user_role: storedRole, role: storedRole };
|
||
}
|
||
// If no role is stored, set the default and return it
|
||
localStorage.setItem(MOCK_USER_KEY, DEFAULT_MOCK_USER.user_role);
|
||
return DEFAULT_MOCK_USER;
|
||
} catch (e) {
|
||
// localStorage is not available (e.g., in SSR)
|
||
return DEFAULT_MOCK_USER;
|
||
}
|
||
};
|
||
|
||
export const base44 = {
|
||
auth: {
|
||
me: () => Promise.resolve(getMockUser()),
|
||
logout: () => {
|
||
try {
|
||
localStorage.removeItem(MOCK_USER_KEY); // Clear role on logout
|
||
// Optionally, redirect to login page or reload
|
||
window.location.reload();
|
||
} catch (e) {
|
||
// localStorage is not available
|
||
}
|
||
return Promise.resolve();
|
||
},
|
||
updateMe: (data) => {
|
||
try {
|
||
if (data.user_role) {
|
||
localStorage.setItem(MOCK_USER_KEY, data.user_role);
|
||
}
|
||
} catch (e) {
|
||
// localStorage is not available
|
||
}
|
||
// Simulate a successful update
|
||
return Promise.resolve({ ...getMockUser(), ...data });
|
||
},
|
||
},
|
||
entities: {
|
||
ActivityLog: {
|
||
filter: () => Promise.resolve([]),
|
||
},
|
||
// Add other entity mocks as needed for the RoleSwitcher to function
|
||
// For now, the RoleSwitcher only updates the user role, so other entities might not be critical.
|
||
},
|
||
integrations: {
|
||
Core: {
|
||
SendEmail: () => Promise.resolve({ status: "sent" }),
|
||
UploadFile: () => Promise.resolve({ file_url: "mock-file-url" }),
|
||
InvokeLLM: () => Promise.resolve({ result: "mock-ai-response" }),
|
||
// Add other integration mocks if the RoleSwitcher indirectly calls them
|
||
}
|
||
}
|
||
};`;
|
||
|
||
try {
|
||
const content = fs.readFileSync(clientFilePath, 'utf8');
|
||
|
||
// Check if the file is the original, unpatched version from the export
|
||
if (content.includes("createClient({")) {
|
||
fs.writeFileSync(clientFilePath, patchedMock, 'utf8');
|
||
console.log('✅ Successfully patched frontend-web/src/api/base44Client.js');
|
||
} else if (content.includes("const MOCK_USER_KEY")) {
|
||
console.log('ℹ️ base44Client.js is already patched. Skipping.');
|
||
} else {
|
||
console.error('❌ Patching failed: Could not find the expected code in base44Client.js. The export format may have changed.');
|
||
process.exit(1);
|
||
}
|
||
} catch (error) {
|
||
console.error('❌ An error occurred during patching:', error);
|
||
process.exit(1);
|
||
} |