diff --git a/web/src/App.js b/web/src/App.js index 0d0dfb4..7d52df9 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -4,6 +4,7 @@ import Typography from '@mui/material/Typography'; import Box from '@mui/material/Box'; import Link from '@mui/material/Link'; import ProTip from './ProTip'; +import {useState} from "react"; function Copyright() { return ( @@ -57,22 +58,53 @@ function NotificationItem(props) { ); } +function SubscriptionAddForm(props) { + const [topic, setTopic] = useState(""); + const handleSubmit = (ev) => { + ev.preventDefault(); + props.onSubmit({ + base_url: "https://ntfy.sh", + topic: topic, + }); + } + return ( +
+ setTopic(ev.target.value)} + placeholder="Topic name, e.g. phil_alerts" + required + /> +
+ ); +} + export default function App() { - const subscriptions = [ + const [state, setState] = useState({ + subscriptions: [], + }); + /*const subscriptions = [ {base_url: "https://ntfy.sh", topic: "mytopic"}, {base_url: "https://ntfy.sh", topic: "phils_alerts"}, - ]; + ];*/ const notifications = [ {id: "qGrfmhp3vK", times: 1645193395, message: "Message 1"}, {id: "m4YYjfxwyT", times: 1645193428, message: "Message 2"} ]; + const addSubscription = (newSubscription) => { + setState(prevState => ({ + subscriptions: [...prevState.subscriptions, newSubscription], + })); + } return ( ntfy - + +