From c91f2b97c5a08c28f013d71dd061d3ee2303425c Mon Sep 17 00:00:00 2001 From: inspector44 Date: Fri, 12 Jan 2024 11:19:55 +0000 Subject: [PATCH] implement toast reducer --- ui/src/helpers/icons.tsx | 138 +++++++++++++++---------------- ui/src/store/rootReducer.ts | 2 + ui/src/store/toastSlice/index.ts | 29 +++++++ 3 files changed, 100 insertions(+), 69 deletions(-) create mode 100644 ui/src/store/toastSlice/index.ts diff --git a/ui/src/helpers/icons.tsx b/ui/src/helpers/icons.tsx index bcaaf34..40f9033 100644 --- a/ui/src/helpers/icons.tsx +++ b/ui/src/helpers/icons.tsx @@ -31,9 +31,9 @@ export const ArrowDown: FC = ({ width, height, fillColor }) => ( ); @@ -46,8 +46,8 @@ export const ArrowRight: FC = ({ width, height, fillColor }) => ( xmlns="http://www.w3.org/2000/svg" > @@ -120,58 +120,58 @@ export const ProcessIcon: FC = ({ width, height, fillColor }) => ( ); @@ -187,30 +187,30 @@ export const ChangeChain: FC = ({ width, height, fillColor }) => ( ); @@ -222,7 +222,7 @@ export const DottedLine: FC = ({ width, height, fillColor }) => ( viewBox="0 0 250 2" fill="none" > - + ); export const TelegramLogo: FC = ({ width, height, fillColor }) => ( @@ -236,16 +236,16 @@ export const TelegramLogo: FC = ({ width, height, fillColor }) => ( ); @@ -304,22 +304,22 @@ export const YoutubeLogo: FC = ({ width, height, fillColor }) => ( xmlns="http://www.w3.org/2000/svg" > ); @@ -334,25 +334,25 @@ export const MediumLogo: FC = ({ width, height, fillColor }) => ( ); diff --git a/ui/src/store/rootReducer.ts b/ui/src/store/rootReducer.ts index c37d0da..088a263 100644 --- a/ui/src/store/rootReducer.ts +++ b/ui/src/store/rootReducer.ts @@ -1,8 +1,10 @@ import { combineReducers } from "@reduxjs/toolkit"; import dataSlice from "./dataSlice"; +import toastReducer from './toastSlice'; const createReducer = combineReducers({ dataSlice, + toast: toastReducer, }); export default createReducer; diff --git a/ui/src/store/toastSlice/index.ts b/ui/src/store/toastSlice/index.ts new file mode 100644 index 0000000..79fba51 --- /dev/null +++ b/ui/src/store/toastSlice/index.ts @@ -0,0 +1,29 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; + +interface ToastState { + type: 'success' | 'error' | 'info' | 'warning' | null; + message: string | null; +} + +const initialState: ToastState = { + type: null, + message: null, +}; + +const toastSlice = createSlice({ + name: 'toast', + initialState, + reducers: { + setToast: (state, action: PayloadAction) => { + state.type = action.payload.type; + state.message = action.payload.message; + }, + clearToast: (state) => { + state.type = null; + state.message = null; + }, + }, +}); + +export const { setToast, clearToast } = toastSlice.actions; +export default toastSlice.reducer;