{"size": 2871, "ext": "js", "max_stars_repo_path": "src/client/src/components/localFontsData.js", "max_stars_repo_name": "mlfcnt/fonts-sync-executable", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/client/src/components/localFontsData.js", "max_issues_repo_name": "mlfcnt/fonts-sync-executable", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/client/src/components/localFontsData.js", "max_forks_repo_name": "mlfcnt/fonts-sync-executable", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.6339285714, "max_line_length": 69, "alphanum_fraction": 0.5416231278}
import React, { useState } from "react";
import moment from "moment";
import { booleanFormatter } from "./helpers/booleanFormatter";
import { LocalFontsToolbar } from "./LocalFontsToolbar";
moment.locale("fr");

export const generateData = (fonts) => {
  return fonts
    .sort((a, b) => a.postscriptName.localeCompare(b.postscriptName))
    .map(
      ({
        path,
        postscriptName: name,
        family,
        style,
        weight,
        width,
        italic,
        monospace,
        birthtime,
        extension,
      }) => [
        name,
        extension,
        family,
        style,
        weight,
        width,
        monospace,
        italic,
        // path,
        moment(birthtime).format("DD/MM/YYYY - HH:mm"),
      ]
    );
};

export const columns = [
  { name: "Nom", options: { filter: false, sort: true } },
  { name: "Extension", options: { filter: true, sort: true } },
  { name: "Famille", options: { filter: true, sort: true } },
  { name: "Style", options: { filter: true, sort: true } },
  { name: "Weight", options: { filter: true, sort: true } },
  { name: "Width", options: { filter: true, sort: true } },
  {
    name: "Monospace",
    options: {
      filter: true,
      sort: true,
      customBodyRender: (value) => booleanFormatter(value),
    },
  },
  {
    name: "Italic",
    options: {
      filter: true,
      sort: true,
      customBodyRender: (value) => booleanFormatter(value),
    },
  },
  // { name: "Chemin", options: { filter: false, sort: true } },
  { name: "Ajoutée le", options: { filter: false, sort: true } },
];

export const generateOptions = (setFontsToUpload) => {
  return {
    filterType: "checkbox",
    filter: true,
    print: false,
    download: false,
    textLabels: {
      body: {
        noMatch: "Pas de polices trouvées :(",
        toolTip: "Trier",
        columnHeaderTooltip: (column) => {
          if (column.name === "Extension")
            return `Grouper par ${column.label.toLowerCase()}`;
          return `Trier par ${column.label.toLowerCase()}`;
        },
      },
      pagination: {
        next: "Page suivante",
        previous: "Page précédente",
        rowsPerPage: "Polices par page:",
        displayRows: "de",
      },
      toolbar: {
        search: "Recherche",
        viewColumns: "Voir les colonnes",
        filterTable: "Filter le tableau",
      },
      filter: {
        all: "Toutes",
        title: "FILTRES",
        reset: "RESET",
      },
      viewColumns: {
        title: "Voir les colonnes",
        titleAria: "Afficher/Cacher les colonnes du tableau",
      },
      selectedRows: {
        text: "police(s) séléctionnée(s)",
      },
    },
    customToolbarSelect: (selectedRows) => (
      <LocalFontsToolbar
        selectedRows={selectedRows}
        setFontsToUpload={setFontsToUpload}
      />
    ),
  };
};
