import React, { useCallback } from "react";

import Button from "@mui/material/Button";

import { useI18n } from "../../contexts/I18nContext";

export interface CardSaveButtonProps {
  label?: string;
  onClick?: () => void;
}

export const CardSaveButton: React.FC<CardSaveButtonProps> = ({ label = "Save", onClick }) => {
  const { t } = useI18n();

  const handleOnClick = useCallback(() => {
    onClick?.();
  }, [onClick]);

  return (
    <Button size="medium" type="submit" variant="contained" onClick={handleOnClick}>
      {t(label)}
    </Button>
  );
};

export default CardSaveButton;
