import { __ } from '@wordpress/i18n'; import { useEffect, useState } from 'react'; import { Link } from 'react-router'; import { toast } from 'react-toastify'; import Button from '../../components/Button'; import CheckBox from '../../components/CheckBox'; import ComponentContainer from '../../components/ComponentContainer'; import LoadingSpinner from '../../components/LoadingSpinner'; import SingleSelect from '../../components/SingleSelect'; import { useGetSettingsQuery, useUpdateSettingsMutation, } from '../../features/settings/settingsApi'; import SettingsTitle from './components/SettingsTitle'; import SingleSelectRadio from './components/SingleSelectRadio'; const Settings = () => { const { data, isLoading } = useGetSettingsQuery(); const [ updateSettings, { isLoading: updateLoading, isSuccess: updateSuccess }, ] = useUpdateSettingsMutation(); const [settings, setSettings] = useState({}); useEffect(() => { if (data) { setSettings(data); } }, [data]); useEffect(() => { if (updateSuccess) { toast.success('Settings Updated'); } }, [updateSuccess]); const handleSettingChange = (key, value) => { setSettings((prevState) => ({ ...prevState, [key]: value, })); }; const handleSettingSave = () => { updateSettings(settings); }; const items = { product_price_type: { regular_price: 'Regular Price', price: 'Sale Price', }, min_max_discount_amount: { min: 'Minimum', max: 'Maximum', }, discount_priority_type: { both: 'Both coupons and campaigns', disco_campaign: 'Only Disco campaigns', }, on_sale_badge: { show_all: 'Show on sale badge', do_not_show: 'Do not show on sale badge', // show_for_campaigns: 'Show on sale badge only for campaigns', // show_for_wc: 'Show on sale badge only for WooCommerce', }, show_strike_through: { shop_page: true, product_pages: true, category_page: true, cart_page: true, }, }; if (isLoading) { return (