updated admin to use swr hooks instead of react-query

This commit is contained in:
dswbx
2024-12-13 16:24:55 +01:00
parent 50c5adce0c
commit 8c91dff94d
20 changed files with 380 additions and 275 deletions

View File

@@ -18,6 +18,7 @@ export function getChangeSet(
data: EntityData,
fields: Field[]
): EntityData {
//console.log("getChangeSet", formData, data);
return transform(
formData,
(acc, _value, key) => {
@@ -26,11 +27,12 @@ export function getChangeSet(
if (!field || field.isVirtual()) return;
const value = _value === "" ? null : _value;
const newValue = field.getValue(value, "submit");
// normalize to null if undefined
const newValue = field.getValue(value, "submit") || null;
// @todo: add typing for "action"
if (action === "create" || newValue !== data[key]) {
acc[key] = newValue;
console.log("changed", {
/*console.log("changed", {
key,
value,
valueType: typeof value,
@@ -38,7 +40,7 @@ export function getChangeSet(
newValue,
new: value,
sent: acc[key]
});
});*/
} else {
//console.log("no change", key, value, data[key]);
}