diff --git a/src/components/ConfigurationPage/css/Widget.css b/src/components/ConfigurationPage/css/Widget.css index c2966fe..3213ec7 100644 --- a/src/components/ConfigurationPage/css/Widget.css +++ b/src/components/ConfigurationPage/css/Widget.css @@ -135,6 +135,19 @@ outline: none; } +.audio-button-container { + display: flex; + justify-content: space-between; + align-items: center; +} + +.sound-container { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; +} + .current-sound { display: inline-block; padding-top: 5px; @@ -147,6 +160,12 @@ cursor: pointer; } +.audio-name { + vertical-align: top; + margin-right: 10px; + font-weight: 900; +} + .new-alert.payment-alerts-previews-item .payment-alert-image-preview { border: none; background-color: #2b3566; diff --git a/src/components/ConfigurationPage/settings/PaymentAlertsSettings.tsx b/src/components/ConfigurationPage/settings/PaymentAlertsSettings.tsx index 94f1151..50a601f 100644 --- a/src/components/ConfigurationPage/settings/PaymentAlertsSettings.tsx +++ b/src/components/ConfigurationPage/settings/PaymentAlertsSettings.tsx @@ -6,53 +6,13 @@ import ColorPicker from "./ColorPicker"; import BaseSettings from "./BaseSettings"; import BooleanPropertyInput from "./properties/BooleanPropertyInput"; import TestAlertButton from "./TestAlertButton"; +import FontSelect from "./FontSelect"; interface PaymentAlertSettingsProps { id: string; onChange: Function; } -const fonts = [ - "Roboto", - "Ruslan Display", - "Cuprum", - "Anonymous Pro", - "Pangolin", - "Ruda", - "Stalinist One", - "Montserrat", - "Ubuntu Mono", - "Jura", - "Scada", - "Prosto One", - "Arsenal", - "Tenor Sans", - "El Messiri", - "Yeseva One", - "Pattaya", - "Andika", - "Gabriela", - "Marmelad", - "Cormorant Unicase", - "Cormorant SC", - "Amatic SC", - "Rubik Mono One", - "PT Sans Caption", - "Spectral SC", - "Rubik", - "Exo 2", - "Exo", - "Oswald", - "Underdog", - "Kurale", - "Forum", - "Neucha", - "Didact Gothic", - "Philosopher", - "Russo One", - "Noto Serif", -]; - export default function PaymentAlertSettings({ id, onChange, @@ -60,7 +20,6 @@ export default function PaymentAlertSettings({ const [tab, setTab] = useState("trigger"); const [selected, setSelected] = useState(-2); const { config, setConfig } = useContext(WidgetsContext); - const [showTestAlert, setShowTestAlert] = useState(false); function addDefaultAlert(): void { let alerts = config.get(id)?.alerts; @@ -291,6 +250,21 @@ export default function PaymentAlertSettings({ } }; + function deleteImage() { + setConfig((oldConfig) => { + const alertConfig = oldConfig.get(id); + const alerts = alertConfig?.alerts; + let updatedAlerts = alerts?.at(selected); + updatedAlerts.image = null; + updatedAlerts.video = null; + alerts[selected] = updatedAlerts; + alertConfig.alerts = alerts; + const newConfig = new Map(oldConfig).set(id, alertConfig); + return newConfig; + }); + onChange.call({}); + } + const handleVideoUpload = (e: ChangeEvent) => { if (e.target.files) { const file = e.target.files[0]; @@ -331,6 +305,20 @@ export default function PaymentAlertSettings({ } }; + function deleteAudio() { + setConfig((oldConfig) => { + const alertConfig = oldConfig.get(id); + const alerts = alertConfig?.alerts; + let updatedAlerts = alerts?.at(selected); + updatedAlerts.audio = null; + alerts[selected] = updatedAlerts; + alertConfig.alerts = alerts; + const newConfig = new Map(oldConfig).set(id, alertConfig); + return newConfig; + }); + onChange.call({}); + } + function update(key: string, value: any) { setConfig((oldConfig) => { const widgetConfig = oldConfig.get(id) ?? {}; @@ -510,15 +498,10 @@ export default function PaymentAlertSettings({ /> )} {prop.type === "fontselect" && ( - + update(prop.name, font)} + /> )} {prop.type === "color" && (
@@ -562,32 +545,62 @@ export default function PaymentAlertSettings({ )} {"image" === tab && (
- - + {!config.get(id)?.alerts?.at(selected)?.video && + !config.get(id)?.alerts?.at(selected)?.image && ( + <> + + + + )} + {(config.get(id)?.alerts?.at(selected)?.video || + config.get(id)?.alerts?.at(selected)?.image) && ( + + )}
)} {"sound" === tab && ( <> -
- - playAudio(config.get(id)?.alerts?.at(selected).audio) - } - className="material-symbols-sharp" - > - play_circle - +
+ {config.get(id)?.alerts?.at(selected).audio && ( +
+ + {config.get(id)?.alerts?.at(selected).audio} + + + playAudio(config.get(id)?.alerts?.at(selected).audio) + } + className="material-symbols-sharp" + > + play_circle + +
+ )} +
+ {!config.get(id)?.alerts?.at(selected).audio && ( + + )} + {config.get(id)?.alerts?.at(selected).audio && ( + + )} +
- )} @@ -595,7 +608,7 @@ export default function PaymentAlertSettings({ return ( <> - + {previews()} {selected > -1 && ( diff --git a/src/index.css b/src/index.css index d9ad4d7..6d0611b 100644 --- a/src/index.css +++ b/src/index.css @@ -79,8 +79,8 @@ code { .upload-button { background-color: #151a33; color: #7885bd; - padding-top: 10px; - padding-bottom: 10px; + padding-top: 7px; + padding-bottom: 9px; padding-left: 10px; padding-right: 10px; margin-top: 20px;