/** * Client favorites — star customers for quick dashboard access. * Persisted in localStorage. Stores customer IDs. */ import { useLocalStorageRef } from '~/utils/useLocalStorageRef' const KEY = 'policy-ui-client-favorites-v1' export function useClientFavorites() { const favoriteIds = useLocalStorageRef(KEY, () => []) function isFavorite(customerId: string) { return favoriteIds.value.includes(customerId) } function toggleFavorite(customerId: string) { if (isFavorite(customerId)) { favoriteIds.value = favoriteIds.value.filter(id => id !== customerId) } else { favoriteIds.value = [customerId, ...favoriteIds.value] } } function addFavorite(customerId: string) { if (!isFavorite(customerId)) { favoriteIds.value = [customerId, ...favoriteIds.value] } } function removeFavorite(customerId: string) { favoriteIds.value = favoriteIds.value.filter(id => id !== customerId) } return { favoriteIds, isFavorite, toggleFavorite, addFavorite, removeFavorite } }