Refactor input fields to handle empty values
This commit is contained in:
parent
e2d2310275
commit
856ae40900
1 changed files with 42 additions and 12 deletions
|
@ -113,9 +113,14 @@ export default function GetWeeklyReport(): JSX.Element {
|
|||
type="number"
|
||||
min="0"
|
||||
className="border-2 border-black rounded-md text-center w-1/2"
|
||||
value={developmentTime}
|
||||
value={developmentTime === 0 ? "" : developmentTime}
|
||||
onChange={(e) => {
|
||||
if (e.target.value === "") {
|
||||
setDevelopmentTime(0);
|
||||
return;
|
||||
} else {
|
||||
setDevelopmentTime(parseInt(e.target.value));
|
||||
}
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
const keyValue = event.key;
|
||||
|
@ -132,9 +137,14 @@ export default function GetWeeklyReport(): JSX.Element {
|
|||
type="number"
|
||||
min="0"
|
||||
className="border-2 border-black rounded-md text-center w-1/2"
|
||||
value={meetingTime}
|
||||
value={meetingTime === 0 ? "" : meetingTime}
|
||||
onChange={(e) => {
|
||||
if (e.target.value === "") {
|
||||
setMeetingTime(0);
|
||||
return;
|
||||
} else {
|
||||
setMeetingTime(parseInt(e.target.value));
|
||||
}
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
const keyValue = event.key;
|
||||
|
@ -151,9 +161,14 @@ export default function GetWeeklyReport(): JSX.Element {
|
|||
type="number"
|
||||
min="0"
|
||||
className="border-2 border-black rounded-md text-center w-1/2"
|
||||
value={adminTime}
|
||||
value={adminTime === 0 ? "" : adminTime}
|
||||
onChange={(e) => {
|
||||
if (e.target.value === "") {
|
||||
setAdminTime(0);
|
||||
return;
|
||||
} else {
|
||||
setAdminTime(parseInt(e.target.value));
|
||||
}
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
const keyValue = event.key;
|
||||
|
@ -170,9 +185,14 @@ export default function GetWeeklyReport(): JSX.Element {
|
|||
type="number"
|
||||
min="0"
|
||||
className="border-2 border-black rounded-md text-center w-1/2"
|
||||
value={ownWorkTime}
|
||||
value={ownWorkTime === 0 ? "" : ownWorkTime}
|
||||
onChange={(e) => {
|
||||
if (e.target.value === "") {
|
||||
setOwnWorkTime(0);
|
||||
return;
|
||||
} else {
|
||||
setOwnWorkTime(parseInt(e.target.value));
|
||||
}
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
const keyValue = event.key;
|
||||
|
@ -189,9 +209,14 @@ export default function GetWeeklyReport(): JSX.Element {
|
|||
type="number"
|
||||
min="0"
|
||||
className="border-2 border-black rounded-md text-center w-1/2"
|
||||
value={studyTime}
|
||||
value={studyTime === 0 ? "" : studyTime}
|
||||
onChange={(e) => {
|
||||
if (e.target.value === "") {
|
||||
setStudyTime(0);
|
||||
return;
|
||||
} else {
|
||||
setStudyTime(parseInt(e.target.value));
|
||||
}
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
const keyValue = event.key;
|
||||
|
@ -208,9 +233,14 @@ export default function GetWeeklyReport(): JSX.Element {
|
|||
type="number"
|
||||
min="0"
|
||||
className="border-2 border-black rounded-md text-center w-1/2"
|
||||
value={testingTime}
|
||||
value={testingTime === 0 ? "" : testingTime}
|
||||
onChange={(e) => {
|
||||
if (e.target.value === "") {
|
||||
setTestingTime(0);
|
||||
return;
|
||||
} else {
|
||||
setTestingTime(parseInt(e.target.value));
|
||||
}
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
const keyValue = event.key;
|
||||
|
|
Loading…
Reference in a new issue