Merge pull request #1228 from iamanishroy/new-field-subtable-array

Bug Fix - could not find row
This commit is contained in:
Shams
2023-04-25 15:35:17 +02:00
committed by GitHub
4 changed files with 9 additions and 5 deletions

View File

@@ -72,7 +72,7 @@ export default function SideDrawerFields({ row }: ISideDrawerFieldsProps) {
value,
deleteField: undefined,
arrayTableData: {
index: selectedCell.arrayIndex ?? 0,
index: selectedCell.arrayIndex,
},
});

View File

@@ -74,7 +74,7 @@ export function useMenuAction(
value: undefined,
deleteField: true,
arrayTableData: {
index: selectedCell.arrayIndex ?? 0,
index: selectedCell.arrayIndex,
},
});
} catch (error) {
@@ -121,7 +121,7 @@ export function useMenuAction(
fieldName: selectedCol.fieldName,
value: parsed,
arrayTableData: {
index: selectedCell.arrayIndex ?? 0,
index: selectedCell.arrayIndex,
},
});
} catch (error) {

View File

@@ -201,7 +201,7 @@ export function useFirestoreDocAsCollectionWithAtom<T = TableRow>(
useEffect(() => {
if (deleteDocAtom) {
setDeleteRowAtom(() => (_: string, options?: ArrayTableRowData) => {
if (!options) return;
if (!options || !options.index) return;
const updateFunction = deleteRow(options.index);
return setRows(updateFunction);
});
@@ -231,11 +231,15 @@ export function useFirestoreDocAsCollectionWithAtom<T = TableRow>(
if (options === undefined) return;
const deleteRowFields = () => {
if (options.index === undefined) return;
const updateFunction = deleteField(options.index, deleteFields);
return setRows(updateFunction);
};
const updateRowValues = () => {
if (options.index === undefined) return;
const updateFunction = updateTable(options.index, update);
return setRows(updateFunction);
};

View File

@@ -212,7 +212,7 @@ export type TableSort = {
};
export type ArrayTableRowData = {
index: number;
index?: number;
parentField?: string;
operation?: ArrayTableOperations;
};