Fix api url in prod

This commit is contained in:
pikiou
2022-01-11 21:46:37 +01:00
parent c7941aefc3
commit 15c6cc0be7
11 changed files with 75 additions and 44 deletions

View File

@@ -1,7 +1,12 @@
import { ActionCreatorWithoutPayload, ActionCreatorWithPayload } from "@reduxjs/toolkit"
import {
Action,
ActionCreatorWithoutPayload,
ActionCreatorWithPayload,
ThunkDispatch,
} from "@reduxjs/toolkit"
import { toast } from "react-toastify"
import { AppThunk, AppDispatch } from "."
import { AppState, AppThunk } from "."
export interface StateRequest {
readyStatus: "idle" | "request" | "success" | "failure"
@@ -41,10 +46,10 @@ export function elementFetch<Element, ServiceInput extends Array<any>>(
getSuccess: ActionCreatorWithPayload<Element, string>,
getFailure: ActionCreatorWithPayload<string, string>,
errorMessage?: (error: Error) => void,
successMessage?: (data: Element, dispatch: AppDispatch) => void
successMessage?: (data: Element, dispatch: ThunkDispatch<AppState, any, Action>) => void
): (...idArgs: ServiceInput) => AppThunk {
return (...idArgs: ServiceInput): AppThunk =>
async (dispatch) => {
async (dispatch: ThunkDispatch<AppState, any, Action>) => {
dispatch(getRequesting())
const { error, data } = await elementService(...idArgs)

View File

@@ -40,13 +40,14 @@ export const fetchVolunteerNotifsSet = elementFetch(
)
const shouldFetchVolunteerNotifsSet = (state: AppState, id: number) =>
state.volunteerNotifsSet.readyStatus !== "success" ||
(state.volunteerNotifsSet.entity && state.volunteerNotifsSet.entity.id !== id)
state.volunteerNotifsSet?.readyStatus !== "success" ||
(state.volunteerNotifsSet?.entity && state.volunteerNotifsSet?.entity?.id !== id)
export const fetchVolunteerNotifsSetIfNeed =
(id = 0, notif: Partial<VolunteerNotifs> = {}): AppThunk =>
(dispatch, getState) => {
let jwt = ""
if (!id) {
;({ id, jwt } = getState().auth)
}