Skip to content

Commit

Permalink
fix: add message validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramin Rezaei committed May 28, 2024
1 parent 54df1a9 commit 25646dc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/domains/counter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ export function CounterPage() {
const onSubmit = (e: FormEvent<HTMLButtonElement>) => {
e.preventDefault();

if (!text.trim()) return;

const AUDIO = new Audio(AUDIO_FILE);
AUDIO.play();

const date = new Date();
const created = `${date.getFullYear()}-${date.getMonth()}-${date.getDay()} | ${date.getHours()}:${date.getMinutes()}`;

const message: GMessage = {
text,
created,
id: null,
userId: id
userId: id,
text: text.trim(),
};

PostMessageRequest(message, (savedMessage) => {
Expand Down

0 comments on commit 25646dc

Please sign in to comment.