chore: Update Fetcher and TokenManager to use API v1

This commit is contained in:
Mo Tarbin 2025-01-02 23:10:36 -05:00
parent 1d0f9ed1ed
commit 989137211e
3 changed files with 8 additions and 8 deletions

View file

@ -22,7 +22,8 @@ const signUp = (username, password, displayName, email) => {
} }
const UpdatePassword = newPassword => { const UpdatePassword = newPassword => {
return fetch(`/users/change_password`, { const baseURL = apiManager.getApiURL()
return fetch(`${baseURL}/users/change_password`, {
method: 'PUT', method: 'PUT',
headers: HEADERS(), headers: HEADERS(),
body: JSON.stringify({ password: newPassword }), body: JSON.stringify({ password: newPassword }),
@ -403,21 +404,20 @@ const ResetPassword = email => {
} }
const UpdateDueDate = (id, dueDate) => { const UpdateDueDate = (id, dueDate) => {
return Fetch(`/chores/${chore.id}/dueDate`, { return Fetch(`/chores/${id}/dueDate`, {
method: 'PUT', method: 'PUT',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify({ body: JSON.stringify({
dueDate: newDate ? new Date(newDate).toISOString() : null, dueDate: dueDate ? new Date(dueDate).toISOString() : null,
UpdatedBy: activeUserId,
}), }),
}) })
} }
const RefreshToken = () => { const RefreshToken = () => {
const basedURL = apiManager.getApiURL() const basedURL = apiManager.getApiURL()
return fetch(basedURL + '/auth/refresh', { return fetch(`${basedURL}/auth/refresh`, {
method: 'GET', method: 'GET',
headers: HEADERS(), headers: HEADERS(),
}) })

View file

@ -6,7 +6,7 @@ import { Preferences } from '@capacitor/preferences'
class ApiManager { class ApiManager {
constructor() { constructor() {
this.customServerURL = API_URL this.customServerURL = `${API_URL}/api/v1`
this.initialized = false this.initialized = false
} }
async init() { async init() {
@ -17,7 +17,7 @@ class ApiManager {
key: 'customServerUrl', key: 'customServerUrl',
}) })
this.customServerURL = serverURL || API_URL this.customServerURL = `${serverURL || API_URL}/api/v1`
this.initialized = true this.initialized = true
} }
getApiURL() { getApiURL() {

View file

@ -204,7 +204,7 @@ const ChoreCard = ({
alert('Please select a performer') alert('Please select a performer')
return return
} }
UpdateDueDate.then(response => { UpdateDueDate(chore.id, newDate).then(response => {
if (response.ok) { if (response.ok) {
response.json().then(data => { response.json().then(data => {
const newChore = data.res const newChore = data.res