
* Simplify "changed" logic * Improve code composition * Test base state and setters * Add more tests * Fix changed logic * Rename hasChanged output * Move channel data outside hook * Move some logic to utils * Save data in dialog and pass to view * Split hooks * Fix react warnings * Fix story * Alias type * Fix stories * Remove rebase artifact * Reset state after closing modal * Capitalize type name
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { Dialog, DialogContent, DialogTitle } from "@material-ui/core";
|
|
import { DialogProps } from "@saleor/types";
|
|
import React from "react";
|
|
|
|
import { ConfirmButtonTransitionState } from "../ConfirmButton";
|
|
import DialogButtons from "./DialogButtons";
|
|
import { ActionDialogVariant, Size } from "./types";
|
|
|
|
export interface ActionDialogProps extends DialogProps {
|
|
children?: React.ReactNode;
|
|
confirmButtonLabel?: string;
|
|
confirmButtonState: ConfirmButtonTransitionState;
|
|
disabled?: boolean;
|
|
maxWidth?: Size | false;
|
|
title: string;
|
|
variant?: ActionDialogVariant;
|
|
onConfirm();
|
|
}
|
|
|
|
const ActionDialog: React.FC<ActionDialogProps> = props => {
|
|
const { children, open, title, onClose, variant, maxWidth, ...rest } = props;
|
|
|
|
return (
|
|
<Dialog fullWidth onClose={onClose} open={open} maxWidth={maxWidth}>
|
|
<DialogTitle>{title}</DialogTitle>
|
|
<DialogContent>{children}</DialogContent>
|
|
<DialogButtons {...rest} onClose={onClose} variant={variant} />
|
|
</Dialog>
|
|
);
|
|
};
|
|
|
|
ActionDialog.defaultProps = {
|
|
maxWidth: "xs"
|
|
};
|
|
|
|
ActionDialog.displayName = "ActionDialog";
|
|
export default ActionDialog;
|