mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
refactor(FE): Validate transferToLayingId before fetching data
This commit is contained in:
+18
-8
@@ -50,12 +50,18 @@ const TransferToLayingConfirmationModalTable = ({
|
|||||||
transferToLayingForm?: TransferToLayingFormValues;
|
transferToLayingForm?: TransferToLayingFormValues;
|
||||||
transferToLayingId?: number;
|
transferToLayingId?: number;
|
||||||
}) => {
|
}) => {
|
||||||
|
const isValidId =
|
||||||
|
transferToLayingId !== undefined &&
|
||||||
|
transferToLayingId !== null &&
|
||||||
|
!isNaN(transferToLayingId) &&
|
||||||
|
transferToLayingId > 0;
|
||||||
|
|
||||||
const { data: transferToLaying, isLoading: isLoadingTransferToLaying } =
|
const { data: transferToLaying, isLoading: isLoadingTransferToLaying } =
|
||||||
useSWR(
|
useSWR(
|
||||||
transferToLayingId
|
isValidId
|
||||||
? ['detail-transfer-to-laying', String(transferToLayingId)]
|
? ['detail-transfer-to-laying', String(transferToLayingId)]
|
||||||
: undefined,
|
: undefined,
|
||||||
([id]) => TransferToLayingApi.getSingle(Number(id))
|
([, id]) => TransferToLayingApi.getSingle(Number(id))
|
||||||
);
|
);
|
||||||
|
|
||||||
const confirmationTableColumns: ColumnDef<TransferToLayingConfirmationTableDataType>[] =
|
const confirmationTableColumns: ColumnDef<TransferToLayingConfirmationTableDataType>[] =
|
||||||
@@ -273,12 +279,16 @@ const TransferToLayingConfirmationModal = ({
|
|||||||
|
|
||||||
{transferToLayingIds &&
|
{transferToLayingIds &&
|
||||||
!transferToLayingForm &&
|
!transferToLayingForm &&
|
||||||
transferToLayingIds.map((transferToLayingId, idx) => (
|
transferToLayingIds
|
||||||
<TransferToLayingConfirmationModalTable
|
.filter(
|
||||||
key={idx}
|
(id) => id !== undefined && id !== null && !isNaN(id) && id > 0
|
||||||
transferToLayingId={transferToLayingId}
|
)
|
||||||
/>
|
.map((transferToLayingId, idx) => (
|
||||||
))}
|
<TransferToLayingConfirmationModalTable
|
||||||
|
key={idx}
|
||||||
|
transferToLayingId={transferToLayingId}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
|
||||||
{withNote && (
|
{withNote && (
|
||||||
<TextArea
|
<TextArea
|
||||||
|
|||||||
Reference in New Issue
Block a user