Redux -> simple fixes in async thunks & add model & render crud slicers
parent
7078b4f4f2
commit
39c796eb1a
|
|
@ -0,0 +1 @@
|
|||
export const GeneralAddress = 'localhost:9090'
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import axios from 'axios'
|
||||
import { GeneralAddress } from './abstractAddress'
|
||||
|
||||
|
||||
const APIAddress = 'http://localhost:9090'
|
||||
const APIAddress = 'http://' + GeneralAddress
|
||||
|
||||
let defaultBody = ''
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
import { createSlice } from '@reduxjs/toolkit'
|
||||
import modelCrudAsyncThunk from '../asyncThunks/modelCrudAsyncThunk'
|
||||
|
||||
const modelCrudSlice = createSlice(
|
||||
{
|
||||
name: 'model',
|
||||
initialState: {
|
||||
models_list: [],
|
||||
download_blend_file: '',
|
||||
upload_blend_file_status: ''
|
||||
|
||||
},
|
||||
reducers: {},
|
||||
extraReducers: {
|
||||
[modelCrudAsyncThunk.fetchGetAllModels.fulfilled.type]: (state, action) => {
|
||||
state.models_list = action.payload.data
|
||||
},
|
||||
[modelCrudAsyncThunk.fetchGetOneModelAndDownload.fulfilled.type]: (state, action) => {
|
||||
state.download_blend_file = action.payload.data
|
||||
},
|
||||
[modelCrudAsyncThunk.fetchUploadModel.fulfilled.type]: (state, action) => {
|
||||
state.upload_blend_file_status = action.payload.data
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
export const modelCrudReducer = modelCrudSlice.reducer
|
||||
|
||||
export const modelCrudSelector = state => state.modelCrudReducer
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import { createSlice } from '@reduxjs/toolkit'
|
||||
import renderCrudAsyncThunk from '../asyncThunks/renderCrudAsyncThunk'
|
||||
|
||||
const renderCrudSlice = createSlice(
|
||||
{
|
||||
name: 'render',
|
||||
initialState: {
|
||||
models_list: [],
|
||||
download_zip_file: ''
|
||||
},
|
||||
reducers: {},
|
||||
extraReducers: {
|
||||
[renderCrudAsyncThunk.fetchGetAllRenders.fulfilled.type]: (state, action) => {
|
||||
state.renders_list = action.payload.data
|
||||
},
|
||||
[renderCrudAsyncThunk.fetchGetOneRenderAndDownload.fulfilled.type]: (state, action) => {
|
||||
state.download_zip_file = action.payload.data
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
export const renderCrudReducer = renderCrudSlice.reducer
|
||||
|
||||
export const renderCrudSelector = state => state.renderCrudReducer
|
||||
Loading…
Reference in New Issue