|
|
@@ -213,29 +213,35 @@
|
|
|
const disabledDate = (time: Date) => {
|
|
|
return time.getTime() > Date.now();
|
|
|
};
|
|
|
- const disabledHours = () => {
|
|
|
- const arrs: number[] = [];
|
|
|
- for (let i = 0; i < 24; i++) {
|
|
|
- if (new Date().getHours() >= i) continue;
|
|
|
- arrs.push(i);
|
|
|
- }
|
|
|
- return arrs;
|
|
|
+ const disabledHours = (role, comparingDate) => {
|
|
|
+ if (!role) return [];
|
|
|
+ const now = new Date();
|
|
|
+ now.setHours(0, 0, 0, 0);
|
|
|
+ if (comparingDate.valueOf() < now.getTime()) return [];
|
|
|
+ const huors = 23 - new Date().getHours();
|
|
|
+ return Array.from({ length: huors }, (_, i) => 23 - i);
|
|
|
};
|
|
|
- const disabledMinutes = () => {
|
|
|
- const arrs: number[] = [];
|
|
|
- for (let i = 0; i < 60; i++) {
|
|
|
- if (new Date().getMinutes() >= i) continue;
|
|
|
- arrs.push(i);
|
|
|
- }
|
|
|
- return arrs;
|
|
|
+ const disabledMinutes = (hour, role, comparingDate) => {
|
|
|
+ if (!role) return [];
|
|
|
+ const now = new Date();
|
|
|
+ const nowHour = now.getHours();
|
|
|
+ if (hour < nowHour) return [];
|
|
|
+ now.setHours(0, 0, 0, 0);
|
|
|
+ if (comparingDate.valueOf() < now.getTime()) return [];
|
|
|
+ const minutes = 59 - new Date().getMinutes();
|
|
|
+ return Array.from({ length: minutes }, (_, i) => 59 - i);
|
|
|
};
|
|
|
- const disabledSeconds = () => {
|
|
|
- const arrs: number[] = [];
|
|
|
- for (let i = 0; i < 60; i++) {
|
|
|
- if (new Date().getSeconds() >= i) continue;
|
|
|
- arrs.push(i);
|
|
|
- }
|
|
|
- return arrs;
|
|
|
+ const disabledSeconds = (hour, minute, role, comparingDate) => {
|
|
|
+ if (!role) return [];
|
|
|
+ const now = new Date();
|
|
|
+ const nowHour = now.getHours();
|
|
|
+ const nowMinutes = now.getMinutes();
|
|
|
+ if (hour < nowHour) return [];
|
|
|
+ if (hour === nowHour && minute < nowMinutes) return [];
|
|
|
+ now.setHours(0, 0, 0, 0);
|
|
|
+ if (comparingDate.valueOf() < now.getTime()) return [];
|
|
|
+ const seconds = 59 - new Date().getSeconds();
|
|
|
+ return Array.from({ length: seconds }, (_, i) => 59 - i);
|
|
|
};
|
|
|
|
|
|
const handleAccidentTimeChange = () => {
|