import { Button, Space } from "antd";
import { useTranslation } from "react-i18next";

/*
################################################################################################
 Developer Note:
 Known Technical Debt Item
         Modifications to this code requires complementary changes to the Imgproxy code. This code will be removed once
          the imgproxy migration is completed.
################################################################################################
*/

export default function JobsDocumentsGallerySelectAllComponent({ galleryImages, setGalleryImages }) {
  const { t } = useTranslation();

  const handleSelectAll = () => {
    setGalleryImages({
      ...galleryImages,
      other: galleryImages.other.map((i) => {
        return { ...i, isSelected: true };
      }),
      images: galleryImages.images.map((i) => {
        return { ...i, isSelected: true };
      })
    });
  };
  const handleSelectAllImages = () => {
    setGalleryImages({
      ...galleryImages,

      images: galleryImages.images.map((i) => {
        return { ...i, isSelected: true };
      })
    });
  };
  const handleSelectAllDocuments = () => {
    setGalleryImages({
      ...galleryImages,
      other: galleryImages.other.map((i) => {
        return { ...i, isSelected: true };
      })
    });
  };
  const handleDeselectAll = () => {
    setGalleryImages({
      ...galleryImages,
      other: galleryImages.other.map((i) => {
        return { ...i, isSelected: false };
      }),
      images: galleryImages.images.map((i) => {
        return { ...i, isSelected: false };
      })
    });
  };

  return (
    <Space wrap>
      <Button onClick={handleSelectAll}>{t("general.actions.selectall")}</Button>
      <Button onClick={handleSelectAllImages}>{t("documents.actions.selectallimages")}</Button>
      <Button onClick={handleSelectAllDocuments}>{t("documents.actions.selectallotherdocuments")}</Button>
      <Button onClick={handleDeselectAll}>{t("general.actions.deselectall")}</Button>
    </Space>
  );
}
