import Add from "@mui/icons-material/Add";
import { Button } from "@mui/material";
import { getLocalizedString } from "@olenbetong/appframe-core";

export type DamageFormButtonsProps = {
	isEdit: boolean;
	loading: boolean;
	uploadingFile: boolean;
	handleDelete: () => void;
	handleCancel: () => void;
};

export function DamageFormButtons({
	isEdit,
	loading,
	uploadingFile,
	handleDelete,
	handleCancel,
}: DamageFormButtonsProps) {
	return (
		<>
			{isEdit && <Button onClick={handleDelete}>{getLocalizedString("Delete")}</Button>}
			<Button onClick={handleCancel}>{getLocalizedString("Cancel")}</Button>
			<Button
				loading={loading || uploadingFile}
				loadingPosition="start"
				startIcon={<Add />}
				type="submit"
				variant="contained"
			>
				{isEdit ? getLocalizedString("Save changes") : getLocalizedString("Register damage")}
			</Button>
		</>
	);
}
