Skip to content

Saleor Core: the high performance, composable, headless commerce API.

wip

dominik-zeglen49fc91fec0d9
diff --git a/saleor/static/dashboard-next/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx b/saleor/static/dashboard-next/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx
new file mode 100644
index 0000000000..252e8c24b9
--- /dev/null
+++ b/saleor/static/dashboard-next/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx
@@ -0,0 +1,85 @@
+import Button from "@material-ui/core/Button";
+import Dialog from "@material-ui/core/Dialog";
+import DialogActions from "@material-ui/core/DialogActions";
+import DialogContent from "@material-ui/core/DialogContent";
+import DialogTitle from "@material-ui/core/DialogTitle";
+import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles";
+import * as React from "react";
+
+import AddressEdit from "../../../components/AddressEdit";
+import ConfirmButton, {
+ ConfirmButtonTransitionState
+} from "../../../components/ConfirmButton";
+import Form from "../../../components/Form";
+import i18n from "../../../i18n";
+import { UserError } from "../../../types";
+import { AddressTypeInput } from "../../types";
+import { CustomerAddresses_user } from "../../types/CustomerAddresses";
+
+export interface CustomerAddressDialogProps {
+ address: AddressTypeInput;
+ confirmButtonState: ConfirmButtonTransitionState;
+ countries: Array<{
+ code: string;
+ label: string;
+ }>;
+ errors: UserError[];
+ open: boolean;
+ user: CustomerAddresses_user;
+ onClose: () => void;
+ onConfirm: (data: AddressTypeInput) => void;
+}
+
+const styles = createStyles({
+ overflow: {
+ overflowY: "visible"
+ }
+});
+
+const CustomerAddressDialog = withStyles(styles, {})(
+ ({
+ address,
+ classes,
+ confirmButtonState,
+ countries,
+ errors,
+ open,
+ user,
+ onClose,
+ onConfirm
+ }: CustomerAddressDialogProps & WithStyles<typeof styles>) => (
+ <Dialog open={open} classes={{ paper: classes.overflow }}>
+ <Form initial={address} errors={errors} onSubmit={onConfirm}>
+ {({ change, data, errors, submit }) => (
+ <>
+ <DialogTitle>{}</DialogTitle>
+ <DialogContent className={classes.overflow}>
+ <AddressEdit
+ countries={countries}
+ data={data}
+ errors={errors}
+ onChange={change}
+ />
+ </DialogContent>
+ <DialogActions>
+ <Button onClick={onClose}>
+ {i18n.t("Cancel", { context: "button" })}
+ </Button>
+ <ConfirmButton
+ transitionState={confirmButtonState}
+ color="primary"
+ variant="contained"
+ onClick={submit}
+ type="submit"
+ >
+ {i18n.t("Confirm", { context: "button" })}
+ </ConfirmButton>
+ </DialogActions>
+ </>
+ )}
+ </Form>
+ </Dialog>
+ )
+);
+CustomerAddressDialog.displayName = "CustomerAddressDialog";
+export default CustomerAddressDialog;
diff --git a/saleor/static/dashboard-next/customers/components/CustomerAddressDialog/index.ts b/saleor/static/dashboard-next/customers/components/CustomerAddressDialog/index.ts
new file mode 100644
index 0000000000..a5f6e99731
--- /dev/null
+++ b/saleor/static/dashboard-next/customers/components/CustomerAddressDialog/index.ts
@@ -0,0 +1,2 @@
+export { default } from './CustomerAddressDialog';
+export * from './CustomerAddressDialog';
\ No newline at end of file
diff --git a/saleor/static/dashboard-next/storybook/stories/customers/CustomerAddressDialog.tsx b/saleor/static/dashboard-next/storybook/stories/customers/CustomerAddressDialog.tsx
index 613cd2946c..c4a9c7f838 100644
--- a/saleor/static/dashboard-next/storybook/stories/customers/CustomerAddressDialog.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/customers/CustomerAddressDialog.tsx
@@ -6,10 +6,8 @@ import CustomerAddressDialog, {
} from "../../../customers/components/CustomerAddressDialog";
import Decorator from "../../Decorator";
-const props: CustomerAddressDialogProps = {
+const props: CustomerAddressDialogProps = {};
-};
-
-storiesOf("Customers / CustomerAddressDialog", module)
+storiesOf("Customers / Address editing dialog", module)
.addDecorator(Decorator)
.add("default", () => <CustomerAddressDialog {...props} />);