"use client";

import { MdCall } from "react-icons/md";

type props = {
    phone: string
}

export default function CallButton({ phone }: props) {

    const phoneNumber = phone?.startsWith("+88")
        ? phone
        : `+88${phone?.replace(/^0+/, "")}`; // remove leading zeros if any

    const handleCall = () => {
        window.location.href = `tel:${phone}`;
    };

    return (
        <div className="flex gap-2 cursor-pointer"
            onClick={handleCall}
        >
            <div className="mt-1">
                <MdCall />
            </div>
            <div>
                {phone}
            </div>
        </div>
    );
}
