Sha256: 7fac7c995372aa240753c5cb117f25847e1d531ec412ad9a12f8123ded7db347

Contents?: true

Size: 697 Bytes

Versions: 2

Compression:

Stored size: 697 Bytes

Contents

import { useState } from "react";

import * as Images from "../../types/Images";

import { useDragCollection } from "../drag";

export default function useImageGrid(
  records: Images.Record[],
  enablePrimary = false
): Images.GridState {
  const primaryRecords = enablePrimary
    ? records.filter((r) => r.primary).slice(0, 1)
    : [];
  const imageRecords = records.filter((r) => primaryRecords.indexOf(r) === -1);

  const primary = useDragCollection(primaryRecords);
  const images = useDragCollection(imageRecords);
  const [deleted, setDeleted] = useState<Images.Record[]>([]);

  return {
    primary: primary,
    images: images,
    deleted: deleted,
    setDeleted: setDeleted
  };
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pages_core-3.15.2 app/javascript/components/ImageGrid/useImageGrid.ts
pages_core-3.15.1 app/javascript/components/ImageGrid/useImageGrid.ts