From e055224e0ef26c22af7e054b7a9cbb709f579673 Mon Sep 17 00:00:00 2001 From: stCarolas Date: Tue, 21 May 2024 19:21:31 +0300 Subject: [PATCH] add customization for payButtonText and css --- .../MediaWidget/PaymentPageConfig.ts | 29 ++++++++++++--- .../PaymentPageConfigComponent.tsx | 36 +++++++++++++++++++ 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/src/components/MediaWidget/PaymentPageConfig.ts b/src/components/MediaWidget/PaymentPageConfig.ts index d3d91e4..c79f643 100644 --- a/src/components/MediaWidget/PaymentPageConfig.ts +++ b/src/components/MediaWidget/PaymentPageConfig.ts @@ -14,12 +14,16 @@ export class PaymentPageConfig { private _minimalAmount: Number = 40; private _goals: Goal[] = []; private _recipientId: string = ""; + private _payButtonText: string = ""; + private _customCss: string = ""; constructor(recipientId: string) { log.debug("Loading PaymentPageConfig"); this._recipientId = recipientId; axios - .get(`${process.env.REACT_APP_CONFIG_API_ENDPOINT}/config/paymentpage?ownerId=${recipientId}`) + .get( + `${process.env.REACT_APP_CONFIG_API_ENDPOINT}/config/paymentpage?ownerId=${recipientId}`, + ) .then((data) => data.data) .then((json) => { this.config = json; @@ -32,7 +36,9 @@ export class PaymentPageConfig { this.inn = json.value["inn"] ?? ""; this.arbitraryText = json.value["arbitraryText"] ?? null; this.goals = json.value["goals"] ?? []; + this._payButtonText = json.value["payButtonText"] ?? ""; this.minimalAmount = json.value["minimalAmount"] ?? 40; + this._customCss = json.value["customCss"] ?? []; this.sendMediaRequestsEnabledState(); this.sendEventPaymentPageUpdated(); }); @@ -107,19 +113,34 @@ export class PaymentPageConfig { } public get goals(): Goal[] { - return this._goals; + return this._goals; } public set goals(value: Goal[]) { - this._goals = value; + this._goals = value; } public get minimalAmount() { - return this._minimalAmount; + return this._minimalAmount; } public set minimalAmount(value) { this._minimalAmount = value; this.config.value["minimalAmount"] = value; this.sendEventPaymentPageUpdated(); } + public get payButtonText(): string { + return this._payButtonText; + } + public set payButtonText(value: string) { + this._payButtonText = value; + this.config.value["payButtonText"] = value; + this.sendEventPaymentPageUpdated(); + } + public get customCss(): string { + return this._customCss; + } + public set customCss(value: string) { + this._customCss = value; + this.config.value["customCss"] = value; + } async reloadConfig(): Promise { const data = await axios.get( diff --git a/src/components/PaymentPageConfig/PaymentPageConfigComponent.tsx b/src/components/PaymentPageConfig/PaymentPageConfigComponent.tsx index 7442a75..c08efcf 100644 --- a/src/components/PaymentPageConfig/PaymentPageConfigComponent.tsx +++ b/src/components/PaymentPageConfig/PaymentPageConfigComponent.tsx @@ -38,6 +38,7 @@ export default function PaymentPageConfigComponent({}: {}) { const [inn, setInn] = useState(""); const [arbitraryText, setArbitraryText] = useState(null); const [hasChanges, setHasChanges] = useState(false); + const [payButtonText, setPayButtonText] = useState(null); function listenPaymentPageConfigUpdated() { if (!paymentPageConfig.current) { @@ -52,6 +53,7 @@ export default function PaymentPageConfigComponent({}: {}) { setFio(paymentPageConfig.current?.fio ?? ""); setInn(paymentPageConfig.current?.inn ?? ""); setArbitraryText(paymentPageConfig.current?.arbitraryText ?? null); + setPayButtonText(paymentPageConfig.current?.payButtonText ?? null); } const handleBackUpload = (e: ChangeEvent) => { @@ -61,6 +63,17 @@ export default function PaymentPageConfigComponent({}: {}) { } }; + const handleCssUpload = (e: ChangeEvent) => { + 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.save(); + } + uploadFile(file, `css-${recipientId}.css`); + } + }; + const handleLogoUpload = (e: ChangeEvent) => { if (e.target.files) { const file = e.target.files[0]; @@ -165,6 +178,13 @@ export default function PaymentPageConfigComponent({}: {}) { /> +
+
Custom css
+ +
Текст на странице