2021-08-16 13:44:00 +00:00
|
|
|
import CardSpacer from "@saleor/components/CardSpacer";
|
|
|
|
import Container from "@saleor/components/Container";
|
|
|
|
import Grid from "@saleor/components/Grid";
|
|
|
|
import Metadata from "@saleor/components/Metadata";
|
|
|
|
import Savebar from "@saleor/components/Savebar";
|
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
import GiftCardUpdateDetailsCard from "./GiftCardUpdateDetailsCard";
|
|
|
|
import GiftCardUpdateInfoCard from "./GiftCardUpdateInfoCard";
|
|
|
|
import GiftCardUpdatePageHeader from "./GiftCardUpdatePageHeader";
|
|
|
|
import useGiftCardUpdateDialogs from "./providers/GiftCardUpdateDialogsProvider/hooks/useGiftCardUpdateDialogs";
|
|
|
|
import useGiftCardUpdate from "./providers/GiftCardUpdateFormProvider/hooks/useGiftCardUpdate";
|
|
|
|
import useGiftCardUpdateForm from "./providers/GiftCardUpdateFormProvider/hooks/useGiftCardUpdateForm";
|
|
|
|
|
|
|
|
const GiftCardUpdatePage: React.FC = () => {
|
2021-09-14 13:57:02 +00:00
|
|
|
const { navigateBack, openDeleteDialog } = useGiftCardUpdateDialogs();
|
2021-08-16 13:44:00 +00:00
|
|
|
|
|
|
|
const {
|
|
|
|
hasChanged,
|
|
|
|
submit,
|
|
|
|
data,
|
|
|
|
handlers: { changeMetadata }
|
|
|
|
} = useGiftCardUpdateForm();
|
|
|
|
|
|
|
|
const {
|
|
|
|
opts: { loading: loadingUpdate, status }
|
|
|
|
} = useGiftCardUpdate();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Container>
|
|
|
|
<GiftCardUpdatePageHeader />
|
|
|
|
<Grid>
|
|
|
|
<div>
|
|
|
|
<GiftCardUpdateDetailsCard />
|
|
|
|
<CardSpacer />
|
|
|
|
<Metadata data={data} onChange={changeMetadata} />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<GiftCardUpdateInfoCard />
|
|
|
|
</div>
|
|
|
|
</Grid>
|
|
|
|
<Savebar
|
|
|
|
state={status}
|
|
|
|
disabled={loadingUpdate || !hasChanged}
|
|
|
|
onCancel={navigateBack}
|
|
|
|
onSubmit={submit}
|
2021-09-14 13:57:02 +00:00
|
|
|
onDelete={openDeleteDialog}
|
2021-08-16 13:44:00 +00:00
|
|
|
/>
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default GiftCardUpdatePage;
|