import { OpenConfirmationModalProps } from "@komi-app/components";

type VoidFn = () => void | Promise<void>;
export interface ModalContext {
  onConfirm: VoidFn;
  onCancel?: VoidFn;
};

export const unsavedModalContext = (props: ModalContext): OpenConfirmationModalProps => ({
  title: "You Have Unsaved Changes",
  description: "You haven’t saved your latest changes, would you like to save them before you leave?",
  buttons: [
    {
      label: "Don't save",
      action: "cancel",
      variant: "secondary",
    },
    {
      label: "Save",
      action: "confirm",
      variant: "primary",
    },
  ],
  className: "segment-page__modal",
  ...props,
});
export const deleteModalContext = (props: ModalContext): OpenConfirmationModalProps => ({
  title: "Are you sure you want to delete this segment?",
  description: "This segment will be deleted and you can’t undo this action.",
  buttons: [
    {
      label: "No thanks",
      action: "cancel",
      variant: "primary",
    },
    {
      label: "Delete",
      action: "confirm",
      variant: "secondary",
    },
  ],
  className: "segment-page__modal",
  ...props,
});
export const noConsentModalContext = (props: ModalContext): OpenConfirmationModalProps => ({
  title: "Not All Contacts Have Consented to Receive Marketing Communications",
  description: "Marketing to contacts who have not granted their consent may be a breach of privacy laws and / or may violate our terms of service.  ",
  buttons: [
    {
      label: "Cancel",
      action: "cancel",
      variant: "secondary",
    },
    {
      label: "Save",
      action: "confirm",
      variant: "primary",
    },
  ],
  className: "segment-page__modal",
  ...props,
});
export const exportModalContext = (props: ModalContext): OpenConfirmationModalProps => ({
  title: "You’re About to Export Audience Contact Data",
  description: "By continuing with this export you agree to only use this data in line with our terms of service, your privacy policy and the relevant laws of your jurisdiction.",
  buttons: [
    {
      label: "Cancel",
      action: "cancel",
      variant: "secondary",
    },
    {
      label: "Export",
      action: "confirm",
      variant: "primary",
    },
  ],
  className: "segment-page__modal",
  ...props,
});
