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
|
|
@ -137,15 +137,32 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import { useDebounceFn } from "@vueuse/core";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
||||
const emit = defineEmits<{
|
||||
"save-status": [status: "saving" | "saved" | "error"];
|
||||
}>();
|
||||
|
||||
// Store
|
||||
const streamsStore = useStreamsStore();
|
||||
const { streams } = storeToRefs(streamsStore);
|
||||
const coop = useCoopBuilder();
|
||||
const streams = computed(() =>
|
||||
coop.streams.value.map(s => ({
|
||||
// Map store fields to component expectations
|
||||
id: s.id,
|
||||
name: s.label,
|
||||
category: s.category || 'games',
|
||||
targetMonthlyAmount: s.monthly || 0,
|
||||
subcategory: '',
|
||||
targetPct: 0,
|
||||
certainty: s.certainty || 'Aspirational',
|
||||
payoutDelayDays: 30,
|
||||
terms: 'Net 30',
|
||||
revenueSharePct: 0,
|
||||
platformFeePct: 0,
|
||||
restrictions: 'General',
|
||||
seasonalityWeights: new Array(12).fill(1),
|
||||
effortHoursPerMonth: 0,
|
||||
}))
|
||||
);
|
||||
|
||||
// Original category options
|
||||
const categoryOptions = [
|
||||
|
|
@ -210,18 +227,16 @@ const debouncedSave = useDebounceFn((stream: any) => {
|
|||
emit("save-status", "saving");
|
||||
|
||||
try {
|
||||
// Set sensible defaults for hidden fields
|
||||
stream.targetPct = 0; // Will be calculated automatically later
|
||||
stream.certainty = "Aspirational";
|
||||
stream.payoutDelayDays = 30; // Default 30 days
|
||||
stream.terms = "Net 30";
|
||||
stream.revenueSharePct = 0;
|
||||
stream.platformFeePct = 0;
|
||||
stream.restrictions = "General";
|
||||
stream.seasonalityWeights = new Array(12).fill(1);
|
||||
stream.effortHoursPerMonth = 0;
|
||||
// Convert component format back to store format
|
||||
const streamData = {
|
||||
id: stream.id,
|
||||
label: stream.name || '',
|
||||
monthly: stream.targetMonthlyAmount || 0,
|
||||
category: stream.category || 'games',
|
||||
certainty: stream.certainty || 'Aspirational'
|
||||
};
|
||||
|
||||
streamsStore.upsertStream(stream);
|
||||
coop.upsertStream(streamData);
|
||||
emit("save-status", "saved");
|
||||
} catch (error) {
|
||||
console.error("Failed to save stream:", error);
|
||||
|
|
@ -245,26 +260,17 @@ function validateAndSaveAmount(value: string, stream: any) {
|
|||
function addRevenueStream() {
|
||||
const newStream = {
|
||||
id: Date.now().toString(),
|
||||
name: "",
|
||||
label: "",
|
||||
monthly: 0,
|
||||
category: "games",
|
||||
subcategory: "",
|
||||
targetPct: 0,
|
||||
targetMonthlyAmount: 0,
|
||||
certainty: "Aspirational",
|
||||
payoutDelayDays: 30,
|
||||
terms: "Net 30",
|
||||
revenueSharePct: 0,
|
||||
platformFeePct: 0,
|
||||
restrictions: "General",
|
||||
seasonalityWeights: new Array(12).fill(1),
|
||||
effortHoursPerMonth: 0,
|
||||
certainty: "Aspirational"
|
||||
};
|
||||
|
||||
streamsStore.upsertStream(newStream);
|
||||
coop.upsertStream(newStream);
|
||||
}
|
||||
|
||||
function removeStream(id: string) {
|
||||
streamsStore.removeStream(id);
|
||||
coop.removeStream(id);
|
||||
}
|
||||
|
||||
function exportStreams() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue