canina/frontend/application/lib/useCatalogMode.ts
parsa aghaei 204350eff8
Some checks failed
E2E Playwright Tests / Run Full E2E & Security Suites (push) Waiting to run
Deploy Canina / deploy (push) Has been cancelled
feat(financial): add enable/disable toggle for shelter animal charity and round-up donation
2026-09-13 09:41:56 +03:30

69 lines
2.1 KiB
TypeScript

"use client";
import { useSettingsStore } from "./store/settingsStore";
export function useCatalogMode() {
const { getText, getBoolean, isInitialized } = useSettingsStore();
const isCatalogOnly = isInitialized
? getBoolean("CATALOG_ONLY_MODE", false) || getBoolean("catalog_mode", false)
: false;
const showPrices = isCatalogOnly
? getBoolean("CATALOG_SHOW_PRICES", true) && !getBoolean("catalog_hide_prices", false)
: true;
const allowCart = isCatalogOnly
? getBoolean("CATALOG_ALLOW_CART", false) && !getBoolean("catalog_disable_cart", false)
: true;
const allowCheckout = isCatalogOnly
? getBoolean("CATALOG_ALLOW_CHECKOUT", false) && !getBoolean("catalog_disable_checkout", false)
: true;
const showPreorderBtn = isCatalogOnly && (
getBoolean("CATALOG_PREORDER_BTN", false) || getBoolean("catalog_preorder_btn", false)
);
const showOrders = isCatalogOnly
? getBoolean("CATALOG_SHOW_ORDERS", false) || getBoolean("catalog_show_orders", false)
: true;
const showWallet = isCatalogOnly
? getBoolean("CATALOG_SHOW_WALLET", false) || getBoolean("catalog_show_wallet", false)
: true;
const isCharityGlobalEnabled =
getBoolean("CHARITY_DONATION_ENABLED", true) &&
getBoolean("charity_donation_enabled", true) &&
getBoolean("charityDonationEnabled", true);
const showCharity = isCharityGlobalEnabled && (
isCatalogOnly
? getBoolean("CATALOG_SHOW_CHARITY", false) || getBoolean("catalog_show_charity", false)
: true
);
const orderDisabledTitle = getText(
"ORDER_DISABLED_TITLE",
"امکان ثبت سفارش آنلاین موقتاً غیرفعال است"
);
const orderDisabledMessage = getText(
"ORDER_DISABLED_MESSAGE",
"سامانه در حال حاضر در حالت کاتالوگ قرار دارد. جهت دریافت مشاوره تخصصی می‌توانید با کارشناسان ما تماس بگیرید."
);
return {
isCatalogOnly,
showPrices,
allowCart,
allowCheckout,
showPreorderBtn,
showOrders,
showWallet,
showCharity,
orderDisabledTitle,
orderDisabledMessage,
};
}