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 NonstockForm from '@/components/pages/master-data/nonstock/form/NonstockForm';
|
||||||
|
|
||||||
import { getNonstock } from '@/services/api/master-data/nonstock';
|
import { NonstockApi } from '@/services/api/master-data';
|
||||||
import { isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
|
||||||
const NonstockEdit = () => {
|
const NonstockEdit = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -16,7 +16,7 @@ const NonstockEdit = () => {
|
|||||||
|
|
||||||
const { data: nonstock, isLoading: isLoadingNonstock } = useSWR(
|
const { data: nonstock, isLoading: isLoadingNonstock } = useSWR(
|
||||||
nonstockId,
|
nonstockId,
|
||||||
getNonstock
|
(id: number) => NonstockApi.getSingle(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!nonstockId) {
|
if (!nonstockId) {
|
||||||
@@ -29,7 +29,7 @@ const NonstockEdit = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoadingNonstock && !nonstock) {
|
if (!isLoadingNonstock && (!nonstock || isResponseError(nonstock))) {
|
||||||
router.replace('/404');
|
router.replace('/404');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import useSWR from 'swr';
|
|||||||
|
|
||||||
import NonstockForm from '@/components/pages/master-data/nonstock/form/NonstockForm';
|
import NonstockForm from '@/components/pages/master-data/nonstock/form/NonstockForm';
|
||||||
|
|
||||||
import { getNonstock } from '@/services/api/master-data/nonstock';
|
import { NonstockApi } from '@/services/api/master-data';
|
||||||
import { isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
|
||||||
const NonstockDetail = () => {
|
const NonstockDetail = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -16,7 +16,7 @@ const NonstockDetail = () => {
|
|||||||
|
|
||||||
const { data: nonstock, isLoading: isLoadingNonstock } = useSWR(
|
const { data: nonstock, isLoading: isLoadingNonstock } = useSWR(
|
||||||
nonstockId,
|
nonstockId,
|
||||||
getNonstock
|
(id: number) => NonstockApi.getSingle(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!nonstockId) {
|
if (!nonstockId) {
|
||||||
@@ -29,7 +29,7 @@ const NonstockDetail = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoadingNonstock && !nonstock) {
|
if (!isLoadingNonstock && (!nonstock || isResponseError(nonstock))) {
|
||||||
router.replace('/404');
|
router.replace('/404');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user