Skip to content

Instantly share code, notes, and snippets.

@qkreltms
Last active April 18, 2021 12:22
Show Gist options
  • Select an option

  • Save qkreltms/a9b0ea9576b71772cb766f03e6167487 to your computer and use it in GitHub Desktop.

Select an option

Save qkreltms/a9b0ea9576b71772cb766f03e6167487 to your computer and use it in GitHub Desktop.
export interface WithWarnConfig
  extends Factory,
    Pick<ConfirmProps, "title" | "message"> {}

export const withWarn = (config?: WithWarnConfig): ConfirmProps => {
  return {
    ...config,
    contents: (onClickClose, onClickOk, contentMessage) => (
      <>
        <ModalBody>{contentMessage}</ModalBody>
        <ModalFooter style={{ justifyContent: "flex-end" }}>
          <Button
            style={{ width: "100px" }}
            autoFocus
            onClick={onClickOk}
            onKeyDown={(e: any) =>
              e.key === "enter" && onClickOk && onClickOk(e)
            }
            color="primary"
          >
            Confirm
          </Button>
        </ModalFooter>
      </>
    )
  };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment