2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-16 20:15:44 +00:00

Importer permissions (#8419)

* Improved permission checking for data importing

- Permission checks on the imported model type

* Improved validation for DateField

* Fix for unit test
This commit is contained in:
Oliver
2024-11-03 17:43:09 +11:00
committed by GitHub
parent 504655c92d
commit abad36786f
6 changed files with 69 additions and 15 deletions

View File

@ -39,11 +39,18 @@ export default function DateField({
[field.onChange, definition]
);
const dateValue = useMemo(() => {
const dateValue: Date | null = useMemo(() => {
let dv: Date | null = null;
if (field.value) {
return new Date(field.value);
dv = new Date(field.value) ?? null;
}
// Ensure that the date is valid
if (dv instanceof Date && !isNaN(dv.getTime())) {
return dv;
} else {
return undefined;
return null;
}
}, [field.value]);