-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add TestAlert button to PaymentAlertsSettings
- Loading branch information
Showing
11 changed files
with
136 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
src/components/ConfigurationPage/settings/DonationTimerSettings.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/components/ConfigurationPage/settings/TestAlertButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { useState } from "react"; | ||
import PopupComponent from "../../Popup/PopupComponent"; | ||
import { publish } from "../../../socket"; | ||
import { log } from "../../../logging"; | ||
import { Config } from "../../../config"; | ||
import { useLoaderData } from "react-router"; | ||
import { WidgetData } from "../../../types/WidgetData"; | ||
|
||
export default function TestAlertButton({ config }: { config: Config }) { | ||
const [nickname, setNickname] = useState(""); | ||
const [message, setMessage] = useState(""); | ||
const [amount, setAmount] = useState(""); | ||
const { conf } = useLoaderData() as WidgetData; | ||
|
||
function sendTestAlert() { | ||
publish(conf.topic.alerts, { | ||
id: "ae7d3c02-209b-4b69-a95b-2a60de4aff9b", | ||
nickname: nickname ? nickname : "Аноним", | ||
message: message ? message : "Тестовое сообщение", | ||
amount: { | ||
major: amount ? parseInt(amount) : 40, | ||
minor: 0, | ||
currency: "RUB", | ||
}, | ||
}); | ||
log.debug("Send test alert"); | ||
} | ||
return ( | ||
<> | ||
<PopupComponent buttonText="Тестовый алерт"> | ||
<div> | ||
<div className="test-alert-field-container"> | ||
<div className="test-alert-field-label">Nickname</div> | ||
<input | ||
value={nickname} | ||
placeholder="Аноним" | ||
autoComplete="off" | ||
onChange={(e) => { | ||
setNickname(e.target.value); | ||
}} | ||
/> | ||
</div> | ||
<div className="test-alert-field-container"> | ||
<div className="test-alert-field-label">Message</div> | ||
<textarea | ||
value={message} | ||
placeholder="Тестовое сообщение" | ||
autoComplete="off" | ||
onChange={(e) => { | ||
setMessage(e.target.value); | ||
}} | ||
/> | ||
</div> | ||
<div className="test-alert-field-container"> | ||
<div className="test-alert-field-label">Amount</div> | ||
<input | ||
value={amount} | ||
placeholder="40" | ||
autoComplete="off" | ||
onChange={(e) => { | ||
setAmount(e.target.value); | ||
}} | ||
/> | ||
</div> | ||
<div className="test-alert-buttons"> | ||
<button | ||
className="btn btn-dark" | ||
onClick={() => { | ||
sendTestAlert(); | ||
}} | ||
> | ||
Test alert | ||
</button> | ||
</div> | ||
</div> | ||
</PopupComponent> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,5 @@ | |
} | ||
|
||
.button { | ||
width: unset!important; | ||
margin-bottom: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.popup { | ||
position: fixed; | ||
left: 0px; | ||
top: 0px; | ||
height: 100%; | ||
width: 100%; | ||
background: rgba(30, 30, 30, 0.9); | ||
z-index: 3; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { useState } from "react"; | ||
import classes from "./PopupComponent.module.css"; | ||
|
||
export default function PopupComponent({ | ||
children, | ||
buttonText, | ||
}: { | ||
children: React.ReactNode; | ||
buttonText: string; | ||
}) { | ||
const [showPopup, setShowPopup] = useState<boolean>(false); | ||
|
||
return ( | ||
<> | ||
<button | ||
className={`widget-button`} | ||
onClick={() => setShowPopup(!showPopup)} | ||
> | ||
{buttonText} | ||
</button> | ||
<div | ||
className={`${classes.popup} ${showPopup ? "" : "visually-hidden"}`} | ||
tabIndex={-1} | ||
> | ||
<button id="close-add-media-popup" onClick={() => setShowPopup(false)}> | ||
<span className="material-symbols-sharp">close</span> | ||
</button> | ||
{children} | ||
</div> | ||
</> | ||
); | ||
} |