-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added logic to unregister fields when schema changes
- Loading branch information
1 parent
be058aa
commit 669816a
Showing
3 changed files
with
56 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { SchemaType } from "./interfaces/schema"; | ||
|
||
export const symmetricDiff = (arr1: string[], arr2: string[]) => | ||
arr1 | ||
.filter((x) => !arr2.includes(x)) | ||
.concat(arr2.filter((x) => !arr1.includes(x))); | ||
|
||
export const getFormValuesFromSchema = (schema: SchemaType) => { | ||
let temp: Record<string, string> = {}; | ||
|
||
schema.fields.forEach((field) => { | ||
if (field.type === "field") { | ||
temp[field.accessorKey] = ""; | ||
} else { | ||
temp = { ...temp, ...getFormValuesFromSchema(field) }; | ||
} | ||
}); | ||
|
||
return temp; | ||
}; |