feat: add auto deactivate option for slot plans
Add an autoDeactivate flag to pickup configuration entries, expose it as a dashboard checkbox beside the active state, and keep existing entries defaulting to automatic deactivation unless explicitly disabled.
This commit is contained in:
11
src/App.js
11
src/App.js
@@ -529,6 +529,15 @@ function App() {
|
||||
);
|
||||
};
|
||||
|
||||
const handleToggleAutoDeactivate = (entryId) => {
|
||||
setIsDirty(true);
|
||||
setConfig((prev) =>
|
||||
prev.map((item) =>
|
||||
item.id === entryId ? { ...item, autoDeactivate: item.autoDeactivate === false } : item
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
const handleToggleProfileCheck = (entryId) => {
|
||||
setIsDirty(true);
|
||||
setConfig((prev) =>
|
||||
@@ -693,6 +702,7 @@ function App() {
|
||||
id: storeId,
|
||||
label: store.name || `Store ${storeId}`,
|
||||
active: false,
|
||||
autoDeactivate: true,
|
||||
checkProfileId: true,
|
||||
onlyNotify: false,
|
||||
skipDormantCheck: false,
|
||||
@@ -813,6 +823,7 @@ function App() {
|
||||
config={config}
|
||||
registeredPickups={registeredPickups}
|
||||
onToggleActive={handleToggleActive}
|
||||
onToggleAutoDeactivate={handleToggleAutoDeactivate}
|
||||
onToggleProfileCheck={handleToggleProfileCheck}
|
||||
onToggleOnlyNotify={handleToggleOnlyNotify}
|
||||
onToggleDormantSkip={handleToggleDormantSkip}
|
||||
|
||||
@@ -202,6 +202,7 @@ const DashboardView = ({
|
||||
config,
|
||||
registeredPickups,
|
||||
onToggleActive,
|
||||
onToggleAutoDeactivate,
|
||||
onToggleProfileCheck,
|
||||
onToggleOnlyNotify,
|
||||
onToggleDormantSkip,
|
||||
@@ -388,6 +389,44 @@ const DashboardView = ({
|
||||
enableSorting: false,
|
||||
enableColumnFilter: false
|
||||
}),
|
||||
columnHelper.accessor((row) => row.autoDeactivate !== false, {
|
||||
id: 'autoDeactivate',
|
||||
header: ({ column }) => (
|
||||
<div>
|
||||
<span className="font-semibold text-sm">Automatisch deaktivieren</span>
|
||||
<ColumnSelectFilter
|
||||
column={column}
|
||||
options={[
|
||||
{ value: 'true', label: 'Ja' },
|
||||
{ value: 'false', label: 'Nein' }
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<div className="text-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="h-5 w-5"
|
||||
checked={row.original.autoDeactivate !== false}
|
||||
onChange={() => onToggleAutoDeactivate(row.original.id)}
|
||||
title="Nach erfolgreicher Slot-Aktion automatisch deaktivieren"
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
filterFn: (row, columnId, value) => {
|
||||
if (value === undefined) {
|
||||
return true;
|
||||
}
|
||||
const boolValue = value === 'true';
|
||||
return row.getValue(columnId) === boolValue;
|
||||
},
|
||||
sortingFn: (rowA, rowB, columnId) => {
|
||||
const a = rowA.getValue(columnId);
|
||||
const b = rowB.getValue(columnId);
|
||||
return Number(b) - Number(a);
|
||||
}
|
||||
}),
|
||||
columnHelper.accessor('label', {
|
||||
header: ({ column }) => (
|
||||
<div>
|
||||
@@ -649,7 +688,9 @@ const DashboardView = ({
|
||||
onDeleteEntry,
|
||||
onHideEntry,
|
||||
onRangePickerRequest,
|
||||
onToggleAutoDeactivate,
|
||||
onToggleActive,
|
||||
onToggleDormantSkip,
|
||||
onToggleOnlyNotify,
|
||||
onToggleProfileCheck,
|
||||
onWeekdayChange,
|
||||
|
||||
Reference in New Issue
Block a user