| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import { createSlice, PayloadAction } from "@reduxjs/toolkit";
- import loadingSlice from "../loading/loadingSlice";
- const popupSlice = createSlice({
- name: "popup",
- initialState: {
- notification: {
- isOpen: false,
- isSuccess: true,
- title: "Notification",
- message: "",
- buttonText: "Close",
- hasRightButton: false,
- rightButtonText: "Confirm",
- rightButtonAction: "",
- },
- compatibilityModal: {
- isOpen: false,
- },
- qrModal: {
- isOpen: false,
- qrData: "",
- },
- },
- reducers: {
- openPopup: (state, action: PayloadAction<any>) => {
- return {
- ...state,
- notification: {
- isOpen: true,
- isSuccess: action.payload?.isSuccess ?? true,
- title: action.payload?.title ?? "Notification",
- message: action.payload?.message,
- buttonText: action.payload?.buttonText ?? "Close",
- hasRightButton: action.payload?.hasRightButton ?? false,
- rightButtonText: action.payload?.rightButtonText ?? "Confirm",
- rightButtonAction: action.payload?.rightButtonAction ?? "",
- },
- };
- },
- closePopup: (state) => {
- state.notification.isOpen = false;
- },
- openCompatibilityModal: (state) => {
- state.compatibilityModal.isOpen = true;
- },
- closeCompatibilityModal: (state) => {
- state.compatibilityModal.isOpen = false;
- },
- openQRModal: (state, action: PayloadAction<string>) => {
- state.qrModal.isOpen = true;
- state.qrModal.qrData = action.payload;
- },
- closeQRModal: (state) => {
- state.qrModal.isOpen = false;
- },
- },
- });
- export const {
- openPopup,
- closePopup,
- openCompatibilityModal,
- closeCompatibilityModal,
- openQRModal,
- closeQRModal,
- } = popupSlice.actions;
- export default popupSlice.reducer;
|