import {__} from "@wordpress/i18n"; import React, {lazy, Suspense, useReducer, useState} from "react"; import {ToggleControl, Tooltip} from "@wordpress/components"; import localizeSettings from "./localizeSettings"; import ErrorBoundary from "../components/ErrorBoundary"; import Fallback from "../components/Fallback"; import SchemaConditionTooltip from "../components/SchemaConditionTooltip"; import {FreemiusOverlay} from "../components/FreemiusOverlay"; import {Icon, info} from "@wordpress/icons"; import LockIcon from "../components/LockIcon"; const CssEditor = lazy(() => import("../components/CssEditor")); const conditions = localizeSettings.conditions; const settings = localizeSettings.settings; const homeUrl = localizeSettings.homeUrl; type State = { productCondition: string; productConditionCustom: string; productConditionCustomGroup: string; productConditionLabel: string; showOnShopPage: boolean; productConditionShopLabel: string; productConditionCustomCss: string; }; export {State as GlobalSettingsProps}; type Action = Partial; const AdminSettings = () => { const [state, dispatch] = useReducer( (prevState: State, action: Action) => ({...prevState, ...action}), { productCondition: "", productConditionCustom: "", productConditionCustomGroup: "", productConditionLabel: "", showOnShopPage: false, productConditionShopLabel: "", productConditionCustomCss: "", ...settings, }, ); const [isFocused, setIsFocused] = useState(false); return ( <> {state.productCondition === "other" && ( )} {state.productCondition && ( )} {state.showOnShopPage && ( )}

{__( "Select the default condition", "product-condition-manager-for-woocommerce", )}

{__( "Read more", "product-condition-manager-for-woocommerce", )}
{ dispatch({ productConditionCustom: event.target.value, }); }} />
{ dispatch({ productConditionLabel: event.target.value, }); }} type="text" placeholder={__( "Product Condition:", "product-condition-manager-for-woocommerce", )} />
{__( "Enable this if you want the product condition shown on the", "product-condition-manager-for-woocommerce", )}   {__( "shop page.", "product-condition-manager-for-woocommerce", )} } checked={state.showOnShopPage} onChange={() => { dispatch({ showOnShopPage: !state.showOnShopPage, }); }} />
{ dispatch({ productConditionShopLabel: event.target.value, }); }} type="text" placeholder={__( "Product Condition:", "product-condition-manager-for-woocommerce", )} />
{isFocused ? ( }> { dispatch({ productConditionCustomCss: value, }); }} /> ) : (