"use client";

import React, { useContext, useEffect, useRef, useState } from "react";
import { BottomSheet } from "react-spring-bottom-sheet";
import Input from "plugins/Input/page";
import AppContext from "@ctx/AppContext";
import SimpleReactValidator from "simple-react-validator";
import CheckBoxBriz from "plugins/CheckBoxBriz/page";
import Buttonbriz from "plugins/Buttonbriz/page";
import { toast } from "react-toastify";
import moment from "jalali-moment";
import HasPermission from "plugins/HasPermission/page";

const BottomFilterActivities = (props) => {
  const CTX = useContext(AppContext);
  const [typeFilter, setTypeFilter] = useState(0);

  const handleFilterActivity = (num) => {
    setTypeFilter(num);
  };

  const handleChangeFilter = () => {
    CTX.GetActivity(null, null, 0, typeFilter);
    CTX.setBottomFilterActivitiesOpen(false);
  };

  return (
    <BottomSheet
      // onSpringStart={(e) => handleBottomSheetCreateRole(e)}
      open={CTX.state.BottomFilterActivitiesOpen}
      onDismiss={() => CTX.setBottomFilterActivitiesOpen(false)}
      blocking={false}
    >
      <div className="text-center py-2 bg-primary-300  ">
        <p className="mb-0 text-white relative top-[-5px]">فیلتر اکتیویتی</p>
      </div>

      <div className="bg-body-100 p-3 ">
        <div
          className={`rounded-xl border-[1px] border-gray-200 p-5 m-2 tr03 ${
            typeFilter == 0 ? " bg-primary-100" : "bg-gray-100 "
          }`}
          onClick={() => handleFilterActivity(0)}
        >
          <p className="mb-0 text-right">اکتیویتی های امروز</p>
        </div>

        <div
          className={`rounded-xl border-[1px] border-gray-200 p-5 m-2 tr03 ${
            typeFilter == 1 ? " bg-primary-100" : "bg-gray-100 "
          }`}
          onClick={() => handleFilterActivity(1)}
        >
          <p className="mb-0 text-right">اکتیویتی های فردا</p>
        </div>

        <div
          className={`rounded-xl border-[1px] border-gray-200 p-5 m-2 tr03 ${
            typeFilter == 2 ? " bg-primary-100" : "bg-gray-100 "
          }`}
          onClick={() => handleFilterActivity(2)}
        >
          <p className="mb-0 text-right">اکتیویتی های هفته</p>
        </div>

        <Buttonbriz
          title="اعمال فیلتر"
          color="PRIMARY"
          icon="CHECK"
          buttonEvent={() => handleChangeFilter()}
        />
      </div>
    </BottomSheet>
  );
};

export default BottomFilterActivities;
