2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 03:26:45 +00:00

Small SAST fixes (#8534)

* fix various middle-high SAST errors

* fix another small issue

* add default
This commit is contained in:
Matthias Mair 2024-11-25 23:15:44 +01:00 committed by GitHub
parent 0f194af585
commit 5cda270e4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 11 additions and 12 deletions

View File

@ -219,7 +219,7 @@ export function ApiForm({
// If the user has specified initial data, that overrides default values
// But, *only* for the fields we have specified
if (props.initialData) {
Object.keys(props.initialData).map((key) => {
Object.keys(props.initialData).forEach((key) => {
if (key in defaultValuesMap) {
defaultValuesMap[key] =
props?.initialData?.[key] ?? defaultValuesMap[key];

View File

@ -43,7 +43,7 @@ export default function DateField({
let dv: Date | null = null;
if (field.value) {
dv = new Date(field.value) ?? null;
dv = new Date(field.value);
}
// Ensure that the date is valid

View File

@ -70,7 +70,6 @@ export default function ImporterDrawer({
// Map from import steps to stepper steps
const currentStep = useMemo(() => {
switch (session.status) {
default:
case importSessionStatus.INITIAL:
return 0;
case importSessionStatus.MAPPING:
@ -81,6 +80,8 @@ export default function ImporterDrawer({
return 3;
case importSessionStatus.COMPLETE:
return 4;
default:
return 0;
}
}, [session.status]);

View File

@ -84,7 +84,7 @@ export const getPluginTemplateEditor = (
useEffect(() => {
(async () => {
try {
await func({
func({
ref: elRef.current!,
registerHandlers: ({ getCode, setCode }) => {
setCodeRef.current = setCode;
@ -136,7 +136,7 @@ export const getPluginTemplatePreview = (
useEffect(() => {
(async () => {
try {
await func({
func({
ref: elRef.current!,
registerHandlers: ({ updatePreview }) => {
updatePreviewRef.current = updatePreview;

View File

@ -159,7 +159,7 @@ export function useStockFields({
hidden:
create ||
partInstance.trackable == false ||
(!stockItem?.quantity != undefined && stockItem?.quantity != 1)
(stockItem?.quantity != undefined && stockItem?.quantity != 1)
},
batch: {
placeholder: nextBatchCode

View File

@ -283,12 +283,10 @@ export default function ParametricPartTable({
if (column?.accessor?.toString()?.startsWith('parameter_')) {
const col = column as any;
onParameterClick(col.extra.template, record);
} else {
} else if (record?.pk) {
// Navigate through to the part detail page
if (record?.pk) {
const url = getDetailUrl(ModelType.part, record.pk);
navigateToLink(url, navigate, event);
}
const url = getDetailUrl(ModelType.part, record.pk);
navigateToLink(url, navigate, event);
}
}
}}

View File

@ -236,7 +236,7 @@ export function TemplateTable({
sortable: false,
switchable: true
},
...Object.entries(additionalFormFields || {})?.map(([key, field]) => ({
...Object.entries(additionalFormFields || {}).map(([key, field]) => ({
accessor: key,
...field,
title: field.label,