mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
build passes Create all missing components (modals, dropdowns, icons, tabs, mail drivers, customer partials), fix all @/scripts/ imports to @v2/, wire up vite entry point and blade template. 382 files, 48883 lines. - 27 settings components: modals (tax, payment, custom field, note, category, role, exchange rate, unit, mail test), dropdowns (6), customization tabs (4), mail driver forms (4) - 22 icon components: 5 utility icons, 4 dashboard icons, 13 editor toolbar icons with typed barrel export - 3 customer components: info, chart placeholder, custom fields single - Fixed usePopper composable, client/format-money import patterns - Zero remaining @/scripts/ imports in scripts-v2/ Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
118 lines
3.4 KiB
TypeScript
118 lines
3.4 KiB
TypeScript
import { client } from '../client'
|
|
import { API } from '../endpoints'
|
|
import type { ExchangeRateProvider, Currency } from '@v2/types/domain/currency'
|
|
import type { ApiResponse, ListParams } from '@v2/types/api'
|
|
|
|
export interface CreateExchangeRateProviderPayload {
|
|
driver: string
|
|
key: string
|
|
active?: boolean
|
|
currencies?: string[]
|
|
}
|
|
|
|
export interface ExchangeRateResponse {
|
|
exchange_rate: number
|
|
}
|
|
|
|
export interface ActiveProviderResponse {
|
|
has_active_provider: boolean
|
|
exchange_rate: number | null
|
|
}
|
|
|
|
export interface SupportedCurrenciesResponse {
|
|
supportedCurrencies: string[]
|
|
}
|
|
|
|
export interface UsedCurrenciesResponse {
|
|
activeUsedCurrencies: Currency[]
|
|
}
|
|
|
|
export interface BulkCurrenciesResponse {
|
|
currencies: Array<Currency & { exchange_rate: number | null }>
|
|
}
|
|
|
|
export interface BulkUpdatePayload {
|
|
currencies: Array<{
|
|
id: number
|
|
exchange_rate: number
|
|
}>
|
|
}
|
|
|
|
export interface ConfigDriversResponse {
|
|
exchange_rate_drivers: string[]
|
|
}
|
|
|
|
export const exchangeRateService = {
|
|
// Providers CRUD
|
|
async listProviders(params?: ListParams): Promise<ApiResponse<ExchangeRateProvider[]>> {
|
|
const { data } = await client.get(API.EXCHANGE_RATE_PROVIDERS, { params })
|
|
return data
|
|
},
|
|
|
|
async getProvider(id: number): Promise<ApiResponse<ExchangeRateProvider>> {
|
|
const { data } = await client.get(`${API.EXCHANGE_RATE_PROVIDERS}/${id}`)
|
|
return data
|
|
},
|
|
|
|
async createProvider(payload: CreateExchangeRateProviderPayload): Promise<ApiResponse<ExchangeRateProvider>> {
|
|
const { data } = await client.post(API.EXCHANGE_RATE_PROVIDERS, payload)
|
|
return data
|
|
},
|
|
|
|
async updateProvider(
|
|
id: number,
|
|
payload: Partial<CreateExchangeRateProviderPayload>,
|
|
): Promise<ApiResponse<ExchangeRateProvider>> {
|
|
const { data } = await client.put(`${API.EXCHANGE_RATE_PROVIDERS}/${id}`, payload)
|
|
return data
|
|
},
|
|
|
|
async deleteProvider(id: number): Promise<{ success: boolean }> {
|
|
const { data } = await client.delete(`${API.EXCHANGE_RATE_PROVIDERS}/${id}`)
|
|
return data
|
|
},
|
|
|
|
// Exchange Rates
|
|
async getRate(currencyId: number): Promise<ExchangeRateResponse> {
|
|
const { data } = await client.get(`${API.CURRENCIES}/${currencyId}/exchange-rate`)
|
|
return data
|
|
},
|
|
|
|
async getActiveProvider(currencyId: number): Promise<ActiveProviderResponse> {
|
|
const { data } = await client.get(`${API.CURRENCIES}/${currencyId}/active-provider`)
|
|
return data
|
|
},
|
|
|
|
// Currency lists
|
|
async getSupportedCurrencies(): Promise<SupportedCurrenciesResponse> {
|
|
const { data } = await client.get(API.SUPPORTED_CURRENCIES)
|
|
return data
|
|
},
|
|
|
|
async getUsedCurrencies(): Promise<UsedCurrenciesResponse> {
|
|
const { data } = await client.get(API.USED_CURRENCIES)
|
|
return data
|
|
},
|
|
|
|
async getBulkCurrencies(): Promise<BulkCurrenciesResponse> {
|
|
const { data } = await client.get(API.CURRENCIES_USED)
|
|
return data
|
|
},
|
|
|
|
async bulkUpdateExchangeRate(payload: BulkUpdatePayload): Promise<{ success: boolean }> {
|
|
const { data } = await client.post(API.CURRENCIES_BULK_UPDATE, payload)
|
|
return data
|
|
},
|
|
|
|
// Config
|
|
async getDrivers(): Promise<ConfigDriversResponse> {
|
|
const { data } = await client.get(API.CONFIG, { params: { key: 'exchange_rate_drivers' } })
|
|
return data
|
|
},
|
|
|
|
async getCurrencyConverterServers(): Promise<Record<string, unknown>> {
|
|
const { data } = await client.get(API.CONFIG, { params: { key: 'currency_converter_servers' } })
|
|
return data
|
|
},
|
|
}
|