import React from "react";

import ActionButton, { ActionButtonProps } from "../../../components/ActionButton";
import { useI18n } from "../../../contexts/I18nContext";

export interface StartSubscriptionButtonProps extends Pick<ActionButtonProps, "refresh"> {
  subscriptionId: number;
}

const StartSubscriptionButton: React.FC<StartSubscriptionButtonProps> = ({
  subscriptionId,
  refresh,
}) => {
  const { t } = useI18n();

  return (
    <ActionButton
      errorMessage={t("Failed to start subscription.")}
      operation="subscription.subscription:start"
      refresh={refresh}
      request={{ params: { subscription_id: subscriptionId } }}
      successMessage={t("Subscription startd successfully.")}
    >
      {t("Start subscription")}
    </ActionButton>
  );
};

export default StartSubscriptionButton;
