| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- interface CompanySettings {
- hero_background_url: string | null
- hero_title: string | null
- hero_subtitle: string | null
- stat1_value: string | null
- stat1_label: string | null
- stat2_value: string | null
- stat2_label: string | null
- stat3_value: string | null
- stat3_label: string | null
- contact_email: string | null
- contact_phone: string | null
- contact_location: string | null
- }
- interface CompanyBenefit {
- id: number
- title: string
- icon: string
- description: string | null
- order: number
- }
- interface ApiResponse<T> {
- payload: T
- }
- const FALLBACK_SETTINGS: CompanySettings = {
- hero_background_url: null,
- hero_title: 'Serprati é fazer parte de algo maior',
- hero_subtitle: 'Benefícios exclusivos, parceiros de qualidade e uma comunidade que cuida de você e sua família.',
- stat1_value: '1.000+',
- stat1_label: 'Associados',
- stat2_value: '50+',
- stat2_label: 'Parceiros',
- stat3_value: '30+',
- stat3_label: 'Anos de História',
- contact_email: 'serprati@serprati.com.br',
- contact_phone: '45 99126-6531',
- contact_location: 'Toledo - PR',
- }
- const FALLBACK_BENEFITS: CompanyBenefit[] = [
- { id: 1, title: 'Descontos Exclusivos', icon: 'mdi-tag', description: 'Até 50% de desconto em parceiros selecionados.', order: 1 },
- { id: 2, title: 'Convênios Médicos', icon: 'mdi-hospital-box-outline', description: 'Planos de saúde com condições especiais.', order: 2 },
- { id: 3, title: 'Loja do Associado', icon: 'mdi-store-outline', description: 'Produtos com preços diferenciados.', order: 3 },
- { id: 4, title: 'Carteirinha Digital', icon: 'mdi-card-account-details-outline', description: 'Acesso rápido aos benefícios pelo celular.', order: 4 },
- { id: 5, title: 'Notificações', icon: 'mdi-bell-outline', description: 'Fique por dentro das novidades e promoções.', order: 5 },
- { id: 6, title: 'Dependentes', icon: 'mdi-human-male-female-child', description: 'Inclua sua família nos benefícios.', order: 6 },
- ]
- export const useCompanyData = () => {
- const { apiUrl } = useRuntimeConfig().public
- const { data: settingsData } = useAsyncData('company-settings', () =>
- $fetch<ApiResponse<CompanySettings>>(`${apiUrl}/api/company-settings`).catch(() => null),
- )
- const { data: benefitsData } = useAsyncData('company-benefits', () =>
- $fetch<ApiResponse<CompanyBenefit[]>>(`${apiUrl}/api/company-benefits`).catch(() => null),
- )
- const settings = computed<CompanySettings>(() => {
- const payload = settingsData.value?.payload
- if (!payload) return FALLBACK_SETTINGS
- return { ...FALLBACK_SETTINGS, ...payload }
- })
- const benefits = computed<CompanyBenefit[]>(() => {
- const payload = benefitsData.value?.payload
- if (!Array.isArray(payload) || payload.length === 0) return FALLBACK_BENEFITS
- return payload
- })
- return { settings, benefits }
- }
|