From 63633dcd62e72a6c55533b50949630ed8d554328 Mon Sep 17 00:00:00 2001 From: Rosyid Haryadi Date: Sat, 30 Sep 2023 14:21:44 +0700 Subject: initial commit --- src/App.jsx | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/App.jsx (limited to 'src/App.jsx') diff --git a/src/App.jsx b/src/App.jsx new file mode 100644 index 0000000..da2bbc7 --- /dev/null +++ b/src/App.jsx @@ -0,0 +1,82 @@ +import {useEffect, useState} from "react"; +import Entry from "./Entry.jsx"; + +import {Button, Container, Typography} from "@mui/material"; +import dayjs from "dayjs"; +import SalaryInput from "./SalaryInput.jsx"; + + +function App() { + const [listEntry, setListEntry] = useState( + [ + {id: 0, date: dayjs(), start: dayjs(), finish: dayjs()}, + ] + ); + const [removeDisabled, setRemoveDisabled] = useState(false); + // const [lastId, setLastId] = useState(0); + + useEffect(() => { + setRemoveDisabled(listEntry.length === 1); + }, [listEntry]); + + const getLastId = () => { + const lastEntry = listEntry[listEntry.length - 1]; + return lastEntry.id; + } + + const addToList = () => { + const newEntry = { + id: getLastId() + 1, + date: dayjs(), + start: dayjs(), + finish: dayjs() + } + setListEntry((currentList) => [...currentList, newEntry]); + } + + const removeFromList = (id) => { + setListEntry((currentList) => { + return currentList.filter((en) => en.id !== id); + }); + } + + return ( + + Overtime Calculator + 🤑🤑 Sudahkah anda lembur hari ini? 🤑🤑 + + + ) +} + +export default App -- cgit v1.2.3-70-g09d2