mirror of
https://github.com/ershisan99/cards-front.git
synced 2026-01-22 05:02:06 +00:00
add auth api and auth instance
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit"
|
||||
|
||||
const initialAppState = {
|
||||
error: null as null | string,
|
||||
isLoading: true,
|
||||
isAppInitialized: false,
|
||||
}
|
||||
|
||||
export type InitialAppState = typeof initialAppState
|
||||
|
||||
const slice = createSlice({
|
||||
name: "app",
|
||||
initialState: {
|
||||
error: null as null | string,
|
||||
isLoading: true,
|
||||
isAppInitialized: false,
|
||||
},
|
||||
initialState: initialAppState,
|
||||
reducers: {
|
||||
setIsLoading: (state, action: PayloadAction<{ isLoading: boolean }>) => {
|
||||
state.isLoading = action.payload.isLoading
|
||||
@@ -14,11 +18,11 @@ const slice = createSlice({
|
||||
setError: (state, action: PayloadAction<{ error: string | null }>) => {
|
||||
state.error = action.payload.error
|
||||
},
|
||||
setIsAppInitialized: (
|
||||
setAppInitialized: (
|
||||
state,
|
||||
action: PayloadAction<{ isInitialized: boolean }>,
|
||||
action: PayloadAction<{ isAppInitialized: boolean }>,
|
||||
) => {
|
||||
state.isAppInitialized = action.payload.isInitialized
|
||||
state.isAppInitialized = action.payload.isAppInitialized
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
7
src/features/auth/auth.api.ts
Normal file
7
src/features/auth/auth.api.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { AuthInstance } from "@/features/auth/auth.instance"
|
||||
|
||||
export const AuthApi = () => ({
|
||||
register: (params: any) => {
|
||||
return AuthInstance.post(params)
|
||||
},
|
||||
})
|
||||
6
src/features/auth/auth.instance.ts
Normal file
6
src/features/auth/auth.instance.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import axios from "axios"
|
||||
|
||||
export const AuthInstance = axios.create({
|
||||
baseURL: import.meta.env.BASE_URL + "auth/",
|
||||
withCredentials: true,
|
||||
})
|
||||
Reference in New Issue
Block a user