import axios from 'axios'; import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'; import { axiosRetailInstanceData, axiosCommonInstanceData, } from '../AuthenicationToken/AuthenticationToken'; import { getSession } from '../../Services/Others'; const apiUrl = import.meta.env.ENV_API_URL; const apiCommonUrl = import.meta.env.ENV_API_URL_COMMON; export const getColors = createAsyncThunk('theme/getColors', async () => { return axiosRetailInstanceData.get(`/color?ActiveStatus=A`); }); export const getLayoutOverallBackgroundColors = createAsyncThunk( 'theme/getLayoutOverallBackgroundColors', async (data) => { if ( data?.SessionID != null && data?.SessionID != undefined && data?.OptionName != null && data?.OptionName != undefined ) { return axiosRetailInstanceData.get( `/color?ActiveStatus=A&sessionId=${data?.SessionID}&OptionName=${data?.OptionName}` ); } } ); export const getCategoryOverallBackgroundColors = createAsyncThunk( 'theme/getCategoryOverallBackgroundColors', async (data) => { if ( data?.SessionID != null && data?.SessionID != undefined && data?.OptionName != null && data?.OptionName != undefined ) { return axiosRetailInstanceData.get( `/color?ActiveStatus=A&sessionId=${data?.SessionID}&OptionName=${data?.OptionName}` ); } } ); export const getSubcategoryOverallBackgroundColors = createAsyncThunk( 'theme/getSubcategoryOverallBackgroundColors', async (data) => { if ( data?.SessionID != null && data?.SessionID != undefined && data?.OptionName != null && data?.OptionName != undefined ) { return axiosRetailInstanceData.get( `/color?ActiveStatus=A&sessionId=${data?.SessionID}&OptionName=${data?.OptionName}` ); } } ); export const getCardOverallBackgroundColors = createAsyncThunk( 'theme/getCardOverallBackgroundColors', async (data) => { if ( data?.SessionID != null && data?.SessionID != undefined && data?.OptionName != null && data?.OptionName != undefined ) { return axiosRetailInstanceData.get( `/color?ActiveStatus=A&sessionId=${data?.SessionID}&OptionName=${data?.OptionName}` ); } } ); export const getBillingOverallBackgroundColors = createAsyncThunk( 'theme/getBillingOverallBackgroundColors', async (data) => { if ( data?.SessionID != null && data?.SessionID != undefined && data?.OptionName != null && data?.OptionName != undefined ) { return axiosRetailInstanceData.get( `/color?ActiveStatus=A&sessionId=${data?.SessionID}&OptionName=${data?.OptionName}` ); } } ); export const getColorsCat = createAsyncThunk( 'theme/getColorsCat', async (data) => { if ( data?.SessionID != null && data?.SessionID != undefined && data?.OptionName != null && data?.OptionName != undefined ) { return axiosRetailInstanceData.get( `/color?ActiveStatus=A&sessionId=${data?.SessionID}&OptionName=${data?.OptionName}` ); } } ); export const getColorsSubcat = createAsyncThunk( 'theme/getColorsSubcat', async (data) => { if ( data?.SessionID != null && data?.SessionID != undefined && data?.OptionName != null && data?.OptionName != undefined ) { return axiosRetailInstanceData.get( `/color?ActiveStatus=A&sessionId=${data?.SessionID}&OptionName=${data?.OptionName}` ); } } ); export const getColorsCard = createAsyncThunk( 'theme/getColorsCard', async (data) => { if ( data?.SessionID != null && data?.SessionID != undefined && data?.OptionName != null && data?.OptionName != undefined ) { return axiosRetailInstanceData.get( `/color?ActiveStatus=A&sessionId=${data?.SessionID}&OptionName=${data?.OptionName}` ); } } ); export const getColorsBilltable = createAsyncThunk( 'theme/getColorsBilltable', async (data) => { if ( data?.SessionID != null && data?.SessionID != undefined && data?.OptionName != null && data?.OptionName != undefined ) { return axiosRetailInstanceData.get( `/color?ActiveStatus=A&sessionId=${data?.SessionID}&OptionName=${data?.OptionName}` ); } } ); export const getCatFonts = createAsyncThunk( 'theme/getCatFonts', async (data) => { if (data != null && data != undefined) { return axiosRetailInstanceData.get( `/font?ActiveStatus=A&sessionId=${data}` ); } } ); export const getSubCatFonts = createAsyncThunk( 'theme/getSubCatFonts', async (data) => { if (data != null && data != undefined) { return axiosRetailInstanceData.get( `/font?ActiveStatus=A&sessionId=${data}` ); } } ); export const getCardFonts = createAsyncThunk( 'theme/getCardFonts', async (data) => { if (data != null && data != undefined) { return axiosRetailInstanceData.get( `/font?ActiveStatus=A&sessionId=${data}` ); } } ); export const getTableFonts = createAsyncThunk( 'theme/getTableFonts', async (data) => { if (data != null && data != undefined) { return axiosRetailInstanceData.get( `/font?ActiveStatus=A&sessionId=${data}` ); } } ); export const getTemplate = createAsyncThunk( 'theme/getTemplate', async ({ CompId, BranchId, AppId }) => { if ( CompId != null && CompId != undefined && BranchId != null && BranchId != undefined && AppId != null && AppId != undefined ) { return axiosRetailInstanceData.get( `/template?CompId=${CompId}&BranchId=${BranchId}&AppId=${AppId}` ); } else { } } ); export const getOthersTemplate = createAsyncThunk( 'theme/getOthersTemplate', async ({ pagenumber }) => { return axiosRetailInstanceData.get( `/template?Type=O&PageNumber=${pagenumber}` ); } ); export const getThemes = createAsyncThunk('theme/getThemes', async () => { return axiosRetailInstanceData.get(`/template`); }); export const deleteThemeTemplate = createAsyncThunk( 'theme/deleteThemeTemplate', async (Data) => { return await axiosRetailInstanceData.delete( `/Template?templatePreferenceId=${Data?.templatePreferenceId}&updatedBy=${Data?.UpdatedBy}&activeStatus=${Data?.ActiveStatus}`, Data ); } ); export const postColorData = createAsyncThunk( 'theme/postColorData', async (postData) => { return await axiosRetailInstanceData.post(`/color`, postData); } ); export const postCatFontData = createAsyncThunk( 'theme/postCatFontData', async (postData) => { return await axiosRetailInstanceData.post(`/font`, postData); } ); export const postSubcatFontData = createAsyncThunk( 'theme/postSubcatFontData', async (postData) => { return await axiosRetailInstanceData.post(`/font`, postData); } ); export const postCardFontData = createAsyncThunk( 'theme/postCardFontData', async (postData) => { return await axiosRetailInstanceData.post(`/font`, postData); } ); export const postTableFontData = createAsyncThunk( 'theme/postTableFontData', async (postData) => { return await axiosRetailInstanceData.post(`/font`, postData); } ); export const getLayout = createAsyncThunk('theme/getLayout', async () => { return await axiosRetailInstanceData.get( `/component?SessionName=BookingLayout` ); }); export const getNavbar = createAsyncThunk('theme/getNavbar', async () => { return await axiosRetailInstanceData.get( `/component?SessionName=BookingNavbar` ); }); export const getCategory = createAsyncThunk('theme/getCategory', async () => { return await axiosRetailInstanceData.get( `/component?SessionName=BookingCategory` ); }); export const getCard = createAsyncThunk('theme/getCard', async () => { return await axiosRetailInstanceData.get( `/component?SessionName=BookingCard` ); }); export const getSubCategory = createAsyncThunk( 'theme/getSubCategory', async () => { return await axiosRetailInstanceData.get( `/component?SessionName=BookingSubCategory` ); } ); export const getBillingTable = createAsyncThunk( 'theme/getBillingTable', async () => { return await axiosRetailInstanceData.get( `/component?SessionName=BookingBilling` ); } ); export const getCombo1Navbar = createAsyncThunk( 'theme/getCombo1Navbat', async () => { return await axiosRetailInstanceData.get( `/component?SessionName=BookingCombo1` ); } ); export const getCombo2Navbar = createAsyncThunk( 'theme/getCombo2Navbar', async () => { return await axiosRetailInstanceData.get( `/component?SessionName=BookingCombo2` ); } ); export const getPrintOptions = createAsyncThunk( 'theme/getPrintOptions', async ({ Data }) => { return await axiosRetailInstanceData.get(`/ConfigMaster?typeName=${Data}`); } ); export const postSelectionComponentData = createAsyncThunk( 'theme/postOverAllData', async (postData) => { return await axiosRetailInstanceData.post(`/template`, postData); } ); export const putSelectionComponentData = createAsyncThunk( 'theme/putOverAllData', async (putData) => { return await axiosRetailInstanceData.put(`/template`, putData); } ); export const postPrintSelectionComponentData = createAsyncThunk( 'theme/postPrintSelectionComponentData', async (postData) => { return await axiosRetailInstanceData.post(`/PrintTemplate`, postData); } ); export const putPrintSelectionComponentData = createAsyncThunk( 'theme/putPrintSelectionComponentData', async (putData) => { return await axiosRetailInstanceData.put(`/PrintTemplate`, putData); } ); export const getPrintSelectionComponentData = createAsyncThunk( 'theme/getPrintSelectionComponentData', async (Data) => { return await axiosRetailInstanceData.get( `${apiUrl}/PrintTemplate?compId=${Data.CompId}&branchId=${Data.BranchId}&appId=${Data.AppId}` ); } ); export const getSalesTemplate = createAsyncThunk( 'theme/getSalesTemplate', async (Data) => { return await axiosRetailInstanceData.get( `${apiUrl}/ThemeMaster?compId=${Data.CompId}&branchId=${Data.BranchId}&appId=${Data.AppId}` ); } ); export const PricingAppPricingNameData = createAsyncThunk( 'theme/PricingAppPricingNameData', async (data) => { if ( data?.appId != null && data?.appId != undefined && data?.compId != null && data?.compId != undefined && data?.branchId != null && data?.branchId != undefined ) { return await axios.get( `${apiCommonUrl}/PricingAppFeatMap?appId=${data?.appId}&compId=${data?.compId}&branchId=${data?.branchId}` ); } else if ( data?.appId != null && data?.appId != undefined && data?.userId != null && data?.userId != undefined ) { return await axios.get( `${apiCommonUrl}/PricingAppFeatMap?appId=${data?.appId}&userId=${data?.userId}` ); } } ); export const FeatureAddon = createAsyncThunk( 'theme/FeatureAddon', async ({ UserId, AppId }) => { const UserType = getSession('UserType'); if ( UserId != null && UserId != undefined && AppId != null && AppId != undefined && UserType !== 'Super Admin' && UserType !== 'Super Admin User' ) { return await axios.get( `${apiCommonUrl}/UAMFeatAddon?AppId=${AppId}&UserId=${UserId}` ); } } ); export const getPrinterMappingDetails = createAsyncThunk( 'theme/getPrinterMappingDetails', async (Data) => { if (Data.UserId != null && Data.UserId != undefined) { return await axiosRetailInstanceData.get( `/PrintMapping?compId=${Data.CompId}&branchId=${Data.BranchId}&appId=${Data.AppId}&userId=${Data.UserId}` ); } else { return await axiosRetailInstanceData.get( `/PrintMapping?compId=${Data.CompId}&branchId=${Data.BranchId}&appId=${Data.AppId}` ); } } ); export const getKioskDevices = createAsyncThunk( 'theme/getKioskDevices', async (Data) => { return await axiosRetailInstanceData.get( `/getKisokDevice?compId=${Data.CompId}&branchId=${Data.BranchId}&appId=${Data.AppId}` ); } ); export const putPrinterMapping = createAsyncThunk( 'theme/postPrinterMapping', async (postData) => { return await axiosRetailInstanceData.put(`/PrintMapping`, postData); } ); const initialState = { ReprintDataFound: false, PrintdummyData: false, printSize: null, printStyle: null, SlNo: false, Item: false, MRP: false, Discount: false, Tax: false, Quantity: false, Rate: false, Amount: false, HsnCode: false, Qrcode: false, Signature: false, CashierName: false, Logo: false, Credit: false, termsAndConditions: false, themeFormat: false, notes: false, SignatureImage: '', BillName: '', SelectedHeaderColor: '#000000', allColors: [], allColorsCat: [], LayoutOverallColorsList: [], CategoryOverallColorsList: [], cardOverallColorsList: [], SubcategoryOverallColorsList: [], BillingOverallColorsList: [], allColorsSubcat: [], allColorsCard: [], allColorsBillTable: [], allFonts: [], catFont: [], subFont: [], cardFont: [], tableFont: [], CurrentColor: { darkColor: '#37943C', lightColor: '#b2eb9b', }, CurrentText: { head: 'Gilroy', para: 'Poppins', }, templateData: {}, colorId: [], fontId: [], OverallColorId: null, SelectedLayout: null, SelectedNavbar: null, SelectedCategory: null, SelectedSubCategory: null, SelectedCard: null, SelectedBillingTable: null, SelectedNavbarCheckedItems: [], SelectedCategoryCheckedItems: [], SelectedSubCategoryCheckedItems: [], SelectedCardCheckedItems: [], SelectedBillTableCheckedItems: [], previewData: {}, SelectedLayoutColorDetail: { OverallBackgroundColor: null }, SelectedCardColorDetail: { BackgroundColor: '#ffffff', FontColor: '#000000', OverallBackgroundColor: null, }, SelectedBillingColorDetail: { BackgroundColor: '#ffffff', FontColor: '#000000', OverallBackgroundColor: null, }, SelectedCatgColorDetail: { BackgroundColor: '#ffffff', FontColor: '#000000', OverallBackgroundColor: null, }, SelectedSubCatgColorDetail: { BackgroundColor: '#ffffff', FontColor: '#000000', OverallBackgroundColor: null, }, SelectedCardFont: 'Poppins', SelectedBillingFont: 'Gilroy', SelectedCatgFont: 'Gilroy', SelectedSubCatgFont: 'Poppins', PrintTemplate: null, DCPrintTemplate: null, PrintFieldDetails: null, PricingAppPricingName: null, FeatureAddonData: [], SessionData: [], ThemeCreation: {}, printDatas: {}, DefaultTheme: [], OthersTheme: [], SelectedTheme: {}, ActiveTheme: 'default', ScanTemplate: {}, CustThemeData: 'Layout2', PrinterMappingDtls: [], }; const ThemeSlice = createSlice({ name: 'theme', initialState, reducers: { changetemplateData: (state, action) => { state.SelectedApplication = { AppId: action?.payload?.SelectedApplication, }; state.AppName = action?.payload?.AppName; console.log(action?.payload?.Type, 'action?.payload?.Type'); if (action?.payload?.Type == 'Advance') { if (Object.keys(state.templateData)?.length == 0) { state.fontId = [1, 4, 5]; state.colorId = [43]; state.SelectedCardFont = 'Poppins'; state.SelectedBillingColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.SelectedBillingFont = 'Gilroy'; state.SelectedCatgColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.SelectedCatgFont = 'Gilroy'; state.SelectedLayoutColorDetail = { OverallBackgroundColor: null }; state.SelectedCardColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.templateData = { BookingLayout: [ 'Layout2', [ { TemplateOptionsId: 71805, OptionId: 45, OptionName: 'Category', }, { TemplateOptionsId: 71807, OptionId: 47, OptionName: 'Card', }, { TemplateOptionsId: 71808, OptionId: 48, OptionName: 'Billing', }, { TemplateOptionsId: 71809, OptionId: 166, OptionName: 'Navbar', }, ], ], BookingNavbar: [ 'Navbar3', [ { TemplateOptionsId: 71811, OptionId: 74, OptionName: 'Search', }, { TemplateOptionsId: 71812, OptionId: 75, OptionName: 'RePrint', }, { TemplateOptionsId: 71813, OptionId: 77, OptionName: 'QuickAdd', }, { TemplateOptionsId: 71814, OptionId: 76, OptionName: 'DineIn', }, { TemplateOptionsId: 71815, OptionId: 79, OptionName: 'TakeAway', }, { TemplateOptionsId: 71816, OptionId: 80, OptionName: 'Offer', }, { TemplateOptionsId: 71817, OptionId: 82, OptionName: 'ExtraCharge', }, { TemplateOptionsId: 71825, OptionId: 130, OptionName: 'Hold', }, { TemplateOptionsId: 71826, OptionId: 172, OptionName: 'AddCustomer', }, ], ], BookingCategory: [ 'Category5', [ { TemplateOptionsId: 71818, OptionId: 95, OptionName: 'Image', }, { TemplateOptionsId: 71819, OptionId: 96, OptionName: 'Background', }, ], ], BookingCard: [ 'Card4', [ { TemplateOptionsId: 71821, OptionId: 117, OptionName: 'Background', }, { TemplateOptionsId: 71822, OptionId: 119, OptionName: 'Price', }, { TemplateOptionsId: 71823, OptionId: 120, OptionName: 'SmallImage', }, { TemplateOptionsId: 71824, OptionId: 121, OptionName: 'ImageLeft', }, ], ], BookingBilling: [ 'StandardBilling', [ { TemplateOptionsId: 71825, OptionId: 130, OptionName: 'Hold', }, { TemplateOptionsId: 71825, OptionId: 130, OptionName: 'DineIn', }, { TemplateOptionsId: 71826, OptionId: 171, OptionName: 'Background', }, { TemplateOptionsId: 71826, OptionId: 172, OptionName: 'AddCustomer', }, { TemplateOptionsId: 71828, OptionId: 210, OptionName: 'Sl.No', }, { TemplateOptionsId: 71829, OptionId: 211, OptionName: 'Item', }, { TemplateOptionsId: 71830, OptionId: 214, OptionName: 'Quantity', }, { TemplateOptionsId: 71831, OptionId: 216, OptionName: 'Amount', }, { TemplateOptionsId: 71832, OptionId: 217, OptionName: 'Edit', }, { TemplateOptionsId: 71833, OptionId: 218, OptionName: 'Delete', }, ], ], }; // state.fontId = [1, 4, 5]; // state.colorId = [43]; // state.SelectedCardFont = 'Poppins'; // state.SelectedBillingColorDetail = { // BackgroundColor: '#cfd8dc', // FontColor: '#000000', // OverallBackgroundColor: null, // }; // state.SelectedBillingFont = 'Gilroy'; // state.SelectedCatgColorDetail = { // BackgroundColor: '#cfd8dc', // FontColor: '#000000', // OverallBackgroundColor: null, // }; // state.SelectedSubCatgColorDetail = { // BackgroundColor: '#cfd8dc', // FontColor: '#000000', // OverallBackgroundColor: null, // }; // state.SelectedCatgFont = 'Gilroy'; // state.SelectedLayoutColorDetail = { OverallBackgroundColor: null }; // state.SelectedCardColorDetail = { // BackgroundColor: '#cfd8dc', // FontColor: '#000000', // OverallBackgroundColor: null, // }; // state.templateData = { // BookingLayout: [ // 'Layout1', // [ // { // TemplateOptionsId: 71805, // OptionId: 45, // OptionName: 'Category', // }, // { // TemplateOptionsId: 71805, // OptionId: 46, // OptionName: 'SubCategory', // }, // { // TemplateOptionsId: 71807, // OptionId: 47, // OptionName: 'Card', // }, // { // TemplateOptionsId: 71808, // OptionId: 48, // OptionName: 'Billing', // }, // { // TemplateOptionsId: 71809, // OptionId: 166, // OptionName: 'Navbar', // }, // ], // ], // BookingNavbar: [ // 'Navbar1', // [ // { // TemplateOptionsId: 71811, // OptionId: 74, // OptionName: 'Search', // }, // { // TemplateOptionsId: 71812, // OptionId: 75, // OptionName: 'RePrint', // }, // { // TemplateOptionsId: 71813, // OptionId: 77, // OptionName: 'QuickAdd', // }, // { // TemplateOptionsId: 71814, // OptionId: 76, // OptionName: 'DineIn', // }, // { // TemplateOptionsId: 71815, // OptionId: 79, // OptionName: 'TakeAway', // }, // { // TemplateOptionsId: 71816, // OptionId: 80, // OptionName: 'Offer', // }, // { // TemplateOptionsId: 71817, // OptionId: 82, // OptionName: 'ExtraCharge', // }, // ], // ], // BookingCategory: [ // 'Category1', // [ // { // TemplateOptionsId: 71818, // OptionId: 95, // OptionName: 'Image', // }, // { // TemplateOptionsId: 71819, // OptionId: 96, // OptionName: 'Background', // }, // ], // ], // BookingSubCategory: [ // 'SubCategory1', // [ // { // TemplateOptionsId: 71819, // OptionId: 97, // OptionName: 'Background', // }, // ], // ], // BookingCard: [ // 'Card2', // [ // { // TemplateOptionsId: 71821, // OptionId: 117, // OptionName: 'Background', // }, // { // TemplateOptionsId: 71822, // OptionId: 119, // OptionName: 'Price', // }, // { // TemplateOptionsId: 71823, // OptionId: 120, // OptionName: 'SmallImage', // }, // { // TemplateOptionsId: 71824, // OptionId: 121, // OptionName: 'ImageLeft', // }, // { // TemplateOptionsId: 71825, // OptionId: 122, // OptionName: 'StockCount', // }, // ], // ], // BookingBilling: [ // 'Billing3', // [ // { // TemplateOptionsId: 71826, // OptionId: 130, // OptionName: 'Hold', // }, // { // TemplateOptionsId: 71827, // OptionId: 171, // OptionName: 'Background', // }, // { // TemplateOptionsId: 71828, // OptionId: 172, // OptionName: 'AddCustomer', // }, // { // TemplateOptionsId: 71830, // OptionId: 210, // OptionName: 'Sl.No', // }, // { // TemplateOptionsId: 71831, // OptionId: 211, // OptionName: 'Item', // }, // { // TemplateOptionsId: 71832, // OptionId: 214, // OptionName: 'Quantity', // }, // { // TemplateOptionsId: 71833, // OptionId: 216, // OptionName: 'Amount', // }, // { // TemplateOptionsId: 71834, // OptionId: 217, // OptionName: 'Edit', // }, // { // TemplateOptionsId: 71835, // OptionId: 218, // OptionName: 'Delete', // }, // ], // ], // }; } } else if (action?.payload?.Type == 'Pro') { state.fontId = [1, 4, 5]; state.colorId = [43]; state.SelectedCardFont = 'Poppins'; state.SelectedBillingColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.SelectedBillingFont = 'Gilroy'; state.SelectedCatgColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.SelectedSubCatgColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.SelectedCatgFont = 'Gilroy'; state.SelectedLayoutColorDetail = { OverallBackgroundColor: null }; state.SelectedCardColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.templateData = { BookingLayout: [ 'Layout1', [ { TemplateOptionsId: 71805, OptionId: 45, OptionName: 'Category', }, { TemplateOptionsId: 71805, OptionId: 46, OptionName: 'SubCategory', }, { TemplateOptionsId: 71807, OptionId: 47, OptionName: 'Card', }, { TemplateOptionsId: 71808, OptionId: 48, OptionName: 'Billing', }, { TemplateOptionsId: 71809, OptionId: 166, OptionName: 'Navbar', }, ], ], BookingNavbar: [ 'Navbar1', [ { TemplateOptionsId: 71811, OptionId: 74, OptionName: 'Search', }, { TemplateOptionsId: 71812, OptionId: 75, OptionName: 'RePrint', }, { TemplateOptionsId: 71813, OptionId: 77, OptionName: 'QuickAdd', }, { TemplateOptionsId: 71814, OptionId: 76, OptionName: 'DineIn', }, { TemplateOptionsId: 71815, OptionId: 79, OptionName: 'TakeAway', }, { TemplateOptionsId: 71816, OptionId: 80, OptionName: 'Offer', }, { TemplateOptionsId: 71817, OptionId: 82, OptionName: 'ExtraCharge', }, ], ], BookingCategory: [ 'Category1', [ { TemplateOptionsId: 71818, OptionId: 95, OptionName: 'Image', }, { TemplateOptionsId: 71819, OptionId: 96, OptionName: 'Background', }, ], ], BookingSubCategory: [ 'SubCategory1', [ { TemplateOptionsId: 71819, OptionId: 97, OptionName: 'Background', }, ], ], BookingCard: [ 'Card2', [ { TemplateOptionsId: 71821, OptionId: 117, OptionName: 'Background', }, { TemplateOptionsId: 71822, OptionId: 119, OptionName: 'Price', }, { TemplateOptionsId: 71823, OptionId: 120, OptionName: 'SmallImage', }, { TemplateOptionsId: 71824, OptionId: 121, OptionName: 'ImageLeft', }, { TemplateOptionsId: 71825, OptionId: 122, OptionName: 'StockCount', }, ], ], BookingBilling: [ 'Billing3', [ { TemplateOptionsId: 71826, OptionId: 130, OptionName: 'Hold', }, { TemplateOptionsId: 71827, OptionId: 171, OptionName: 'Background', }, { TemplateOptionsId: 71828, OptionId: 172, OptionName: 'AddCustomer', }, { TemplateOptionsId: 71830, OptionId: 210, OptionName: 'Sl.No', }, { TemplateOptionsId: 71831, OptionId: 211, OptionName: 'Item', }, { TemplateOptionsId: 71832, OptionId: 214, OptionName: 'Quantity', }, { TemplateOptionsId: 71833, OptionId: 216, OptionName: 'Amount', }, { TemplateOptionsId: 71834, OptionId: 217, OptionName: 'Edit', }, { TemplateOptionsId: 71835, OptionId: 218, OptionName: 'Delete', }, ], ], }; } else if (action?.payload?.Type == 'ParkingRedirect') { state.fontId = [1, 4, 5]; state.colorId = [43]; state.SelectedCardFont = 'Poppins'; state.SelectedBillingColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.SelectedBillingFont = 'Gilroy'; state.SelectedCatgColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.SelectedCatgFont = 'Gilroy'; state.SelectedLayoutColorDetail = { OverallBackgroundColor: null }; state.SelectedCardColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.templateData = { BookingLayout: [ 'Layout1', [ { TemplateOptionsId: 71805, OptionId: 45, OptionName: 'Category', }, { TemplateOptionsId: 71807, OptionId: 47, OptionName: 'Card', }, { TemplateOptionsId: 71808, OptionId: 48, OptionName: 'Billing', }, { TemplateOptionsId: 71809, OptionId: 166, OptionName: 'Navbar', }, ], ], BookingNavbar: ['Navbar1', []], BookingCategory: ['Category1', []], BookingCard: ['Card2', []], BookingBilling: [ 'Billing1', [ { TemplateOptionsId: 71826, OptionId: 171, OptionName: 'Background', }, { TemplateOptionsId: 71828, OptionId: 210, OptionName: 'Sl.No', }, { TemplateOptionsId: 71829, OptionId: 211, OptionName: 'Item', }, { TemplateOptionsId: 71830, OptionId: 214, OptionName: 'Quantity', }, { TemplateOptionsId: 71831, OptionId: 216, OptionName: 'Amount', }, { TemplateOptionsId: 71832, OptionId: 217, OptionName: 'Edit', }, { TemplateOptionsId: 71833, OptionId: 218, OptionName: 'Delete', }, ], ], }; } //pro subcategory with layout // if (action?.payload.Type == "Pro") { // state.fontId = [1, 4, 5] // state.colorId = [43] // state.SelectedCardFont = "Poppins" // state.SelectedBillingColorDetail = { // 'BackgroundColor': "#cfd8dc", // 'FontColor': "#000000", // 'OverallBackgroundColor': null // } // state.SelectedBillingFont = "Gilroy" // state.SelectedCatgColorDetail = { // 'BackgroundColor': "#cfd8dc", // 'FontColor': "#000000", // 'OverallBackgroundColor': null // } // state.SelectedCatgFont = "Gilroy" // state.SelectedLayoutColorDetail = { OverallBackgroundColor: null } // state.SelectedCardColorDetail = { // 'BackgroundColor': "#cfd8dc", // 'FontColor': "#000000", // 'OverallBackgroundColor': null // } // state.templateData = // { // "BookingLayout": [ // "Layout2", // [ // { // "TemplateOptionsId": 71805, // "OptionId": 45, // "OptionName": "Category" // }, // { // "TemplateOptionsId": 71807, // "OptionId": 47, // "OptionName": "Card" // }, // { // "TemplateOptionsId": 71808, // "OptionId": 48, // "OptionName": "Billing" // }, // { // "TemplateOptionsId": 71809, // "OptionId": 166, // "OptionName": "Navbar" // }, // ] // ], // "BookingNavbar": [ // "Navbar1", // [ // { // "TemplateOptionsId": 71811, // "OptionId": 74, // "OptionName": "Search" // }, // { // "TemplateOptionsId": 71812, // "OptionId": 75, // "OptionName": "RePrint" // }, // { // "TemplateOptionsId": 71813, // "OptionId": 77, // "OptionName": "QuickAdd" // }, // { // "TemplateOptionsId": 71814, // "OptionId": 76, // "OptionName": "DineIn" // }, // { // "TemplateOptionsId": 71815, // "OptionId": 79, // "OptionName": "TakeAway" // }, // { // "TemplateOptionsId": 71816, // "OptionId": 80, // "OptionName": "Offer" // }, // { // "TemplateOptionsId": 71817, // "OptionId": 82, // "OptionName": "ExtraCharge" // }, // ] // ], // "BookingCategory": [ // "Category1", // [ // { // "TemplateOptionsId": 71818, // "OptionId": 95, // "OptionName": "Image" // }, // { // "TemplateOptionsId": 71819, // "OptionId": 96, // "OptionName": "Background" // } // ] // ], // "BookingCard": [ // "Card2", // [ // { // "TemplateOptionsId": 71821, // "OptionId": 117, // "OptionName": "Background" // }, // { // "TemplateOptionsId": 71822, // "OptionId": 119, // "OptionName": "Price" // }, // { // "TemplateOptionsId": 71823, // "OptionId": 120, // "OptionName": "SmallImage" // }, // { // "TemplateOptionsId": 71824, // "OptionId": 121, // "OptionName": "ImageLeft" // }, // { // "TemplateOptionsId": 71825, // "OptionId": 122, // "OptionName": "StockCount" // } // ] // ], // "BookingBilling": [ // "Billing3", // [ // { // "TemplateOptionsId": 71826, // "OptionId": 130, // "OptionName": "Hold" // }, // { // "TemplateOptionsId": 71827, // "OptionId": 171, // "OptionName": "Background" // }, // { // "TemplateOptionsId": 71828, // "OptionId": 172, // "OptionName": "AddCustomer" // }, // { // "TemplateOptionsId": 71830, // "OptionId": 210, // "OptionName": "Sl.No" // }, // { // "TemplateOptionsId": 71831, // "OptionId": 211, // "OptionName": "Item" // }, // { // "TemplateOptionsId": 71832, // "OptionId": 214, // "OptionName": "Quantity" // }, // { // "TemplateOptionsId": 71833, // "OptionId": 216, // "OptionName": "Amount" // }, // { // "TemplateOptionsId": 71834, // "OptionId": 217, // "OptionName": "Edit" // }, // { // "TemplateOptionsId": 71835, // "OptionId": 218, // "OptionName": "Delete" // } // ] // ] // } // } else { // if(action?.payload?.AppName != 'Restaurant'){ state.fontId = [1, 4, 5]; state.colorId = [43]; state.SelectedCardFont = 'Poppins'; state.SelectedBillingColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.SelectedBillingFont = 'Gilroy'; state.SelectedCatgColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.SelectedCatgFont = 'Gilroy'; state.SelectedLayoutColorDetail = { OverallBackgroundColor: null }; state.SelectedCardColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.templateData = { BookingLayout: [ 'Layout2', [ { TemplateOptionsId: 71805, OptionId: 45, OptionName: 'Category', }, { TemplateOptionsId: 71807, OptionId: 47, OptionName: 'Card', }, { TemplateOptionsId: 71808, OptionId: 48, OptionName: 'Billing', }, { TemplateOptionsId: 71809, OptionId: 166, OptionName: 'Navbar', }, ], ], BookingNavbar: [ 'Navbar3', [ { TemplateOptionsId: 71811, OptionId: 74, OptionName: 'Search', }, { TemplateOptionsId: 71812, OptionId: 75, OptionName: 'RePrint', }, { TemplateOptionsId: 71813, OptionId: 77, OptionName: 'QuickAdd', }, { TemplateOptionsId: 71814, OptionId: 76, OptionName: 'DineIn', }, { TemplateOptionsId: 71815, OptionId: 79, OptionName: 'TakeAway', }, { TemplateOptionsId: 71816, OptionId: 80, OptionName: 'Offer', }, { TemplateOptionsId: 71817, OptionId: 82, OptionName: 'ExtraCharge', }, { TemplateOptionsId: 71825, OptionId: 130, OptionName: 'Hold', }, { TemplateOptionsId: 71826, OptionId: 172, OptionName: 'AddCustomer', }, ], ], BookingCategory: [ 'Category5', [ { TemplateOptionsId: 71818, OptionId: 95, OptionName: 'Image', }, { TemplateOptionsId: 71819, OptionId: 96, OptionName: 'Background', }, ], ], BookingCard: [ 'Card4', [ { TemplateOptionsId: 71821, OptionId: 117, OptionName: 'Background', }, { TemplateOptionsId: 71822, OptionId: 119, OptionName: 'Price', }, { TemplateOptionsId: 71823, OptionId: 120, OptionName: 'SmallImage', }, { TemplateOptionsId: 71824, OptionId: 121, OptionName: 'ImageLeft', }, ], ], BookingBilling: [ 'StandardBilling', [ { TemplateOptionsId: 71825, OptionId: 130, OptionName: 'Hold', }, { TemplateOptionsId: 71825, OptionId: 130, OptionName: 'DineIn', }, { TemplateOptionsId: 71826, OptionId: 171, OptionName: 'Background', }, { TemplateOptionsId: 71826, OptionId: 172, OptionName: 'AddCustomer', }, { TemplateOptionsId: 71828, OptionId: 210, OptionName: 'Sl.No', }, { TemplateOptionsId: 71829, OptionId: 211, OptionName: 'Item', }, { TemplateOptionsId: 71830, OptionId: 214, OptionName: 'Quantity', }, { TemplateOptionsId: 71831, OptionId: 216, OptionName: 'Amount', }, { TemplateOptionsId: 71832, OptionId: 217, OptionName: 'Edit', }, { TemplateOptionsId: 71833, OptionId: 218, OptionName: 'Delete', }, ], ], }; // } // else{ // state.fontId = [1, 4, 5]; // state.colorId = [43]; // state.SelectedCardFont = 'Poppins'; // state.SelectedBillingColorDetail = { // BackgroundColor: '#cfd8dc', // FontColor: '#000000', // OverallBackgroundColor: null, // }; // state.SelectedBillingFont = 'Gilroy'; // state.SelectedCatgColorDetail = { // BackgroundColor: '#cfd8dc', // FontColor: '#000000', // OverallBackgroundColor: null, // }; // state.SelectedCatgFont = 'Gilroy'; // state.SelectedLayoutColorDetail = { OverallBackgroundColor: null }; // state.SelectedCardColorDetail = { // BackgroundColor: '#cfd8dc', // FontColor: '#000000', // OverallBackgroundColor: null, // }; // state.templateData = { // BookingLayout: [ // 'Layout2', // [ // { // TemplateOptionsId: 71805, // OptionId: 45, // OptionName: 'Category', // }, // { // TemplateOptionsId: 71807, // OptionId: 47, // OptionName: 'Card', // }, // { // TemplateOptionsId: 71808, // OptionId: 48, // OptionName: 'Billing', // }, // { // TemplateOptionsId: 71809, // OptionId: 166, // OptionName: 'Navbar', // }, // ], // ], // BookingNavbar: [ // 'Navbar1', // [ // { // TemplateOptionsId: 71811, // OptionId: 74, // OptionName: 'Search', // }, // { // TemplateOptionsId: 71812, // OptionId: 75, // OptionName: 'RePrint', // }, // { // TemplateOptionsId: 71813, // OptionId: 77, // OptionName: 'QuickAdd', // }, // { // TemplateOptionsId: 71814, // OptionId: 76, // OptionName: 'DineIn', // }, // { // TemplateOptionsId: 71815, // OptionId: 79, // OptionName: 'TakeAway', // }, // { // TemplateOptionsId: 71816, // OptionId: 80, // OptionName: 'Offer', // }, // { // TemplateOptionsId: 71817, // OptionId: 82, // OptionName: 'ExtraCharge', // }, // ], // ], // BookingCategory: [ // 'Category1', // [ // { // TemplateOptionsId: 71818, // OptionId: 95, // OptionName: 'Image', // }, // { // TemplateOptionsId: 71819, // OptionId: 96, // OptionName: 'Background', // }, // ], // ], // BookingCard: [ // 'Card2', // [ // { // TemplateOptionsId: 71821, // OptionId: 117, // OptionName: 'Background', // }, // { // TemplateOptionsId: 71822, // OptionId: 119, // OptionName: 'Price', // }, // { // TemplateOptionsId: 71823, // OptionId: 120, // OptionName: 'SmallImage', // }, // { // TemplateOptionsId: 71824, // OptionId: 121, // OptionName: 'ImageLeft', // }, // ], // ], // BookingBilling: [ // 'Billing3', // [ // { // TemplateOptionsId: 71825, // OptionId: 130, // OptionName: 'Hold', // }, // { // TemplateOptionsId: 71825, // OptionId: 130, // OptionName: 'DineIn', // }, // { // TemplateOptionsId: 71826, // OptionId: 171, // OptionName: 'Background', // }, // { // TemplateOptionsId: 71826, // OptionId: 172, // OptionName: 'AddCustomer', // }, // { // TemplateOptionsId: 71828, // OptionId: 210, // OptionName: 'Sl.No', // }, // { // TemplateOptionsId: 71829, // OptionId: 211, // OptionName: 'Item', // }, // { // TemplateOptionsId: 71830, // OptionId: 214, // OptionName: 'Quantity', // }, // { // TemplateOptionsId: 71831, // OptionId: 216, // OptionName: 'Amount', // }, // { // TemplateOptionsId: 71832, // OptionId: 217, // OptionName: 'Edit', // }, // { // TemplateOptionsId: 71833, // OptionId: 218, // OptionName: 'Delete', // }, // ], // ], // }; // } } }, changeThemeCreation: (state, action) => { console.log(action?.payload, 'actionaction'); if (action?.payload?.formtype == 'edit') { let tempDic = {}; let templatedetail = action?.payload?.editdata; state.fontId = templatedetail?.FontDetail; state.colorId = templatedetail?.ColorDetail; const tempdata = templatedetail; const mergedData = {}; tempdata?.ColorDetail?.forEach((entry) => { const sessionName = entry.SessionName; if (!mergedData[sessionName]) { mergedData[sessionName] = { SessionName: sessionName, }; } // Merge properties based on conditions if (entry.OverallBackgroundColor) { mergedData[sessionName].OverallBackgroundColor = entry.OverallBackgroundColor; } if (entry.FontColor || entry.BackgroundColor) { if (!mergedData[sessionName].FontColor && entry.FontColor) { mergedData[sessionName].FontColor = entry.FontColor; } if ( !mergedData[sessionName].BackgroundColor && entry.BackgroundColor ) { mergedData[sessionName].BackgroundColor = entry.BackgroundColor; } } }); const transformedData = Object.values(mergedData); console.log(transformedData, 'transformedData'); const filterLayoutData = transformedData?.find( (item) => item?.SessionName === 'BookingLayout' ); state.SelectedLayoutColorDetail = { OverallBackgroundColor: filterLayoutData?.OverallBackgroundColor != undefined ? filterLayoutData?.OverallBackgroundColor : null, }; const filterCardData = transformedData?.find( (item) => item?.SessionName === 'BookingCard' ); state.SelectedCardColorDetail = { BackgroundColor: filterCardData?.BackgroundColor != undefined ? filterCardData?.BackgroundColor : '#ffffff', FontColor: filterCardData?.FontColor != undefined ? filterCardData?.FontColor : '#000000', OverallBackgroundColor: filterCardData?.OverallBackgroundColor != undefined ? filterCardData?.OverallBackgroundColor : null, }; const filterCardFont = tempdata?.FontDetail?.find( (item) => item?.SessionName === 'BookingCard' ); state.SelectedCardFont = filterCardFont?.SessionFont != undefined ? filterCardFont?.SessionFont : 'Poppins'; const filterBillingData = transformedData?.find( (item) => item.SessionName === 'BookingBilling' ); state.SelectedBillingColorDetail = { BackgroundColor: filterBillingData?.BackgroundColor != undefined ? filterBillingData?.BackgroundColor : '#ffffff', FontColor: filterBillingData?.FontColor != undefined ? filterBillingData?.FontColor : '#000000', OverallBackgroundColor: filterBillingData?.OverallBackgroundColor != undefined ? filterBillingData?.OverallBackgroundColor : null, }; const filterBillingFont = tempdata?.FontDetail?.find( (item) => item?.SessionName === 'BookingBilling' ); state.SelectedBillingFont = filterBillingFont?.SessionFont != undefined ? filterBillingFont?.SessionFont : 'Gilroy'; const filterCatgData = transformedData?.find( (item) => item?.SessionName === 'BookingCategory' ); state.SelectedCatgColorDetail = { BackgroundColor: filterCatgData?.BackgroundColor != undefined ? filterCatgData?.BackgroundColor : '#ffffff', FontColor: filterCatgData?.FontColor != undefined ? filterCatgData?.FontColor : '#000000', OverallBackgroundColor: filterCatgData?.OverallBackgroundColor != undefined ? filterCatgData?.OverallBackgroundColor : null, }; const filterCatgFont = tempdata?.FontDetail?.find( (item) => item?.SessionName === 'BookingCategory' ); state.SelectedCatgFont = filterCatgFont?.SessionFont != undefined ? filterCatgFont?.SessionFont : 'Gilroy'; const filterSubCatgData = transformedData?.find( (item) => item?.SessionName === 'BookingSubCategory' ); state.SelectedSubCatgColorDetail = { BackgroundColor: filterSubCatgData?.BackgroundColor != undefined ? filterSubCatgData?.BackgroundColor : '#ffffff', FontColor: filterSubCatgData?.FontColor != undefined ? filterSubCatgData?.FontColor : '#000000', OverallBackgroundColor: filterSubCatgData?.OverallBackgroundColor != undefined ? filterSubCatgData?.OverallBackgroundColor : null, }; const filterSubCatgFont = tempdata?.FontDetail?.find( (item) => item?.SessionName === 'BookingSubCategory' ); state.SelectedSubCatgFont = filterSubCatgFont?.SessionFont != undefined ? filterSubCatgFont?.SessionFont : 'Poppins'; for (let eachData of templatedetail?.ComponentDetails) { tempDic[eachData.SessionName] = [ eachData.ComponentName, eachData.FieldDetails, ]; } console.log(tempDic, 'tempDictempDic'); const desiredOrder = [ 'Sl.No', 'Item', 'MRP', 'Discount', 'Tax', 'Quantity', 'Rate', 'Amount', 'Edit', 'Delete', 'Hold', 'AddCustomer', 'Background', 'UnpaidBill', 'OverallBackground', 'CreditCustomer', ]; const bookingBillingOptionsArray = tempDic['BookingBilling'][1]; const sortedBillingOptions = desiredOrder .map((optionName) => { return bookingBillingOptionsArray.find( (option) => option.OptionName === optionName ); }) .filter((option) => option !== undefined); tempDic['BookingBilling'][1] = sortedBillingOptions; state.ThemeCreation = tempDic; } else { state.ThemeCreation = {}; state.previewData = {}; state.fontId = [1, 4, 5]; state.colorId = [43]; state.SelectedCardFont = 'Poppins'; state.SelectedBillingColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.SelectedBillingFont = 'Gilroy'; state.SelectedCatgColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.SelectedSubCatgColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; state.SelectedCatgFont = 'Gilroy'; state.SelectedLayoutColorDetail = { OverallBackgroundColor: null }; state.SelectedCardColorDetail = { BackgroundColor: '#cfd8dc', FontColor: '#000000', OverallBackgroundColor: null, }; } }, changeScanTemplate: (state, action) => { console.log( action?.payload?.Scantemplate, action?.payload, 'action?.payload?.Scantemplate' ); if (action?.payload?.Scantemplate) { state.ScanTemplate = action?.payload; console.log(action?.payload, 'action?.payload?.Scantemplate '); state.templateData = action?.payload?.Template; } else { if ( action?.payload?.OldTemp == 'Combo1' || action?.payload?.OldTemp == 'Combo2' ) { state.ScanTemplate = action?.payload; state.templateData = action?.payload?.Template; } else { state.ScanTemplate = action?.payload; } } }, changeSelectedTheme: (state, action) => { console.log(action?.payload, 'action?.payload theme'); state.SelectedTheme = action?.payload; }, changePricingAppPricingName: (state, action) => { state.PricingAppPricingName = action?.payload; }, changeReprintDataFound: (state, action) => { state.ReprintDataFound = action?.payload; }, changeSelectedPrintdummyData: (state, action) => { state.PrintdummyData = action?.payload; }, changeSelectedprintSize: (state, action) => { state.printSize = action?.payload; }, changeSelectedprintStyle: (state, action) => { state.printStyle = action?.payload; }, changeSelectedSlNo: (state, action) => { state.SlNo = action?.payload; }, changeSelectedItem: (state, action) => { state.Item = action?.payload; }, changeSelectedMRP: (state, action) => { state.MRP = action?.payload; }, changeSelectedDiscount: (state, action) => { state.Discount = action?.payload; }, changeSelectedTax: (state, action) => { state.Tax = action?.payload; }, changeSelectedQuantity: (state, action) => { state.Quantity = action?.payload; }, changeSelectedRate: (state, action) => { state.Rate = action?.payload; }, changeSelectedAmount: (state, action) => { state.Amount = action?.payload; }, changeSelectedHsnCode: (state, action) => { state.HsnCode = action?.payload; }, changeSelectedQrcode: (state, action) => { state.Qrcode = action?.payload; }, changeSelectedSignature: (state, action) => { state.Signature = action?.payload; }, changeSelectedCashierName: (state, action) => { state.CashierName = action?.payload; }, changeSelectedLogo: (state, action) => { state.Logo = action?.payload; }, changeSelectedCredit: (state, action) => { state.Credit = action?.payload; }, changeSelectedtermsAndConditions: (state, action) => { state.termsAndConditions = action?.payload; }, changethemeFormat: (state, action) => { state.themeFormat = action?.payload; }, changeNotes: (state, action) => { state.notes = action?.payload; }, changeSignatureImage: (state, action) => { state.SignatureImage = action?.payload; }, changeBillName: (state, action) => { state.BillName = action?.payload; }, changeSelectedHeaderColor: (state, action) => { state.SelectedHeaderColor = action?.payload; }, changeCurrentColor: (state, action) => { const { color } = action?.payload; state.CurrentColor = color; }, changeCurrentText: (state, action) => { const { text } = action?.payload; state.CurrentText = text; }, changeSelectedLayout: (state, action) => { const LayoutId = action?.payload; state.SelectedLayout = LayoutId; }, changeSelectedNavbar: (state, action) => { state.SelectedNavbar = action?.payload; }, changeSelectedCategory: (state, action) => { state.SelectedCategory = action?.payload; }, changeSelectedSubCategory: (state, action) => { state.SelectedSubCategory = action?.payload; }, changeSelectedCard: (state, action) => { state.SelectedCard = action?.payload; }, changeSelectedBillingTable: (state, action) => { state.SelectedBillingTable = action?.payload; }, changeSelectedNavbarCheckedItems: (state, action) => { state.SelectedNavbarCheckedItems = action?.payload; }, changeSelectedCategoryCheckedItems: (state, action) => { state.SelectedCategoryCheckedItems = action?.payload; }, changeSelectedSubCategoryCheckedItems: (state, action) => { state.SelectedSubCategoryCheckedItems = action?.payload; }, changeSelectedCardCheckedItems: (state, action) => { state.SelectedCardCheckedItems = action?.payload; }, changeSelectedBillTableCheckedItems: (state, action) => { state.SelectedBillTableCheckedItems = action?.payload; }, changePreviewComponents: (state, action) => { state.previewData = { ...state.previewData, ...action?.payload }; }, changeSelectedCardColorDetail: (state, action) => { const { cardColor } = action?.payload; state.SelectedCardColorDetail = cardColor; }, changeSelectedBillingColorDetail: (state, action) => { const { billingColor } = action?.payload; state.SelectedBillingColorDetail = billingColor; }, changeSelectedCatgColorDetail: (state, action) => { const { catgColor } = action?.payload; state.SelectedCatgColorDetail = catgColor; }, changeSelectedSubCatgColorDetail: (state, action) => { const { subCatgColor } = action?.payload; state.SelectedSubCatgColorDetail = subCatgColor; }, changeSelectedLayoutColorDetail: (state, action) => { const { layoutColor } = action?.payload; state.SelectedLayoutColorDetail = layoutColor; }, changeSelectedCardFont: (state, action) => { const cardFont = action?.payload; state.SelectedCardFont = cardFont?.['cardFont']; }, changeSelectedBillingFont: (state, action) => { const billFont = action?.payload; state.SelectedBillingFont = billFont?.['billFont']; }, changeSelectedCatgFont: (state, action) => { const catgFont = action?.payload; state.SelectedCatgFont = catgFont?.['catgFont']; }, changeSelectedSubCatgFont: (state, action) => { const subCargFont = action?.payload; state.SelectedSubCatgFont = subCargFont?.['subCargFont']; }, changeSessionData: (state, action) => { state.SessionData = action?.payload; }, changeOthersTheme: (state, action) => { state.OthersTheme = action?.payload; }, changeActiveTheme: (state, action) => { state.ActiveTheme = action?.payload; }, }, extraReducers: (builder) => { (builder.addCase(getColors.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.allColors = action?.payload?.data?.data; } }), builder.addCase( getLayoutOverallBackgroundColors.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.LayoutOverallColorsList = action?.payload?.data?.data; } } ), builder.addCase( getCategoryOverallBackgroundColors.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.CategoryOverallColorsList = action?.payload?.data?.data; } } ), builder.addCase( getSubcategoryOverallBackgroundColors.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.SubcategoryOverallColorsList = action?.payload?.data?.data; } } ), builder.addCase( getCardOverallBackgroundColors.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.cardOverallColorsList = action?.payload?.data?.data; } } ), builder.addCase( getBillingOverallBackgroundColors.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.BillingOverallColorsList = action?.payload?.data?.data; } } ), builder.addCase(getColorsCat.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.allColorsCat = action?.payload?.data?.data; } }), builder.addCase(getColorsSubcat.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.allColorsSubcat = action?.payload?.data?.data; } }), builder.addCase(getColorsCard.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.allColorsCard = action?.payload?.data?.data; } }), builder.addCase(getColorsBilltable.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.allColorsBillTable = action?.payload?.data?.data; } }), builder.addCase(getCatFonts.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.catFont = action?.payload?.data?.data; } }), builder.addCase(getSubCatFonts.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.subFont = action?.payload?.data?.data; } }), builder.addCase(getCardFonts.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.cardFont = action?.payload?.data?.data; } }), builder.addCase(getTableFonts.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.tableFont = action?.payload?.data?.data; } }), builder.addCase(PricingAppPricingNameData.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.PricingAppPricingName = action?.payload?.data?.data; } }), builder.addCase(FeatureAddon.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode == 1) { state.FeatureAddonData = action?.payload?.data?.data?.[0]?.FeatAddonHdr?.[0]; } }), builder.addCase( getPrintSelectionComponentData.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { const Advance = state?.PricingAppPricingName?.some( (item) => item.PricingName === 'Premium' ); const hasCustomizedTemplate = state.FeatureAddonData?.FeatureDtls?.some( (item) => item?.FeatureAddonName?.toLowerCase() === 'customized template' ); if (Advance || hasCustomizedTemplate) { state.PrintTemplate = action?.payload?.data?.data?.[0]?.ComponentDetails?.find( (item) => item.SetasDefault == 'Y' && item.PrintTypeName === 'Sales' )?.StyleName; state.DCPrintTemplate = action?.payload?.data?.data?.[0]?.ComponentDetails?.find( (item) => item.SetasDefault == 'Y' && item.PrintTypeName === 'Delivery Chalan' )?.StyleName; state.printDatas = action?.payload?.data?.data?.[0]?.ComponentDetails.find( (item) => item.SetasDefault == 'Y' && item.PrintTypeName === 'Sales' ); state.PrintFieldDetails = action?.payload?.data?.data?.[0]?.ComponentDetails?.find( (item) => item.SetasDefault == 'Y' && item.PrintTypeName === 'Sales' )?.FieldDetails?.reduce((acc, item) => { acc[item.ConfigName] = true; return acc; }, {}); } } else if (action?.payload?.data?.statusCode == 0) { state.PrintTemplate = undefined; } } ), builder.addCase(getTemplate.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { let tempDic = {}; state.SelectedApplication = { AppId: action?.payload?.data?.data[0]?.AppId, }; state.AppName = action?.payload?.data?.data[0]?.AppName; state.fontId = action?.payload?.data?.data[0]?.FontDetail; state.colorId = action?.payload?.data?.data[0]?.ColorDetail; const tempdata = action?.payload?.data?.data?.[0]; state.CustThemeData = tempdata?.ComponentDetails?.[0]?.ComponentName; console.log( tempdata?.ComponentDetails?.[0]?.ComponentName, 'tempdata?.ComponentDetails?.[0]?.ComponentName' ); const mergedData = {}; tempdata?.ColorDetail?.forEach((entry) => { const sessionName = entry.SessionName; if (!mergedData[sessionName]) { mergedData[sessionName] = { SessionName: sessionName, }; } // Merge properties based on conditions if (entry.OverallBackgroundColor) { mergedData[sessionName].OverallBackgroundColor = entry.OverallBackgroundColor; } if (entry.FontColor || entry.BackgroundColor) { if (!mergedData[sessionName].FontColor && entry.FontColor) { mergedData[sessionName].FontColor = entry.FontColor; } if ( !mergedData[sessionName].BackgroundColor && entry.BackgroundColor ) { mergedData[sessionName].BackgroundColor = entry.BackgroundColor; } } }); const transformedData = Object.values(mergedData); const filterLayoutData = transformedData?.find( (item) => item?.SessionName === 'BookingLayout' ); state.SelectedLayoutColorDetail = { OverallBackgroundColor: filterLayoutData?.OverallBackgroundColor != undefined ? filterLayoutData?.OverallBackgroundColor : null, }; const filterCardData = transformedData?.find( (item) => item?.SessionName === 'BookingCard' ); state.SelectedCardColorDetail = { BackgroundColor: filterCardData?.BackgroundColor != undefined ? filterCardData?.BackgroundColor : '#ffffff', FontColor: filterCardData?.FontColor != undefined ? filterCardData?.FontColor : '#000000', OverallBackgroundColor: filterCardData?.OverallBackgroundColor != undefined ? filterCardData?.OverallBackgroundColor : null, }; const filterCardFont = tempdata?.FontDetail?.find( (item) => item?.SessionName === 'BookingCard' ); state.SelectedCardFont = filterCardFont?.SessionFont != undefined ? filterCardFont?.SessionFont : 'Poppins'; const filterBillingData = transformedData?.find( (item) => item.SessionName === 'BookingBilling' ); state.SelectedBillingColorDetail = { BackgroundColor: filterBillingData?.BackgroundColor != undefined ? filterBillingData?.BackgroundColor : '#ffffff', FontColor: filterBillingData?.FontColor != undefined ? filterBillingData?.FontColor : '#000000', OverallBackgroundColor: filterBillingData?.OverallBackgroundColor != undefined ? filterBillingData?.OverallBackgroundColor : null, }; const filterBillingFont = tempdata?.FontDetail?.find( (item) => item?.SessionName === 'BookingBilling' ); state.SelectedBillingFont = filterBillingFont?.SessionFont != undefined ? filterBillingFont?.SessionFont : 'Gilroy'; const filterCatgData = transformedData?.find( (item) => item?.SessionName === 'BookingCategory' ); state.SelectedCatgColorDetail = { BackgroundColor: filterCatgData?.BackgroundColor != undefined ? filterCatgData?.BackgroundColor : '#ffffff', FontColor: filterCatgData?.FontColor != undefined ? filterCatgData?.FontColor : '#000000', OverallBackgroundColor: filterCatgData?.OverallBackgroundColor != undefined ? filterCatgData?.OverallBackgroundColor : null, }; const filterCatgFont = tempdata?.FontDetail?.find( (item) => item?.SessionName === 'BookingCategory' ); state.SelectedCatgFont = filterCatgFont?.SessionFont != undefined ? filterCatgFont?.SessionFont : 'Gilroy'; const filterSubCatgData = transformedData?.find( (item) => item?.SessionName === 'BookingSubCategory' ); state.SelectedSubCatgColorDetail = { BackgroundColor: filterSubCatgData?.BackgroundColor != undefined ? filterSubCatgData?.BackgroundColor : '#ffffff', FontColor: filterSubCatgData?.FontColor != undefined ? filterSubCatgData?.FontColor : '#000000', OverallBackgroundColor: filterSubCatgData?.OverallBackgroundColor != undefined ? filterSubCatgData?.OverallBackgroundColor : null, }; const filterSubCatgFont = tempdata?.FontDetail?.find( (item) => item?.SessionName === 'BookingSubCategory' ); state.SelectedSubCatgFont = filterSubCatgFont?.SessionFont != undefined ? filterSubCatgFont?.SessionFont : 'Poppins'; for (let eachData of action?.payload?.data?.data[0] ?.ComponentDetails) { tempDic[eachData.SessionName] = [ eachData.ComponentName, eachData.FieldDetails, ]; } const desiredOrder = [ 'Sl.No', 'HSNCode', 'Item', 'QRCode', 'MRP', 'Discount', 'Tax', 'Quantity', 'Rate', 'Amount', 'Edit', 'Points', 'SalesMan', 'Commission', 'StockId', 'Total', 'Delete', 'Hold', 'AddCustomer', 'Background', 'UnpaidBill', 'OverallBackground', 'CreditCustomer', ]; const bookingBillingOptionsArray = tempDic['BookingBilling'][1]; const sortedBillingOptions = desiredOrder .map((optionName) => { return bookingBillingOptionsArray.find( (option) => option.OptionName === optionName ); }) .filter((option) => option !== undefined); tempDic['BookingBilling'][1] = sortedBillingOptions; state.templateData = tempDic; } // else { // state.templateData = {} // state.previewData= {} // state.fontId = [1, 4, 5] // state.colorId = [43] // state.SelectedCardFont = "Poppins" // state.SelectedBillingColorDetail = { // 'BackgroundColor': "#cfd8dc", // 'FontColor': "#000000", // 'OverallBackgroundColor': null // } // state.SelectedBillingFont = "Gilroy" // state.SelectedCatgColorDetail = { // 'BackgroundColor': "#cfd8dc", // 'FontColor': "#000000", // 'OverallBackgroundColor': null // } // state.SelectedSubCatgColorDetail = { // 'BackgroundColor': "#cfd8dc", // 'FontColor': "#000000", // 'OverallBackgroundColor': null // } // state.SelectedCatgFont = "Gilroy" // state.SelectedLayoutColorDetail = { OverallBackgroundColor: null } // state.SelectedCardColorDetail = { // 'BackgroundColor': "#cfd8dc", // 'FontColor': "#000000", // 'OverallBackgroundColor': null // } // } }), builder.addCase(getThemes.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode == 1) { state.DefaultTheme = action?.payload?.data?.data?.filter( (item) => item?.ActiveStatus == 'A' ); console.log( action?.payload?.data?.data?.filter( (item) => item?.ActiveStatus == 'A' ), 'DefaultTheme' ); } })); builder.addCase(getPrinterMappingDetails.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode == 1) { state.PrinterMappingDtls = action?.payload?.data?.data?.[0]?.PrintMappingDtl?.filter( (item) => item?.ChkStatus == 'Y' ); console.log( action?.payload?.data?.data?.[0]?.PrintMappingDtl?.filter( (item) => item?.ChkStatus == 'Y' ), 'PrinterMappingDtls' ); } }); }, }); export const { changeCurrentColor, changeCurrentText, changeSelectedLayout, emptyTemplateData, emptyPostData, changeSelectedNavbar, changeSelectedCategory, changeSelectedSubCategory, changeSelectedCard, changeSelectedBillingTable, changeSelectedNavbarCheckedItems, changeSelectedCategoryCheckedItems, changeSelectedSubCategoryCheckedItems, changeSelectedCardCheckedItems, changeSelectedBillTableCheckedItems, changePreviewComponents, changeSelectedCardColorDetail, changeSelectedBillingColorDetail, changeSelectedCatgColorDetail, changeSelectedSubCatgColorDetail, changeSelectedLayoutColorDetail, changeSelectedBillingFont, changeSelectedCardFont, changeSelectedCatgFont, changeSelectedSubCatgFont, changeSelectedprintSize, changeSelectedprintStyle, changeSelectedSlNo, changeSelectedItem, changeSelectedMRP, changeSelectedDiscount, changeSelectedTax, changeSelectedQuantity, changeSelectedRate, changeSelectedAmount, changeSelectedHsnCode, changeSelectedQrcode, changeSelectedSignature, changeSelectedCashierName, changeSelectedLogo, changeSelectedCredit, changeSelectedtermsAndConditions, changethemeFormat, changeNotes, changeSelectedPrintdummyData, changeReprintDataFound, changePricingAppPricingName, changeBillName, changetemplateData, changeSessionData, changeThemeCreation, changeSignatureImage, changeSelectedTheme, changeOthersTheme, changeActiveTheme, changeScanTemplate, changeSelectedHeaderColor, } = ThemeSlice.actions; export const GlobalPricingAppPricingName = (state) => state?.theme?.PricingAppPricingName; export const SelectedPrintTemplate = (state) => state?.theme?.PrintTemplate; export const GloabalFieldDetails = (state) => state?.theme?.PrintFieldDetails; export const GlobalReprintDataFound = (state) => state.theme?.ReprintDataFound; export const GlobalPritdummyData = (state) => state.theme?.PrintdummyData; export const GlobalprintSize = (state) => state.theme?.printSize; export const GlobalprintprintStyle = (state) => state.theme?.printStyle; export const GlobalprintSlNo = (state) => state.theme?.SlNo; export const GlobalprintItem = (state) => state.theme?.Item; export const GlobalprintMRP = (state) => state.theme?.MRP; export const GlobalprintDiscount = (state) => state.theme?.Discount; export const GlobalprintTax = (state) => state.theme?.Tax; export const GlobalprintQuantity = (state) => state.theme?.Quantity; export const GlobalprintRate = (state) => state.theme?.Rate; export const GlobalprintAmount = (state) => state.theme?.Amount; export const GlobalprintHsnCode = (state) => state.theme?.HsnCode; export const GlobalprintQrcodet = (state) => state.theme?.Qrcode; export const GlobalprintSignature = (state) => state.theme?.Signature; export const GlobalprintCashierName = (state) => state.theme?.CashierName; export const GlobalprintLogo = (state) => state.theme?.Logo; export const GlobalprintCredit = (state) => state.theme?.Credit; export const GlobalprinttermsAndConditions = (state) => state.theme?.termsAndConditions; export const GlobalthemeFormat = (state) => state.theme?.themeFormat; export const Globalnotes = (state) => state.theme?.notes; export const GlobalSignatureImage = (state) => state.theme?.SignatureImage; export const GlobalBillName = (state) => state.theme?.BillName; export const GlobalSelectedPrintHeaderColor = (state) => state.theme?.SelectedHeaderColor; export const changeCurrentColorValue = (state) => state.theme?.CurrentColor; export const changeCurrentTextValue = (state) => state.theme?.CurrentText; export const getColorsData = (state) => state.theme?.allColors; export const GlobalCatData = (state) => state.theme?.catFont; export const GlobalSubcatData = (state) => state.theme?.subFont; export const GlobalCardData = (state) => state.theme?.cardFont; export const GlobalTableData = (state) => state.theme?.tableFont; export const GlobalCategoryOverallColorsList = (state) => state.theme?.CategoryOverallColorsList; export const GlobalSubcategoryOverallColorsList = (state) => state.theme?.SubcategoryOverallColorsList; export const GlobalcardOverallColorsList = (state) => state.theme?.cardOverallColorsList; export const GlobalBillingOverallColorsList = (state) => state.theme?.BillingOverallColorsList; export const GlobalLayoutOverallbackgroundlist = (state) => state.theme?.LayoutOverallColorsList; export const getColorsDataCat = (state) => state.theme?.allColorsCat; export const getColorsDataSubcat = (state) => state.theme?.allColorsSubcat; export const getColorsDataCard = (state) => state.theme?.allColorsCard; export const getColorsDataBilltable = (state) => state.theme?.allColorsBillTable; export const selectedApplication = (state) => state?.theme?.SelectedApplication; export const selectedApplicationName = (state) => state?.theme?.AppName; export const selectedFontId = (state) => state?.theme?.fontId; export const selectedColorId = (state) => state?.theme?.colorId; export const GlobalSelectedColor = (state) => state?.theme?.CurrentColor; export const GlobalSelectedFont = (state) => state?.theme?.CurrentText; export const getTemplateData = (state) => state.theme.templateData; export const getPreviewData = (state) => state.theme.previewData; export const getThemeCreation = (state) => state.theme.ThemeCreation; export const getSelectedNavbarOptions = (state) => state.theme.SelectedNavbarCheckedItems; export const getSelectedCategoryOptions = (state) => state.theme.SelectedCategoryCheckedItems; export const getSelectedSubCategoryOptions = (state) => state.theme.SelectedSubCategoryCheckedItems; export const getSelectedCardOptions = (state) => state.theme.SelectedCardCheckedItems; export const getSelectedBillingOptions = (state) => state.theme.SelectedBillTableCheckedItems; export const SelectedGlobalCardColorDetail = (state) => state.theme.SelectedCardColorDetail; export const SelectedGlobalBillingColorDetail = (state) => state.theme.SelectedBillingColorDetail; export const SelectedGlobalCatgColorDetail = (state) => state.theme.SelectedCatgColorDetail; export const SelectedGlobalSubCatgColorDetail = (state) => state.theme.SelectedSubCatgColorDetail; export const SelectedGlobalLayoutColorDetail = (state) => state.theme.SelectedLayoutColorDetail; export const SelectedGlobalCardFont = (state) => state.theme.SelectedCardFont; export const SelectedGlobalBillingFont = (state) => state.theme.SelectedBillingFont; export const SelectedGlobalCatgFont = (state) => state.theme.SelectedCatgFont; export const SelectedGlobalSubCatgFont = (state) => state.theme.SelectedSubCatgFont; export const StoredSessionData = (state) => state.theme.SessionData; export const GlobalprintDatas = (state) => state.theme.printDatas; export const GlobalDefaultTheme = (state) => state.theme.DefaultTheme; export const GlobalOthersTheme = (state) => state.theme.OthersTheme; export const GlobalSelectedTheme = (state) => state.theme.SelectedTheme; export const GlobalActiveTheme = (state) => state.theme.ActiveTheme; export const GlobalDCPrintTemplate = (state) => state.theme.DCPrintTemplate; export const GlobalScanTemplate = (state) => state.theme.ScanTemplate; export const GlobalCustThemeData = (state) => state.theme.CustThemeData; export const GlobalPrinterMappingDtls = (state) => state.theme.PrinterMappingDtls; export default ThemeSlice.reducer;