Skip to content

Commit

Permalink
Merge pull request #22 from anshu1992/clear-input-after-successful-ht…
Browse files Browse the repository at this point in the history
…tp-request

Clears input field.
  • Loading branch information
ats1999 authored Jan 20, 2022
2 parents 9f90c8d + 8749a54 commit 96d3bd8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pages/back-date.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useRef } from "react";

import {
VStack,
Expand All @@ -18,6 +18,7 @@ export default function BackDate() {
const [submitIng, setSubmitIng] = useState(false);
const [time, setTime] = useState(0);
const [date, setDate] = useState(to_YY_MM_DD(new Date()));
const minutesInputRef = useRef(null);

const submitTagTimer = () => {
setSubmitIng(true);
Expand All @@ -29,6 +30,8 @@ export default function BackDate() {
})
.then((res) => {
alert("Updated successfully");
minutesInputRef.current.value = '';
setTime('');
alert(err?.response?.data || "Internal Server Error :)");
})
.catch((err) => {
Expand Down Expand Up @@ -57,6 +60,7 @@ export default function BackDate() {
<Input
onChange={(e) => setTime(e.target.value)}
placeholder="minutes"
ref={minutesInputRef}
w="100%"
type="number"
/>
Expand Down

1 comment on commit 96d3bd8

@vercel
Copy link

@vercel vercel bot commented on 96d3bd8 Jan 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.