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