Skip to content

Commit

Permalink
Merge pull request #41 from codeday/feat-sms-max-len
Browse files Browse the repository at this point in the history
This prevents people from accidentally sending out a large amount of texts and racking up our Twilio bill
  • Loading branch information
oohwooh authored Jul 18, 2024
2 parents c2308f0 + 54b5d8d commit 9a48b41
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/pages/events/[event]/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {getSession} from "next-auth/react";
import {SendNotification, getEventQuery} from "./notification.gql"
import {useFetcher, getFetcher} from "../../../fetch";

const MAX_SMS_LENGTH = 280

export default function Notification({event}) {
const fetch = useFetcher();
const [emailSubject, setEmailSubject] = useState('');
Expand Down Expand Up @@ -36,14 +38,15 @@ export default function Notification({event}) {
mb={2}
/>
<Textarea
placeholder="SMS/WhatsApp Body"
placeholder={`SMS/WhatsApp Body (Max ${MAX_SMS_LENGTH} char})`}
value={smsBody}
onChange={(e) => setSmsBody(e.target.value)}
mb={2}
isInvalid={smsBody.length > MAX_SMS_LENGTH}
/>
<Button
isLoading={isLoading}
disabled={!(smsBody || (emailBody && emailSubject))}
disabled={smsBody.length <= MAX_SMS_LENGTH || !(smsBody || (emailBody && emailSubject))}
onClick={async () => {
success(`Notification sent.`);
setIsLoading(true);
Expand Down

0 comments on commit 9a48b41

Please sign in to comment.