mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-09-11 22:06:29 +02:00
Fix api url in prod
This commit is contained in:
@@ -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)
|
||||
|
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user