parent
9100449a61
commit
dc55a46cf9
@ -0,0 +1,32 @@
|
|||||||
|
import {createSlice} from "@reduxjs/toolkit";
|
||||||
|
import {timeFormatEnum} from "@perm-hack/ui";
|
||||||
|
|
||||||
|
|
||||||
|
export interface IStatFilters {
|
||||||
|
data: {
|
||||||
|
start_date: string
|
||||||
|
} | {
|
||||||
|
start_data: string,
|
||||||
|
end_date: string
|
||||||
|
} | {}
|
||||||
|
type: "date" | "period"
|
||||||
|
}
|
||||||
|
|
||||||
|
const initialState: IStatFilters = {
|
||||||
|
data: {},
|
||||||
|
type: "date"
|
||||||
|
}
|
||||||
|
const statisticsFilterSlice = createSlice({
|
||||||
|
name: "statFilter",
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
setData: (state, action) => {
|
||||||
|
state.data = action.payload;
|
||||||
|
},
|
||||||
|
setType: (state, action) => {
|
||||||
|
state.type = state.type === "date" ? "period" : "date"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
export const {setData, setType} = statisticsFilterSlice.actions;
|
||||||
|
export default statisticsFilterSlice.reducer
|
@ -0,0 +1,20 @@
|
|||||||
|
import {configureStore} from "@reduxjs/toolkit"
|
||||||
|
import {TypedUseSelectorHook, useDispatch, useSelector} from "react-redux";
|
||||||
|
import statisticsFilterSlice from "./features/statisticsFilterSlice";
|
||||||
|
import {statisticsFilterApi} from "./services/statisticsFilterApi";
|
||||||
|
|
||||||
|
const store = configureStore({
|
||||||
|
reducer: {
|
||||||
|
statFilter: statisticsFilterSlice,
|
||||||
|
[statisticsFilterApi.reducerPath]: statisticsFilterApi.reducer
|
||||||
|
},
|
||||||
|
middleware: (getDefaultMiddleware) =>
|
||||||
|
getDefaultMiddleware().concat(statisticsFilterApi.middleware),
|
||||||
|
})
|
||||||
|
export default store;
|
||||||
|
|
||||||
|
export type RootState = ReturnType<typeof store.getState>;
|
||||||
|
export type AppDispatch = typeof store.dispatch;
|
||||||
|
export const useAppDispatch: (data: any) => AppDispatch = useDispatch // Export a hook that can be reused to resolve types
|
||||||
|
|
||||||
|
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
|
@ -0,0 +1,16 @@
|
|||||||
|
import {createApi, fetchBaseQuery} from "@reduxjs/toolkit/query/react";
|
||||||
|
|
||||||
|
export const statisticsFilterApi = createApi({
|
||||||
|
reducerPath: "statFilterApi",
|
||||||
|
baseQuery: fetchBaseQuery({baseUrl: "https://ayin.k-lab.su/api/analytics"}),
|
||||||
|
endpoints: (build) => ({
|
||||||
|
getDate: build.mutation({
|
||||||
|
query: (data) => ({
|
||||||
|
url: '/all',
|
||||||
|
method: 'POST',
|
||||||
|
body: data,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
export const {useGetDateMutation} = statisticsFilterApi
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,3 @@
|
|||||||
.container {
|
.container {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
.container {
|
.container {
|
||||||
|
grid-area: 1 / 1 / 2 / 6;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
gap: 30px;
|
gap: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
color: var(--white);
|
color: var(--white);
|
||||||
background-color: #94BF5E;
|
background-color: #94BF5E;
|
||||||
|
|
||||||
|
&:disabled {
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue