chore(FE-41): use Nonstock API service

This commit is contained in:
ValdiANS
2025-10-08 15:01:45 +07:00
parent b8548b72c9
commit 780c0bb9d0
2 changed files with 8 additions and 8 deletions
@@ -5,8 +5,8 @@ import useSWR from 'swr';
import NonstockForm from '@/components/pages/master-data/nonstock/form/NonstockForm';
import { getNonstock } from '@/services/api/master-data/nonstock';
import { isResponseSuccess } from '@/lib/api-helper';
import { NonstockApi } from '@/services/api/master-data';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
const NonstockEdit = () => {
const router = useRouter();
@@ -16,7 +16,7 @@ const NonstockEdit = () => {
const { data: nonstock, isLoading: isLoadingNonstock } = useSWR(
nonstockId,
getNonstock
(id: number) => NonstockApi.getSingle(id)
);
if (!nonstockId) {
@@ -29,7 +29,7 @@ const NonstockEdit = () => {
);
}
if (!isLoadingNonstock && !nonstock) {
if (!isLoadingNonstock && (!nonstock || isResponseError(nonstock))) {
router.replace('/404');
return;
}
+4 -4
View File
@@ -5,8 +5,8 @@ import useSWR from 'swr';
import NonstockForm from '@/components/pages/master-data/nonstock/form/NonstockForm';
import { getNonstock } from '@/services/api/master-data/nonstock';
import { isResponseSuccess } from '@/lib/api-helper';
import { NonstockApi } from '@/services/api/master-data';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
const NonstockDetail = () => {
const router = useRouter();
@@ -16,7 +16,7 @@ const NonstockDetail = () => {
const { data: nonstock, isLoading: isLoadingNonstock } = useSWR(
nonstockId,
getNonstock
(id: number) => NonstockApi.getSingle(id)
);
if (!nonstockId) {
@@ -29,7 +29,7 @@ const NonstockDetail = () => {
);
}
if (!isLoadingNonstock && !nonstock) {
if (!isLoadingNonstock && (!nonstock || isResponseError(nonstock))) {
router.replace('/404');
return;
}