improve table loading
This commit is contained in:
parent
a05f541713
commit
54701726cd
@ -130,24 +130,12 @@ const ResourceViewPage = (
|
|||||||
const resourceQuery = api.auditoryResource.byId.useQuery({ id });
|
const resourceQuery = api.auditoryResource.byId.useQuery({ id });
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
const ConditionalView = () => {
|
||||||
if (!resourceQuery.data) {
|
if (!resourceQuery.data) {
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
|
||||||
<div className="min-h-screen">
|
|
||||||
<Header />
|
|
||||||
<AdminBarLayout
|
|
||||||
actions={
|
|
||||||
<AdminActionLink
|
|
||||||
symbol={<PencilSquareIcon className="w-4" />}
|
|
||||||
label="Edit Page"
|
|
||||||
href={`${router.asPath}/edit`}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<main className="mb-12">
|
|
||||||
<div className="mx-auto flex max-w-2xl flex-col flex-col-reverse divide-x py-4 sm:flex-row">
|
<div className="mx-auto flex max-w-2xl flex-col flex-col-reverse divide-x py-4 sm:flex-row">
|
||||||
<div className="my-5 mr-4 flex flex-col justify-end text-lg font-bold">
|
<div className="my-5 mr-4 flex flex-col justify-end text-lg font-bold">
|
||||||
<div className="mx-4">
|
<div className="mx-4">
|
||||||
@ -175,6 +163,24 @@ const ResourceViewPage = (
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="min-h-screen">
|
||||||
|
<Header />
|
||||||
|
<AdminBarLayout
|
||||||
|
actions={
|
||||||
|
<AdminActionLink
|
||||||
|
symbol={<PencilSquareIcon className="w-4" />}
|
||||||
|
label="Edit Page"
|
||||||
|
href={`${router.asPath}/edit`}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<main className="mb-12">
|
||||||
|
<ConditionalView />
|
||||||
</main>
|
</main>
|
||||||
</AdminBarLayout>
|
</AdminBarLayout>
|
||||||
<Footer />
|
<Footer />
|
||||||
|
@ -23,17 +23,30 @@ const Resources = () => {
|
|||||||
skills: queryData.skills,
|
skills: queryData.skills,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!resourceQuery.data) {
|
|
||||||
return <></>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const totalPages = Math.ceil(resourceQuery.data.count / queryData.perPage);
|
|
||||||
const printQueryStr =
|
const printQueryStr =
|
||||||
router.asPath.split("?").length === 2
|
router.asPath.split("?").length === 2
|
||||||
? router.asPath.split("?").at(-1) ?? ""
|
? router.asPath.split("?").at(-1) ?? ""
|
||||||
: "";
|
: "";
|
||||||
const printLink = `${router.route}/print?${printQueryStr}`;
|
const printLink = `${router.route}/print?${printQueryStr}`;
|
||||||
|
|
||||||
|
const ConditionalTable = () => {
|
||||||
|
if (!resourceQuery.data) {
|
||||||
|
return <></>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const totalPages = Math.ceil(resourceQuery.data.count / queryData.perPage);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ResourceTable
|
||||||
|
resourcesPerPage={queryData.perPage}
|
||||||
|
resources={resourceQuery.data.resources}
|
||||||
|
totalPages={totalPages}
|
||||||
|
query={router.query}
|
||||||
|
currentPage={currentPage}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header />
|
<Header />
|
||||||
@ -67,13 +80,7 @@ const Resources = () => {
|
|||||||
</Link>
|
</Link>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
<ResourceTable
|
<ConditionalTable />
|
||||||
resourcesPerPage={queryData.perPage}
|
|
||||||
resources={resourceQuery.data.resources}
|
|
||||||
totalPages={totalPages}
|
|
||||||
query={router.query}
|
|
||||||
currentPage={currentPage}
|
|
||||||
/>
|
|
||||||
</main>
|
</main>
|
||||||
<Footer />
|
<Footer />
|
||||||
</>
|
</>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user