refactoring
This commit is contained in:
11
src/App.js
11
src/App.js
@@ -435,11 +435,7 @@ function App() {
|
|||||||
if (item.id !== entryId) {
|
if (item.id !== entryId) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
const updated = { ...item, desiredWeekday: value || null };
|
return { ...item, desiredWeekday: value || null };
|
||||||
if (value && updated.desiredDateRange) {
|
|
||||||
delete updated.desiredDateRange;
|
|
||||||
}
|
|
||||||
return updated;
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
if (value) {
|
if (value) {
|
||||||
@@ -462,9 +458,6 @@ function App() {
|
|||||||
start: startValue || endValue,
|
start: startValue || endValue,
|
||||||
end: endValue || startValue
|
end: endValue || startValue
|
||||||
};
|
};
|
||||||
if (updated.desiredWeekday) {
|
|
||||||
delete updated.desiredWeekday;
|
|
||||||
}
|
|
||||||
} else if (updated.desiredDateRange) {
|
} else if (updated.desiredDateRange) {
|
||||||
delete updated.desiredDateRange;
|
delete updated.desiredDateRange;
|
||||||
}
|
}
|
||||||
@@ -499,7 +492,7 @@ function App() {
|
|||||||
if (!activeRangePicker) {
|
if (!activeRangePicker) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!activeRangeEntry || activeRangeEntry.desiredWeekday) {
|
if (!activeRangeEntry) {
|
||||||
setActiveRangePicker(null);
|
setActiveRangePicker(null);
|
||||||
}
|
}
|
||||||
}, [activeRangePicker, activeRangeEntry]);
|
}, [activeRangePicker, activeRangeEntry]);
|
||||||
|
|||||||
@@ -254,7 +254,6 @@ const DashboardView = ({
|
|||||||
: null;
|
: null;
|
||||||
const rangeStart = normalizedRange?.start || '';
|
const rangeStart = normalizedRange?.start || '';
|
||||||
const rangeEnd = normalizedRange?.end || '';
|
const rangeEnd = normalizedRange?.end || '';
|
||||||
const hasDateRange = Boolean(rangeStart || rangeEnd);
|
|
||||||
return (
|
return (
|
||||||
<tr
|
<tr
|
||||||
key={item.id || index}
|
key={item.id || index}
|
||||||
@@ -294,7 +293,6 @@ const DashboardView = ({
|
|||||||
value={item.desiredWeekday || ''}
|
value={item.desiredWeekday || ''}
|
||||||
onChange={(event) => onWeekdayChange(item.id, event.target.value)}
|
onChange={(event) => onWeekdayChange(item.id, event.target.value)}
|
||||||
className="border rounded p-1 w-full"
|
className="border rounded p-1 w-full"
|
||||||
disabled={hasDateRange}
|
|
||||||
>
|
>
|
||||||
<option value="">Kein Wochentag</option>
|
<option value="">Kein Wochentag</option>
|
||||||
{weekdays.map((day) => (
|
{weekdays.map((day) => (
|
||||||
@@ -307,18 +305,8 @@ const DashboardView = ({
|
|||||||
<td className="px-4 py-2">
|
<td className="px-4 py-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => {
|
onClick={() => onRangePickerRequest(item.id)}
|
||||||
if (item.desiredWeekday) {
|
className="w-full border rounded p-2 text-left transition focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white hover:border-blue-400"
|
||||||
return;
|
|
||||||
}
|
|
||||||
onRangePickerRequest(item.id);
|
|
||||||
}}
|
|
||||||
disabled={Boolean(item.desiredWeekday)}
|
|
||||||
className={`w-full border rounded p-2 text-left transition focus:outline-none focus:ring-2 focus:ring-blue-500 ${
|
|
||||||
item.desiredWeekday
|
|
||||||
? 'bg-gray-100 text-gray-400 cursor-not-allowed'
|
|
||||||
: 'bg-white hover:border-blue-400'
|
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
<span className="block text-sm text-gray-700">{formatRangeLabel(rangeStart, rangeEnd)}</span>
|
<span className="block text-sm text-gray-700">{formatRangeLabel(rangeStart, rangeEnd)}</span>
|
||||||
<span className="block text-xs text-gray-500">Klicke zum Auswählen</span>
|
<span className="block text-xs text-gray-500">Klicke zum Auswählen</span>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { de } from 'date-fns/locale';
|
|||||||
import { buildSelectionRange } from '../utils/dateUtils';
|
import { buildSelectionRange } from '../utils/dateUtils';
|
||||||
|
|
||||||
const RangePickerModal = ({ entry, minDate, onSelectRange, onResetRange, onClose }) => {
|
const RangePickerModal = ({ entry, minDate, onSelectRange, onResetRange, onClose }) => {
|
||||||
if (!entry || entry.desiredWeekday) {
|
if (!entry) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user