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:
Jennie Robinson Faber 2025-08-23 18:24:31 +01:00
parent 848386e3dd
commit 4cea1f71fe
55 changed files with 4053 additions and 1486 deletions

View file

@ -1,13 +1,49 @@
import { monthlyPayroll } from '~/types/members'
/**
* Computes months of runway from cash, reserves, and burn rate
* Formula: (cash + savings) ÷ average monthly burn in scenario
*/
export const useRunway = () => {
const membersStore = useMembersStore()
const policiesStore = usePoliciesStore()
const budgetStore = useBudgetStore()
const calculateRunway = (cash: number, savings: number, monthlyBurn: number): number => {
if (monthlyBurn <= 0) return Infinity
return (cash + savings) / monthlyBurn
}
// Calculate monthly burn based on operating mode
const getMonthlyBurn = (mode?: 'minimum' | 'target') => {
const operatingMode = mode || policiesStore.operatingMode || 'minimum'
// Get payroll costs based on mode
const payrollCost = monthlyPayroll(membersStore.members, operatingMode)
// Add oncosts
const oncostPct = policiesStore.payrollOncostPct || 0
const totalPayroll = payrollCost * (1 + oncostPct / 100)
// Add overhead costs
const overheadCost = budgetStore.overheadCosts.reduce((sum, cost) => sum + (cost.amount || 0), 0)
return totalPayroll + overheadCost
}
// Calculate runway for both modes
const getDualModeRunway = (cash: number, savings: number) => {
const minBurn = getMonthlyBurn('minimum')
const targetBurn = getMonthlyBurn('target')
return {
minimum: calculateRunway(cash, savings, minBurn),
target: calculateRunway(cash, savings, targetBurn),
minBurn,
targetBurn
}
}
const getRunwayStatus = (months: number): 'green' | 'yellow' | 'red' => {
if (months >= 3) return 'green'
if (months >= 2) return 'yellow'
@ -22,6 +58,8 @@ export const useRunway = () => {
return {
calculateRunway,
getRunwayStatus,
formatRunway
formatRunway,
getMonthlyBurn,
getDualModeRunway
}
}