From 6a5c6e2e6f420d1f22681ce898bfb0cb067acc45 Mon Sep 17 00:00:00 2001 From: stCarolas Date: Thu, 23 May 2024 09:42:22 +0300 Subject: [PATCH] add deleteCustomCss button --- .../MediaWidget/PaymentPageConfig.ts | 1 + .../PaymentPageConfigComponent.tsx | 32 +++++++++++++++---- src/index.css | 12 +++++++ 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/components/MediaWidget/PaymentPageConfig.ts b/src/components/MediaWidget/PaymentPageConfig.ts index c79f643..37fc451 100644 --- a/src/components/MediaWidget/PaymentPageConfig.ts +++ b/src/components/MediaWidget/PaymentPageConfig.ts @@ -140,6 +140,7 @@ export class PaymentPageConfig { public set customCss(value: string) { this._customCss = value; this.config.value["customCss"] = value; + this.sendEventPaymentPageUpdated(); } async reloadConfig(): Promise { diff --git a/src/components/PaymentPageConfig/PaymentPageConfigComponent.tsx b/src/components/PaymentPageConfig/PaymentPageConfigComponent.tsx index 96c7936..a478d7b 100644 --- a/src/components/PaymentPageConfig/PaymentPageConfigComponent.tsx +++ b/src/components/PaymentPageConfig/PaymentPageConfigComponent.tsx @@ -39,6 +39,7 @@ export default function PaymentPageConfigComponent({}: {}) { const [arbitraryText, setArbitraryText] = useState(null); const [hasChanges, setHasChanges] = useState(false); const [payButtonText, setPayButtonText] = useState(null); + const [hasCustomCss, setHasCustomCss] = useState(false); function listenPaymentPageConfigUpdated() { if (!paymentPageConfig.current) { @@ -54,6 +55,9 @@ export default function PaymentPageConfigComponent({}: {}) { setInn(paymentPageConfig.current?.inn ?? ""); setArbitraryText(paymentPageConfig.current?.arbitraryText ?? null); setPayButtonText(paymentPageConfig.current?.payButtonText ?? null); + if (paymentPageConfig.current?.customCss) { + setHasChanges(true); + } } const handleBackUpload = (e: ChangeEvent) => { @@ -67,7 +71,7 @@ export default function PaymentPageConfigComponent({}: {}) { if (e.target.files) { const file = e.target.files[0]; if (paymentPageConfig.current) { - paymentPageConfig.current.customCss = `${process.env.REACT_APP_CDN_ENDPOINT}/css-${recipientId}.css` + paymentPageConfig.current.customCss = `${process.env.REACT_APP_CDN_ENDPOINT}/css-${recipientId}.css`; paymentPageConfig.current.save(); } uploadFile(file, `css-${recipientId}.css`); @@ -75,11 +79,11 @@ export default function PaymentPageConfigComponent({}: {}) { }; const deleteCustomCss = () => { - if (paymentPageConfig.current){ + if (paymentPageConfig.current) { paymentPageConfig.current.customCss = ""; paymentPageConfig.current.save(); } - } + }; const handleLogoUpload = (e: ChangeEvent) => { if (e.target.files) { @@ -185,12 +189,24 @@ export default function PaymentPageConfigComponent({}: {}) { /> -
+
Custom css
+ {hasCustomCss && ()}
Текст на странице
@@ -236,10 +252,10 @@ export default function PaymentPageConfigComponent({}: {}) { Реквесты музыки/видео