editRegularVessel.tsx
Thu Jun 13 2024 11:43:51 GMT+0000 (Coordinated Universal Time)
Saved by @rafal_rydz
import { NextPage } from "next";
import {
BackHomeButton,
CommandPalletteButton,
MinimalPage,
PageHeading,
} from "ui";
import { VesselInfoForm } from "@/components/forms/vesselInfoForm";
import { BugReportButton, CommandInterface, Navigation } from "@/components";
import { useRouter } from "next/router";
import { useGetVesselFromIMO } from "@/hooks";
const EditRegularVessel: NextPage = () => {
const router = useRouter();
const { imo } = router.query;
const {
data: vesselData,
isError,
isLoading,
} = useGetVesselFromIMO(imo as string);
if (isLoading) {
return (
<MinimalPage
pageTitle={"Edit Vessel | Vessel Interface"}
pageDescription={"Vessel Interface | Edit Vessel Info"}
commandPrompt
>
<div className="flex w-full flex-row justify-between pl-1 pt-1">
<BackHomeButton />
<Navigation />
<div className="flex flex-row gap-4">
<BugReportButton />
<CommandPalletteButton />
<CommandInterface />
</div>
</div>
<PageHeading text="Edit Vessel Info" />
<p>Loading...</p>
</MinimalPage>
);
}
if (isError || !vesselData || vesselData.length === 0) {
return (
<MinimalPage
pageTitle={"Edit Vessel | Vessel Interface"}
pageDescription={"Vessel Interface | Edit Vessel Info"}
commandPrompt
>
<div className="flex w-full flex-row justify-between pl-1 pt-1">
<BackHomeButton />
<Navigation />
<div className="flex flex-row gap-4">
<BugReportButton />
<CommandPalletteButton />
<CommandInterface />
</div>
</div>
<PageHeading text="Edit Vessel Info" />
<p>Vessel not found.</p>
</MinimalPage>
);
}
return (
<MinimalPage
pageTitle={"Edit Vessel | Vessel Interface"}
pageDescription={"Vessel Interface | Edit Vessel Info"}
commandPrompt
>
<div className="flex w-full flex-row justify-between pl-1 pt-1">
<BackHomeButton />
<Navigation />
<div className="flex flex-row gap-4">
<BugReportButton />
<CommandPalletteButton />
<CommandInterface />
</div>
</div>
<PageHeading text="Edit Vessel Info" />
<VesselInfoForm mode="edit" initialValues={vesselData[0]} />
</MinimalPage>
);
};
export default EditRegularVessel;



Comments