refactoring
This commit is contained in:
11
src/App.js
11
src/App.js
@@ -435,11 +435,7 @@ function App() {
|
||||
if (item.id !== entryId) {
|
||||
return item;
|
||||
}
|
||||
const updated = { ...item, desiredWeekday: value || null };
|
||||
if (value && updated.desiredDateRange) {
|
||||
delete updated.desiredDateRange;
|
||||
}
|
||||
return updated;
|
||||
return { ...item, desiredWeekday: value || null };
|
||||
})
|
||||
);
|
||||
if (value) {
|
||||
@@ -462,9 +458,6 @@ function App() {
|
||||
start: startValue || endValue,
|
||||
end: endValue || startValue
|
||||
};
|
||||
if (updated.desiredWeekday) {
|
||||
delete updated.desiredWeekday;
|
||||
}
|
||||
} else if (updated.desiredDateRange) {
|
||||
delete updated.desiredDateRange;
|
||||
}
|
||||
@@ -499,7 +492,7 @@ function App() {
|
||||
if (!activeRangePicker) {
|
||||
return;
|
||||
}
|
||||
if (!activeRangeEntry || activeRangeEntry.desiredWeekday) {
|
||||
if (!activeRangeEntry) {
|
||||
setActiveRangePicker(null);
|
||||
}
|
||||
}, [activeRangePicker, activeRangeEntry]);
|
||||
|
||||
@@ -254,7 +254,6 @@ const DashboardView = ({
|
||||
: null;
|
||||
const rangeStart = normalizedRange?.start || '';
|
||||
const rangeEnd = normalizedRange?.end || '';
|
||||
const hasDateRange = Boolean(rangeStart || rangeEnd);
|
||||
return (
|
||||
<tr
|
||||
key={item.id || index}
|
||||
@@ -294,7 +293,6 @@ const DashboardView = ({
|
||||
value={item.desiredWeekday || ''}
|
||||
onChange={(event) => onWeekdayChange(item.id, event.target.value)}
|
||||
className="border rounded p-1 w-full"
|
||||
disabled={hasDateRange}
|
||||
>
|
||||
<option value="">Kein Wochentag</option>
|
||||
{weekdays.map((day) => (
|
||||
@@ -307,18 +305,8 @@ const DashboardView = ({
|
||||
<td className="px-4 py-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if (item.desiredWeekday) {
|
||||
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'
|
||||
}`}
|
||||
onClick={() => onRangePickerRequest(item.id)}
|
||||
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"
|
||||
>
|
||||
<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>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { de } from 'date-fns/locale';
|
||||
import { buildSelectionRange } from '../utils/dateUtils';
|
||||
|
||||
const RangePickerModal = ({ entry, minDate, onSelectRange, onResetRange, onClose }) => {
|
||||
if (!entry || entry.desiredWeekday) {
|
||||
if (!entry) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user