Skip to content

Commit 969032b

Browse files
Fix: Resource Management Modal Review Issues
1 parent f912d8e commit 969032b

2 files changed

Lines changed: 22 additions & 24 deletions

File tree

src/components/ResourceManagement/ResourceManagement.jsx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,25 @@ function AddLogModal({ isOpen, onClose, onAdd }) {
6868
const validateForm = () => {
6969
const newErrors = {};
7070
const timeRegex = /^([0-1]\d|2[0-3]):([0-5]\d):([0-5]\d)$/;
71+
const textRegex = /^[a-zA-Z\s]+$/;
7172

7273
if (!formData.user.trim()) newErrors.user = 'User is required';
7374

74-
if (!timeRegex.test(formData.timeDuration)) {
75+
if (!formData.timeDuration.trim()) {
76+
newErrors.timeDuration = 'Time/Duration is required';
77+
} else if (!timeRegex.test(formData.timeDuration)) {
7578
newErrors.timeDuration = 'Time must be in HH:MM:SS format';
7679
}
7780

7881
if (!formData.facilities.trim()) {
7982
newErrors.facilities = 'Facilities is required';
80-
} else if (!/^[a-zA-Z\s]+$/.test(formData.facilities)) {
83+
} else if (!textRegex.test(formData.facilities)) {
8184
newErrors.facilities = 'Facilities should contain only letters';
8285
}
8386

8487
if (!formData.materials.trim()) {
8588
newErrors.materials = 'Materials is required';
86-
} else if (!/^[a-zA-Z\s]+$/.test(formData.materials)) {
89+
} else if (!textRegex.test(formData.materials)) {
8790
newErrors.materials = 'Materials should contain only letters';
8891
}
8992

@@ -95,13 +98,6 @@ function AddLogModal({ isOpen, onClose, onAdd }) {
9598
const handleSubmit = e => {
9699
e.preventDefault();
97100

98-
const error = validateForm();
99-
100-
if (error) {
101-
setValidationError(error);
102-
return;
103-
}
104-
105101
const validationErrors = validateForm();
106102

107103
if (Object.keys(validationErrors).length > 0) {
@@ -119,6 +115,7 @@ function AddLogModal({ isOpen, onClose, onAdd }) {
119115
date: '',
120116
});
121117

118+
setErrors({});
122119
onClose();
123120
};
124121

@@ -149,9 +146,9 @@ function AddLogModal({ isOpen, onClose, onAdd }) {
149146
))}
150147

151148
<div className={styles.formGroup}>
152-
<label htmlFor="date">Date</label>
149+
<label htmlFor="resource-date">Date</label>
153150
<input
154-
id="date"
151+
id="resource-date"
155152
name="date"
156153
type="date"
157154
value={formData.date}
@@ -161,17 +158,6 @@ function AddLogModal({ isOpen, onClose, onAdd }) {
161158
{errors.date && <span className={styles.errorText}>{errors.date}</span>}
162159
</div>
163160

164-
<div className={styles.formGroup}>
165-
<label htmlFor="date">Date</label>
166-
<input
167-
id="date"
168-
name="date"
169-
type="date"
170-
value={formData.date}
171-
onChange={handleChange}
172-
/>
173-
</div>
174-
175161
<div className={styles.modalActions}>
176162
<button type="submit" className={styles.submitButton}>
177163
Save Log

src/components/ResourceManagement/ResourceManagement.module.css

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@
350350

351351
.formGroup {
352352
margin-bottom: 1.25rem;
353+
display: flex;
354+
flex-direction: column;
353355
}
354356

355357
.formGroup label {
@@ -370,6 +372,10 @@
370372
color: #333;
371373
}
372374

375+
.formGroup input[type='date'] {
376+
color-scheme: light;
377+
}
378+
373379
.formGroup input:focus {
374380
outline: none;
375381
border-color: #007bff;
@@ -382,6 +388,10 @@
382388
border: 1px solid #667b9c;
383389
}
384390

391+
.modalContentDark .formGroup input[type='date'] {
392+
color-scheme: dark;
393+
}
394+
385395
.inputError {
386396
border: 1px solid #ff4d4f !important;
387397
}
@@ -391,10 +401,12 @@
391401
font-size: 12px;
392402
margin-top: 4px;
393403
display: block;
404+
line-height: 1.3;
405+
text-align: left;
394406
}
395407

396408
.modalContentDark .errorText {
397-
color: #ff7a7a;
409+
color: #ff9a9a;
398410
}
399411

400412
.modalActions {

0 commit comments

Comments
 (0)