Redux -> simple fixes in async thunks & add model & render crud slicers

feature/0_redux_slices
TBS093A 2021-02-17 10:58:17 +01:00
parent 0131d75f8b
commit a8f55c540d
4 changed files with 58 additions and 2 deletions

View File

@ -0,0 +1 @@
export const GeneralAddress = 'localhost:9090'

View File

@ -1,7 +1,7 @@
import axios from 'axios'
import { GeneralAddress } from './abstractAddress'
const APIAddress = 'http://localhost:9090'
const APIAddress = 'http://' + GeneralAddress
let defaultBody = ''

View File

@ -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

View File

@ -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