-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
75 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/// <reference types="vite/client" /> | ||
|
||
interface ImportMetaEnv { | ||
readonly VITE_API_URL: string | ||
} | ||
|
||
interface ImportMeta { | ||
readonly env: ImportMetaEnv | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import axios from 'axios'; | ||
|
||
let http = | ||
axios.create({ | ||
baseURL: import.meta.env.VITE_API_URL | ||
}); | ||
|
||
let headers = () => | ||
({ | ||
headers: { | ||
'Access-Control-Allow-Headers': '*', | ||
'Authorization': `Bearer ${localStorage.getItem('token')}` | ||
} | ||
}); | ||
|
||
export default { | ||
get<T>(url: string) { | ||
return http.get<T>(url, headers()); | ||
}, | ||
|
||
post<T>(url: string, data: any) { | ||
return http.post<T>(url, data, headers()); | ||
}, | ||
|
||
patch<T>(url: string, data: any) { | ||
return http.patch<T>(url, data, headers()); | ||
}, | ||
|
||
delete(url: string) { | ||
http.delete(url, headers()); | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import http from '../infrastructure/http'; | ||
import { Item } from '../types/Item'; | ||
|
||
|
||
export function createItem(budgetId: number, recipientId: number, name: string, price: number) { | ||
return http.post<Item>(`/api/budgets/${budgetId}/recipients/${recipientId}/items`, { name, price }); | ||
} | ||
|
||
export function updateItem(budgetId, recipientId, id, name, price, purchased) { | ||
return http.patch<Item>(`/api/budgets/${budgetId}/recipients/${recipientId}/items/${id}`, { name, price, purchased }); | ||
} | ||
|
||
export function deleteItem(budgetId, recipientId, id) { | ||
http.delete(`/api/budgets/${budgetId}/recipients/${recipientId}/items/${id}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export type Item = { | ||
id: number | ||
recipientId: number | ||
name: string | ||
price: number | ||
purchased: boolean | ||
created_at: Date | ||
updated_at: Date | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import vue from '@vitejs/plugin-vue2' | ||
import { defineConfig } from 'vite' | ||
import vue from '@vitejs/plugin-vue2' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [vue()], | ||
server: { | ||
port: 8080 | ||
} | ||
}) | ||
}) |