mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-19 03:04:05 +00:00
Create the complete TypeScript foundation for the Vue 3 migration in a parallel scripts-v2/ directory. 72 files, 5430 lines, zero any types, strict mode. - types/ (21 files): Domain interfaces for all 17 entities derived from actual Laravel models and API resources. Enums for all statuses. Generic API response wrappers. - api/ (29 files): Typed axios client with interceptors, endpoint constants from routes/api.php, 25 typed service classes covering every API endpoint. - composables/ (14 files): Vue 3 composition functions for auth, notifications, dialogs, modals, pagination, filters, currency, dates, theme, sidebar, company context, and permissions. - utils/ (5 files): Pure typed utilities for money formatting, date formatting (date-fns), localStorage, and error handling. - config/ (3 files): Typed ability constants, app constants. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
101 lines
2.9 KiB
TypeScript
101 lines
2.9 KiB
TypeScript
import { client } from '../client'
|
|
import { API } from '../endpoints'
|
|
import type { Company } from '../../types/domain/company'
|
|
import type { ApiResponse } from '../../types/api'
|
|
|
|
export interface UpdateCompanyPayload {
|
|
name: string
|
|
vat_id?: string | null
|
|
tax_id?: string | null
|
|
phone?: string | null
|
|
address?: {
|
|
address_street_1?: string | null
|
|
address_street_2?: string | null
|
|
city?: string | null
|
|
state?: string | null
|
|
country_id?: number | null
|
|
zip?: string | null
|
|
phone?: string | null
|
|
}
|
|
}
|
|
|
|
export interface CompanySettingsPayload {
|
|
settings: Record<string, string | number | boolean | null>
|
|
}
|
|
|
|
export interface CreateCompanyPayload {
|
|
name: string
|
|
currency?: number
|
|
address?: Record<string, unknown>
|
|
}
|
|
|
|
export const companyService = {
|
|
async update(payload: UpdateCompanyPayload): Promise<ApiResponse<Company>> {
|
|
const { data } = await client.put(API.COMPANY, payload)
|
|
return data
|
|
},
|
|
|
|
async uploadLogo(payload: FormData): Promise<ApiResponse<Company>> {
|
|
const { data } = await client.post(API.COMPANY_UPLOAD_LOGO, payload)
|
|
return data
|
|
},
|
|
|
|
async getSettings(settings?: string[]): Promise<Record<string, string>> {
|
|
const { data } = await client.get(API.COMPANY_SETTINGS, {
|
|
params: { settings },
|
|
})
|
|
return data
|
|
},
|
|
|
|
async updateSettings(payload: CompanySettingsPayload): Promise<{ success: boolean }> {
|
|
const { data } = await client.post(API.COMPANY_SETTINGS, payload)
|
|
return data
|
|
},
|
|
|
|
async hasTransactions(): Promise<{ has_transactions: boolean }> {
|
|
const { data } = await client.get(API.COMPANY_HAS_TRANSACTIONS)
|
|
return data
|
|
},
|
|
|
|
async create(payload: CreateCompanyPayload): Promise<ApiResponse<Company>> {
|
|
const { data } = await client.post(API.COMPANIES, payload)
|
|
return data
|
|
},
|
|
|
|
async listUserCompanies(): Promise<ApiResponse<Company[]>> {
|
|
const { data } = await client.get(API.COMPANIES)
|
|
return data
|
|
},
|
|
|
|
async delete(payload: { id: number }): Promise<{ success: boolean }> {
|
|
const { data } = await client.post(API.COMPANIES_DELETE, payload)
|
|
return data
|
|
},
|
|
|
|
async transferOwnership(userId: number): Promise<{ success: boolean }> {
|
|
const { data } = await client.post(`${API.TRANSFER_OWNERSHIP}/${userId}`)
|
|
return data
|
|
},
|
|
|
|
// Company Mail Configuration
|
|
async getMailDefaultConfig(): Promise<Record<string, unknown>> {
|
|
const { data } = await client.get(API.COMPANY_MAIL_DEFAULT_CONFIG)
|
|
return data
|
|
},
|
|
|
|
async getMailConfig(): Promise<Record<string, unknown>> {
|
|
const { data } = await client.get(API.COMPANY_MAIL_CONFIG)
|
|
return data
|
|
},
|
|
|
|
async saveMailConfig(payload: Record<string, unknown>): Promise<{ success: boolean }> {
|
|
const { data } = await client.post(API.COMPANY_MAIL_CONFIG, payload)
|
|
return data
|
|
},
|
|
|
|
async testMailConfig(payload: Record<string, unknown>): Promise<{ success: boolean }> {
|
|
const { data } = await client.post(API.COMPANY_MAIL_TEST, payload)
|
|
return data
|
|
},
|
|
}
|