Save pay later messaging config to database

This commit is contained in:
Emili Castells Guasch 2025-01-30 16:39:26 +01:00
parent a652f21629
commit 66c6fb17b8
6 changed files with 70 additions and 37 deletions

View file

@ -34,7 +34,7 @@ const useHooks = () => {
};
};
export const useState = () => {
export const useStore = () => {
const { persist, isReady } = useHooks();
return { persist, isReady };
};

View file

@ -23,47 +23,52 @@ const useHooks = () => {
const [ isReady ] = useTransient( 'isReady' );
// Persistent accessors.
// TODO: Replace with real property.
const [ sampleValue, setSampleValue ] = usePersistent( 'sampleValue' );
const [ cart ] = usePersistent( 'cart' );
const [ checkout ] = usePersistent( 'checkout' );
const [ product ] = usePersistent( 'product' );
const [ shop ] = usePersistent( 'shop' );
const [ home ] = usePersistent( 'home' );
const [ custom_placement ] = usePersistent( 'custom_placement' );
const [ cart, setCart ] = usePersistent( 'cart' );
const [ checkout, setCheckout ] = usePersistent( 'checkout' );
const [ product, setProduct ] = usePersistent( 'product' );
const [ shop, setShop ] = usePersistent( 'shop' );
const [ home, setHome ] = usePersistent( 'home' );
const [ custom_placement, setCustom_placement ] =
usePersistent( 'custom_placement' );
return {
persist,
isReady,
sampleValue,
setSampleValue,
cart,
setCart,
checkout,
setCheckout,
product,
setProduct,
shop,
setShop,
home,
setHome,
custom_placement,
setCustom_placement,
};
};
export const useState = () => {
export const useStore = () => {
const { persist, isReady } = useHooks();
return { persist, isReady };
};
// TODO: Replace with real hook.
export const useSampleValue = () => {
const { sampleValue, setSampleValue } = useHooks();
return {
sampleValue,
setSampleValue,
};
};
export const usePayLaterMessaging = () => {
const { cart, checkout, product, shop, home, customPlacement } = useHooks();
const {
cart,
setCart,
checkout,
setCheckout,
product,
setProduct,
shop,
setShop,
home,
setHome,
custom_placement,
setCustom_placement,
} = useHooks();
return {
config: {
@ -72,7 +77,13 @@ export const usePayLaterMessaging = () => {
product,
shop,
home,
customPlacement,
custom_placement,
},
setCart,
setCheckout,
setProduct,
setShop,
setHome,
setCustom_placement,
};
};

View file

@ -19,8 +19,6 @@ const defaultTransient = Object.freeze( {
// Persistent: Values that are loaded from the DB.
const defaultPersistent = Object.freeze( {
// TODO: Add real DB properties here.
sampleValue: 'foo',
cart: {},
checkout: {},
product: {},