Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | 541x 541x 21x 22x 541x 78x 541x 2x 541x 541x 541x 541x | import { RootState } from "@redux/types/store";
import { PayloadAction, createSlice } from "@reduxjs/toolkit";
import { ContentState, EditorState } from "draft-js";
import { ThankYouCustomization } from "@sections/Checkout/ThankYouCustomization";
import { CheckoutState } from "./types";
const initialState: CheckoutState = {
checkoutCardType: "",
isRecurring: false,
selectedVariant: {
fundraiser: {
min: 10,
max: 25000,
},
invoice: {
min: 10,
max: 25000,
},
},
currentCampaign: {
title: "",
},
thankYouPage: {
customMessage: {
text: EditorState.createWithContent(
ContentState.createFromText(
"We wanted to take a moment to express our heartfelt gratitude for your generous contribution to. Your support is vital to our mission, and we are deeply grateful for your commitment. We will make sure that your contribution is used wisely and effectively to achieve our goals. Please know that your generosity is deeply appreciated.",
),
),
},
redirectUsers: {
active: false,
redirectURL: "",
},
displayIllustration: false,
},
saveChangesEnabled: false,
};
const checkoutSlice = createSlice({
name: "checkout",
initialState,
reducers: {
setCheckoutCardType: (
state: CheckoutState,
action: PayloadAction<string>,
) => {
state.checkoutCardType = action.payload;
},
setCurrentCampaign: (
state: CheckoutState,
action: PayloadAction<Partial<{ title: string }>>,
) => {
state.currentCampaign = {
...state.currentCampaign,
...action.payload,
};
},
setIsPaymentRecurring: (
state: CheckoutState,
action: PayloadAction<boolean>,
) => {
state.isRecurring = action.payload;
},
setSelectedVariant: (state: CheckoutState, action: PayloadAction<any>) => {
(state.selectedVariant as any)[action.payload.type] = action.payload;
},
setThankYouSettings: (
state: CheckoutState,
action: PayloadAction<ThankYouCustomization>,
) => {
state.thankYouPage = action.payload;
},
switchSaveChangesEnabled: (
state: CheckoutState,
action: PayloadAction<boolean>,
) => {
state.saveChangesEnabled = action.payload;
},
},
});
export const selectCardType = (state: RootState) =>
state.checkout.checkoutCardType;
export const selectIsPaymentRecurring = (state: RootState) =>
state.checkout.isRecurring;
export const selectVariant = (state: RootState) =>
state.checkout.selectedVariant;
export const selectCurrentCampaign = (state: RootState) =>
state.checkout.currentCampaign;
export const selectThankYouSettings = (state: RootState) =>
state.checkout.thankYouPage;
export const {
setCheckoutCardType,
setIsPaymentRecurring,
setSelectedVariant,
setCurrentCampaign,
setThankYouSettings,
switchSaveChangesEnabled,
} = checkoutSlice.actions;
export default checkoutSlice.reducer;
|