import { useAppointmentBookingContext } from "../../context.js";
import ContinueButton from "../Cart/ContinueButton/index.js";
import Cart from "../Cart/index.js";
import Total from "../Cart/Item/Total.js";
import React, { useEffect, useState } from "react";
import { Badge, Button, Image, SectionFooters } from "@pisell/materials";
import shoppingCartSvg from "../../assets/shopping-cart.svg";
import "./index.less";
//#region src/components/appointmentBooking/components/Footer/index.tsx
const Footer = ({ onNext, isOpen }) => {
	var _currentStep$step;
	const { carts, currentStep, isErrorHolder, setIsErrorHolder } = useAppointmentBookingContext();
	const [open, setOpen] = useState(false);
	useEffect(() => {
		setOpen(isErrorHolder || false);
	}, [currentStep === null || currentStep === void 0 || (_currentStep$step = currentStep.step) === null || _currentStep$step === void 0 ? void 0 : _currentStep$step.key, isErrorHolder]);
	return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SectionFooters, {
		className: "section-footer-wrap",
		left: /* @__PURE__ */ React.createElement(Total, {
			className: "section-footer-left",
			isFooter: true
		}),
		right: /* @__PURE__ */ React.createElement("div", { className: "section-footer-right" }, /* @__PURE__ */ React.createElement(Badge, { count: (carts === null || carts === void 0 ? void 0 : carts.length) || 0 }, /* @__PURE__ */ React.createElement(Button, {
			size: "large",
			onClick: () => setOpen(true),
			className: "section-footer-btn"
		}, /* @__PURE__ */ React.createElement(Image, {
			src: shoppingCartSvg,
			preview: false
		}))), /* @__PURE__ */ React.createElement(ContinueButton, { onNext }))
	}), /* @__PURE__ */ React.createElement(Cart, {
		open,
		onCancel: () => {
			setOpen(false);
			setIsErrorHolder(false);
		},
		onNext
	}));
};
//#endregion
export { Footer as default };
