refactor: enhance routing and state management in CoopBuilder, add migration checks on startup, and update Tailwind configuration for improved component styling
This commit is contained in:
parent
848386e3dd
commit
4cea1f71fe
55 changed files with 4053 additions and 1486 deletions
6
middleware/redirect-dashboard.global.ts
Normal file
6
middleware/redirect-dashboard.global.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export default defineNuxtRouteMiddleware((to) => {
|
||||
// Redirect root path to dashboard
|
||||
if (to.path === '/') {
|
||||
return navigateTo('/dashboard')
|
||||
}
|
||||
})
|
||||
|
|
@ -1,24 +1,51 @@
|
|||
export default defineNuxtRouteMiddleware((to) => {
|
||||
// Skip middleware for coop-planner, wizards, templates, and API routes
|
||||
// Allowlist: routes that should always be accessible before setup
|
||||
if (
|
||||
to.path === "/coop-planner" ||
|
||||
to.path === "/coop-builder" ||
|
||||
to.path === "/wizards" ||
|
||||
to.path.startsWith("/templates") ||
|
||||
to.path.startsWith("/coach") ||
|
||||
to.path.startsWith("/api/")
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only guard core dashboards until setup is complete
|
||||
const protectedRoutes = new Set([
|
||||
"/dashboard",
|
||||
"/dashboard-simple",
|
||||
"/budget",
|
||||
"/mix",
|
||||
"/cash",
|
||||
]);
|
||||
|
||||
if (!protectedRoutes.has(to.path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Use actual store state to determine whether setup is complete
|
||||
const membersStore = useMembersStore();
|
||||
const policiesStore = usePoliciesStore();
|
||||
const streamsStore = useStreamsStore();
|
||||
const coopStore = useCoopBuilderStore?.();
|
||||
|
||||
const setupComplete =
|
||||
// Legacy stores OR new coop builder store (either is enough)
|
||||
const legacyComplete =
|
||||
membersStore.isValid &&
|
||||
policiesStore.isValid &&
|
||||
streamsStore.hasValidStreams;
|
||||
|
||||
const coopComplete = Boolean(
|
||||
coopStore &&
|
||||
Array.isArray(coopStore.members) &&
|
||||
coopStore.members.length > 0 &&
|
||||
Array.isArray(coopStore.streams) &&
|
||||
coopStore.streams.length > 0
|
||||
);
|
||||
|
||||
const setupComplete = legacyComplete || coopComplete;
|
||||
|
||||
if (!setupComplete) {
|
||||
return navigateTo("/coop-planner");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue