69 lines
2.1 KiB
TypeScript
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,
|
|
};
|
|
}
|