Message
Message
const projects = [
{
value: "QBit Logs",
label: "QBit Logs",
},
{
value: "QBit Suite",
label: "QBit Suite",
},
{
value: "Ragnar",
label: "Ragnar",
},
];
const logTypes = [
{
value: "work",
label: "Work",
},
{
value: "office",
label: "Office",
},
{
value: "meeting",
label: "Meeting",
},
{
value: "leave",
label: "Leave",
},
];
function UpdateLogsComponent() {
const [logDate, setLogDate] = useState("");
const [logType, setLogType] = useState("");
const [project, setProject] = useState("");
const [hours, setHours] = useState("");
const [minutes, setMinutes] = useState("");
const [logDescription, setLogDescription] = useState("");
const [logs, setLogs] = useState([]);
const [selectedLogIndex, setSelectedLogIndex] = useState(null);
const handleLogDateChange = (event) => {
const selectedDate = new Date(event.target.value);
const today = new Date();
today.setHours(0, 0, 0, 0); // Set time to start of day for comparison
if (selectedDate > today) {
// If the entered date is beyond current date, set it to the current date
setLogDate(today.toISOString().split("T")[0]);
} else {
setLogDate(selectedDate.toISOString().split("T")[0]);
}
};
clearInputFields();
};
console.log("Submitting logs...");
};
// You can define isButtonDisabled here if it's used outside this component
const isButtonDisabled = !(
logDate &&
logType &&
project &&
hours &&
minutes &&
logDescription
);
const isButtonDisabledd = !(calculateTotalTimeInTable() >= 8);
return (
<Container>
<Box
sx={{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"colu
mn"}}>
<Box
p={3}
mt={15}
ml={2}
mr={2}
boxShadow={6}
borderRadius={4}
sx={{ backdropFilter: "blur(12px)" }}
>
<Grid container spacing={4}>
<Grid item xs={12} sm={12} md={4}>
<Typography color={"#fff"} sx={{ my: 1 }}>
Log Date
</Typography>
<TextField
fullWidth
id="log-date"
type="date"
variant="standard"
autoComplete="off"
value={logDate}
onChange={handleLogDateChange}
inputProps={{
max: new Date().toISOString().split("T")[0],
}}
/>
</Grid>
<Grid item xs={12} sm={6} md={4}>
<Typography color={"#fff"} sx={{ my: 1 }}>
Hours
</Typography>
<TextField
select
fullWidth
id="hours"
variant="standard"
value={hours}
onChange={handleHoursChange}
>
{[...Array(24).keys()].map((hour) => (
<MenuItem key={hour} value={hour}>
{hour}
</MenuItem>
))}
</TextField>
</Grid>
<Grid item xs={12} sm={6} md={4}>
<Typography color={"#fff"} sx={{ my: 1 }}>
Minutes
</Typography>
<TextField
select
fullWidth
id="minutes"
variant="standard"
value={minutes}
onChange={handleMinutesChange}
>
{[...Array(60).keys()].map((minute) => (
<MenuItem key={minute} value={minute}>
{minute}
</MenuItem>
))}
</TextField>
</Grid>
<Grid item xs={12} md={6}>
<Typography color={"#fff"} sx={{ my: 1 }}>
Log Type
</Typography>
<TextField
select
fullWidth
id="log-type"
variant="standard"
value={logType}
onChange={handleLogTypeChange}
>
{logTypes.map((option) => (
<MenuItem key={option.value} value={option.value}>
{option.label}
</MenuItem>
))}
</TextField>
</Grid>
<Button
variant="contained"
color="primary"
onClick={handleSubmitLogs}
disabled={isButtonDisabledd}
sx={{ mt: 2, borderRadius: "50px", bgcolor: "#858BC5" }}
>
Submit Logs
</Button>
</Box>
</Box>
</Container>
);
}