Skip to content

Commit

Permalink
remove comments and add formatTime back
Browse files Browse the repository at this point in the history
  • Loading branch information
selenaliu1 committed Dec 6, 2024
1 parent 6d94c6a commit 8010278
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 78 deletions.
75 changes: 0 additions & 75 deletions frontend/src/components/EmployeeModal/RoleSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,78 +64,3 @@ const RoleSelector = ({ selectedRoles, setSelectedRoles }: Props) => {
};

export default RoleSelector;

// import React, { ChangeEvent, Dispatch, SetStateAction, useState } from 'react';
// import styles from './employeemodal.module.css';
// import { Label, Input } from '../FormElements/FormElements';

// type Props = {
// selectedRoles: string[];
// setSelectedRoles: Dispatch<SetStateAction<string[]>>;
// };

// const RoleSelector = ({ selectedRoles, setSelectedRoles }: Props) => {
// const [roles, setRoles] = useState<string[]>(selectedRoles);

// const onChange = (e: ChangeEvent<HTMLInputElement>) => {
// const role = e.target.value;
// const checked = e.target.checked;
// const updatedRoles = checked
// ? [...roles, role]
// : roles.filter((r) => r !== role);
// setRoles(updatedRoles);
// setSelectedRoles(updatedRoles); // Update the parent component state with the selected roles
// };

// return (
// <div className={styles.roleSelector}>
// <p className={styles.roleSelectorTitle}>Role</p>
// <div className={styles.radioGroup}>
// <div className={styles.radioOption}>
// <Input
// className={styles.radioButton}
// id="driver"
// name="role"
// type="checkbox"
// value="driver"
// onChange={onChange}
// checked={roles.includes('driver')}
// />
// <Label className={styles.driverLabel} htmlFor={'driver'}>
// Driver
// </Label>
// </div>
// <div className={styles.radioOption}>
// <Input
// className={styles.radioButton}
// id="redrunner-admin"
// name="role"
// type="checkbox"
// value="redrunner-admin"
// onChange={onChange}
// checked={roles.includes('redrunner-admin')}
// />
// <Label className={styles.driverLabel} htmlFor={'redrunner-admin'}>
// Redrunner Admin
// </Label>
// </div>
// <div className={styles.radioOption}>
// <Input
// className={styles.radioButton}
// id="sds-admin"
// name="role"
// type="checkbox"
// value="sds-admin"
// onChange={onChange}
// checked={roles.includes('sds-admin')}
// />
// <Label className={styles.driverLabel} htmlFor={'sds-admin'}>
// SDS Admin
// </Label>
// </div>
// </div>
// </div>
// );
// };

// export default RoleSelector;
4 changes: 2 additions & 2 deletions frontend/src/components/EmployeeModal/StartDate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const StartDate = ({ existingDate }: StartDateProps) => {
InputLabelProps={{
shrink: true, // Keeps the label visible even when a value is set
}}
size="small" // Reduces height of the field
sx={{ width: '150px' }} // Optional: Adjust width if needed
size="small"
sx={{ width: '150px' }}
{...register('startDate', { required: true })}
error={!!errors.startDate}
helperText={errors.startDate ? 'Start date is required' : ''}
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/EmployeeModal/WorkingHours.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '@mui/material';
import DeleteIcon from '@mui/icons-material/Delete';
import { WeekProvider, useWeek } from './WeekContext';
import moment from 'moment';

type FormData = {
availability: {
Expand Down Expand Up @@ -65,7 +66,10 @@ const AvailabilityInput: React.FC<AvailabilityInputProps> = ({

const prefillTimeRange = useCallback(() => {
if (existingTimeRange) {
const [startTime, endTime] = existingTimeRange.split('-');
// const [startTime, endTime] = existingTimeRange.split('-');
let [startTime, endTime] = existingTimeRange.split('-');
startTime = formatTime(startTime);
endTime = formatTime(endTime);
setExistingTime([startTime, endTime]);
}
}, [existingTimeRange]);
Expand All @@ -79,6 +83,8 @@ const AvailabilityInput: React.FC<AvailabilityInputProps> = ({
setValue(`${instance}.days`, days);
}, [instance, days, setValue]);

const formatTime = (time: string): string =>
moment(time, 'ha').format('HH:mm');
return (
<Box
sx={{
Expand Down

0 comments on commit 8010278

Please sign in to comment.