Enables currency selection for expenses
Allows users to select a currency when adding an expense. Fetches available currencies from the backend and displays them in a dropdown menu, defaulting to EUR if the fetch fails. The expense submission process now includes the selected currency.
This commit is contained in:
parent
9c8b696f06
commit
8dad92f0e5
2 changed files with 82 additions and 5 deletions
|
|
@ -207,4 +207,25 @@ export class ExpensesAPI extends BaseService {
|
|||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available currencies from LNbits instance
|
||||
*/
|
||||
async getCurrencies(): Promise<string[]> {
|
||||
try {
|
||||
const response = await fetch(`${this.baseUrl}/api/v1/currencies`, {
|
||||
method: 'GET',
|
||||
signal: AbortSignal.timeout(this.config?.apiConfig?.timeout || 30000)
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch currencies: ${response.statusText}`)
|
||||
}
|
||||
|
||||
return await response.json()
|
||||
} catch (error) {
|
||||
console.error('[ExpensesAPI] Error fetching currencies:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue