big refactor

This commit is contained in:
2026-04-29 16:25:11 -05:00
parent 6c411ce2b6
commit 8265fb689a
156 changed files with 15845 additions and 50373 deletions

View File

@@ -1,12 +1,62 @@
<script setup lang="ts">
import { useReferralChannels, type ReferralChannel } from '~/composables/useReferralChannels'
usePageTitle('Referral Channels · Settings')
const { channels, addChannel, updateChannel, removeChannel } = useReferralChannels()
interface ReferralChannel {
id: string
name: string
type: 'person' | 'company' | 'digital' | 'event' | 'other'
contactName: string
contactPhone: string
contactEmail: string
note: string
active: boolean
}
const STORAGE_KEY = 'policy-ui.referral-channels'
function loadChannels(): ReferralChannel[] {
if (import.meta.client) {
const stored = localStorage.getItem(STORAGE_KEY)
if (stored) {
try {
return JSON.parse(stored)
} catch {
return []
}
}
}
return []
}
const channels = ref<ReferralChannel[]>(loadChannels())
function saveChannels() {
if (import.meta.client) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(channels.value))
}
}
function addChannel(channel: Omit<ReferralChannel, 'id'>) {
const id = String(Date.now())
channels.value.push({ ...channel, id })
saveChannels()
}
function updateChannel(id: string, updates: Partial<ReferralChannel>) {
const idx = channels.value.findIndex(c => c.id === id)
if (idx !== -1) {
channels.value[idx] = { ...channels.value[idx], ...updates }
saveChannels()
}
}
function removeChannel(id: string) {
channels.value = channels.value.filter(c => c.id !== id)
saveChannels()
}
const toast = useToast()
/* ── Form state ── */
const formOpen = ref(false)
const editingId = ref<string | null>(null)
@@ -88,7 +138,6 @@ function toggleActive(id: string) {
if (ch) updateChannel(id, { active: !ch.active })
}
/* ── Filter ── */
type ListFilter = 'all' | 'active' | 'inactive'
const activeFilter = ref<ListFilter>('all')
@@ -104,7 +153,6 @@ const filterCounts = computed(() => ({
inactive: channels.value.filter(c => !c.active).length,
}))
/* ── Helpers ── */
const typeMeta: Record<string, { label: string; icon: string; class: string }> = {
person: { label: 'Person', icon: 'i-heroicons-user', class: 'rc-type-person' },
company: { label: 'Company', icon: 'i-heroicons-building-office', class: 'rc-type-company' },