removed unwanted changes

This commit is contained in:
Anish Roy
2023-10-30 23:08:37 +05:30
parent 5666ba8fa2
commit 201c69a386
4 changed files with 17 additions and 33 deletions

View File

@@ -146,11 +146,7 @@ export const addRowAtom = atom(
// Write to database if no required fields are missing
else {
await updateRowDb(
row._rowy_ref.path,
omitRowyFields(rowValues),
undefined
);
await updateRowDb(row._rowy_ref.path, omitRowyFields(rowValues));
}
if (auditChange) auditChange("ADD_ROW", row._rowy_ref.path);
@@ -341,8 +337,6 @@ export interface IUpdateFieldOptions {
useArrayRemove?: boolean;
/** Optionally, used to locate the row in ArraySubTable. */
arrayTableData?: ArrayTableRowData;
/** Optionally, explicitly specify to use firestore's update method. Required in case of JSON field update. */
// useUpdate?: boolean;
}
/**
* Set function updates or deletes a field in a row.

View File

@@ -88,6 +88,7 @@ export interface ISideDrawerFieldProps<T = any> {
/** Update the local value. Also calls onDirty */
onChange: (value: T) => void;
/** Call when user input is ready to be saved (e.g. onBlur) */
onSubmit: () => void;
/** Field locked. Do NOT check `column.locked` */
disabled: boolean;

View File

@@ -1,7 +1,7 @@
import { useState, useEffect } from "react";
import useMemoValue from "use-memo-value";
import { useAtom, PrimitiveAtom, useSetAtom, SetStateAction } from "jotai";
import { set, update } from "lodash-es";
import { set } from "lodash-es";
import {
Firestore,
query,
@@ -36,7 +36,6 @@ import {
TableFilter,
TableSort,
TableRow,
UpdateRowOptions,
} from "@src/types/table";
import { firebaseDbAtom } from "@src/sources/ProjectSourceFirebase";
import { COLLECTION_PAGE_SIZE } from "@src/config/db";
@@ -257,28 +256,22 @@ export function useFirestoreCollectionWithAtom<
// set the atoms value to a function that updates a doc in the collection
if (updateDocAtom) {
setUpdateDocAtom(
() =>
async (
path: string,
update: T,
deleteFields?: string[],
options?: UpdateRowOptions
) => {
const updateToDb = { ...update };
() => async (path: string, update: T, deleteFields?: string[]) => {
const updateToDb = { ...update };
if (Array.isArray(deleteFields)) {
for (const field of deleteFields) {
set(updateToDb as any, field, deleteField());
}
}
try {
return await updateDoc(doc(firebaseDb, path), updateToDb);
} catch (e) {
return await setDoc(doc(firebaseDb, path), updateToDb, {
merge: true,
});
if (Array.isArray(deleteFields)) {
for (const field of deleteFields) {
set(updateToDb as any, field, deleteField());
}
}
try {
return await updateDoc(doc(firebaseDb, path), updateToDb);
} catch (e) {
return await setDoc(doc(firebaseDb, path), updateToDb, {
merge: true,
});
}
}
);
}

View File

@@ -32,7 +32,7 @@ export type UpdateCollectionDocFunction<T = TableRow> = (
path: string,
update: Partial<T>,
deleteFields?: string[],
options?: ArrayTableRowData & UpdateRowOptions
options?: ArrayTableRowData
) => Promise<void>;
/**
@@ -211,10 +211,6 @@ export type TableSort = {
direction: Parameters<typeof orderBy>[1];
};
export type UpdateRowOptions = {
useUpdate?: boolean;
};
export type ArrayTableRowData = {
index?: number;
parentField?: string;