var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useState } from 'react';
import CheckBox from 'src/components/CheckBox2/CheckBox';
import Button from 'src/components/Button';
import { useAppDispatch } from 'src/app/redux/store';
import { setAlertModal } from 'src/app/redux/slices/common';
import css from '../FilterBar.module.scss';
import { _cx } from 'src/utility/class';
var cx = _cx(css);
var Specialty = function (_a) {
    var filters = _a.filters, t = _a.t, onFilterApply = _a.onFilterApply, _b = _a.showPediatric, showPediatric = _b === void 0 ? false : _b, closeModal = _a.closeModal;
    var isOrthoDoc = filters.isOrthoDoc, isGeneralDoc = filters.isGeneralDoc, isPediatric = filters.isPediatric;
    var _c = __read(useState(isOrthoDoc || false), 2), orthoDoc = _c[0], setOrthoDoc = _c[1];
    var _d = __read(useState(isGeneralDoc || false), 2), generalDoc = _d[0], setGeneralDoc = _d[1];
    var _e = __read(useState(isPediatric || false), 2), pediatric = _e[0], setPediatric = _e[1];
    var dispatch = useAppDispatch();
    var applyFilter = function () {
        if (!orthoDoc && !generalDoc && !pediatric) {
            dispatch(setAlertModal({
                show: true,
                title: t.alertHeading,
                description: t.select_at_least_one,
                imgUrl: '',
            }));
            return;
        }
        onFilterApply('isOrthoDoc', orthoDoc, [
            { key: 'isGeneralDoc', value: generalDoc },
            { key: 'isPediatric', value: pediatric },
        ]);
        closeModal();
    };
    return (_jsxs("div", { className: cx('form-group filter-specialty'), children: [_jsx("label", { className: "filter-title", children: t.result_doctor_types_label }), _jsxs("div", { className: cx('checkbox-wrap'), children: [_jsx(CheckBox, { checked: orthoDoc, onChange: function () {
                            setOrthoDoc(!orthoDoc);
                        }, label: t.orthodontists, name: "isOrthoDoc", width: "50%" }), _jsx(CheckBox, { checked: generalDoc, onChange: function () {
                            setGeneralDoc(!generalDoc);
                        }, label: t.general_dentists, name: "isGeneralDoc", width: "50%" }), showPediatric && (_jsx(CheckBox, { checked: pediatric, onChange: function () {
                            setPediatric(!pediatric);
                        }, label: t.pediatric_dentist, name: "isPediatric", width: "50%" }))] }), _jsx("hr", {}), _jsxs("div", { className: "flex-space-between", children: [_jsx(Button, { type: "submit", styleType: "cancel", onClick: closeModal, children: t.result_sort_button_cancel }), _jsx(Button, { type: "submit", styleType: "normal", onClick: applyFilter, children: t.result_filter_button_apply })] })] }));
};
export default Specialty;
