mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
chore(FE-41): use Nonstock API service
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user