95 lines
2.1 KiB
TypeScript
95 lines
2.1 KiB
TypeScript
import { defineStore } from "pinia";
|
|
|
|
export const useScenariosStore = defineStore("scenarios", () => {
|
|
// Scenario presets
|
|
const presets = ref({
|
|
current: {
|
|
name: "Operate Current Plan",
|
|
description: "Continue with existing revenue and capacity",
|
|
settings: {},
|
|
},
|
|
quitDayJobs: {
|
|
name: "Quit Day Jobs",
|
|
description: "Members leave external work, increase co-op hours",
|
|
settings: {
|
|
targetHoursMultiplier: 1.5,
|
|
externalCoverageReduction: 0.8,
|
|
},
|
|
},
|
|
startProduction: {
|
|
name: "Start Production",
|
|
description: "Launch product development phase",
|
|
settings: {
|
|
productionCostsIncrease: 2000,
|
|
effortHoursIncrease: 100,
|
|
},
|
|
},
|
|
sixMonth: {
|
|
name: "6-Month Plan",
|
|
description: "Extended planning horizon",
|
|
settings: {
|
|
timeHorizonMonths: 6,
|
|
},
|
|
},
|
|
});
|
|
|
|
// What-if sliders state
|
|
const sliders = ref({
|
|
monthlyRevenue: 0,
|
|
paidHoursPerMonth: 0,
|
|
winRatePct: 0,
|
|
avgPayoutDelayDays: 0,
|
|
hourlyWageAdjust: 0,
|
|
});
|
|
|
|
// Selected scenario
|
|
const activeScenario = ref("current");
|
|
|
|
// Computed scenario results (will be calculated by composables)
|
|
const scenarioResults = computed(() => ({
|
|
runway: 0,
|
|
monthlyCosts: 0,
|
|
cashflowRisk: "low",
|
|
recommendations: [],
|
|
}));
|
|
|
|
// Actions
|
|
function setActiveScenario(scenarioKey) {
|
|
activeScenario.value = scenarioKey;
|
|
}
|
|
|
|
function updateSlider(key, value) {
|
|
if (key in sliders.value) {
|
|
sliders.value[key] = value;
|
|
}
|
|
}
|
|
|
|
function resetSliders() {
|
|
sliders.value = {
|
|
monthlyRevenue: 0,
|
|
paidHoursPerMonth: 0,
|
|
winRatePct: 0,
|
|
avgPayoutDelayDays: 0,
|
|
hourlyWageAdjust: 0,
|
|
};
|
|
}
|
|
|
|
function saveCustomScenario(name, settings) {
|
|
presets.value[name.toLowerCase().replace(/\s+/g, "")] = {
|
|
name,
|
|
description: "Custom scenario",
|
|
settings,
|
|
};
|
|
}
|
|
|
|
return {
|
|
presets: readonly(presets),
|
|
sliders,
|
|
activeScenario: readonly(activeScenario),
|
|
scenarioResults,
|
|
setActiveScenario,
|
|
updateSlider,
|
|
resetSliders,
|
|
saveCustomScenario,
|
|
};
|
|
});
|