From 5142580aff25d3d4e40a7472c533cb24dcc89f3a Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Wed, 11 Feb 2026 17:31:45 +0100 Subject: [PATCH] fix: :construction: fix eslint part.457 --- package.json | 1 + resources/sass/back/inputs/_color.scss | 101 ++++++++++++++++ .../BtnOptionnalLinkWithTooltip.tsx | 40 ++++--- .../Documents/AssociatedDocumentList.tsx | 8 +- .../Components/DynamicPages/DynamicInputs.tsx | 60 ++-------- .../Components/DynamicPages/DynamicList.tsx | 6 +- .../DynamicWrapperModelSelect.tsx | 74 ++++++++++++ .../ts/back/Components/Inputs/EnumSelect.tsx | 2 + .../Components/Inputs/SimpleColorPicker.tsx | 108 ++---------------- .../back/Components/Inputs/Slugifycator.tsx | 10 +- .../Components/Inputs/StaticRouteSelect.tsx | 4 +- .../Wysiwyg/Extensions/Image/ImageInputs.tsx | 1 + .../Extensions/Image/ImageNodeView.tsx | 20 ++-- .../Extensions/Replace/FindReplaceButton.tsx | 44 +++---- .../Wysiwyg/Extensions/Table/TableButton.tsx | 20 ++-- .../Inputs/Wysiwyg/SimpleWysiwyg.tsx | 2 + .../Components/News/AssociatedNewsList.tsx | 14 +-- .../Components/PageConfigs/ConfigDetails.tsx | 4 +- .../Components/PageConfigs/DynamicFields.tsx | 35 +++--- .../Components/PageConfigs/FieldGroup.tsx | 2 + .../PageConfigs/ImportConfigJson.tsx | 37 +++--- .../{ => Table}/RenderTranslationCell.tsx | 4 +- .../ts/back/Layouts/AuthenticatedLayout.tsx | 10 +- .../ts/back/Pages/ActivityLogs/Index.tsx | 4 +- .../ts/back/Pages/CompanyActivities/Index.tsx | 8 +- .../ts/back/Pages/CompanyActivities/Show.tsx | 8 +- .../ts/back/Pages/CompanySectors/Index.tsx | 8 +- .../ts/back/Pages/CompanySectors/Show.tsx | 8 +- resources/ts/back/Pages/Document/Index.tsx | 7 +- .../ts/back/Pages/DocumentCategory/Index.tsx | 8 +- .../ts/back/Pages/DocumentCategory/Show.tsx | 12 +- resources/ts/back/Pages/DocumentTag/Index.tsx | 8 +- resources/ts/back/Pages/DocumentTag/Show.tsx | 12 +- .../ts/back/Pages/DynamicPages/Index.tsx | 7 +- resources/ts/back/Pages/DynamicPages/Show.tsx | 9 +- resources/ts/back/Pages/News/Index.tsx | 8 +- resources/ts/back/Pages/News/Show.tsx | 12 +- .../ts/back/Pages/NewsCategory/Index.tsx | 8 +- resources/ts/back/Pages/NewsCategory/Show.tsx | 12 +- resources/ts/back/Pages/NewsTag/Index.tsx | 8 +- resources/ts/back/Pages/NewsTag/Show.tsx | 12 +- resources/ts/back/Pages/PageConfigs/Form.tsx | 12 +- resources/ts/back/Pages/PageConfigs/Index.tsx | 11 +- resources/ts/back/Pages/PageConfigs/Show.tsx | 10 +- 44 files changed, 426 insertions(+), 373 deletions(-) create mode 100644 resources/sass/back/inputs/_color.scss create mode 100644 resources/ts/back/Components/DynamicPages/DynamicWrapperModelSelect.tsx rename resources/ts/back/Components/{ => Table}/RenderTranslationCell.tsx (96%) diff --git a/package.json b/package.json index ef35bdae..82df468c 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "eslint-fix": "node ./node_modules/.bin/eslint --config './.eslintrc.cjs' --max-warnings 0 resources/ts --ext .ts,.tsx --fix", "eslint-ci": "node ./node_modules/.bin/eslint --config './.eslintrc.cjs' --max-warnings 0 resources/ts --ext .ts,.tsx -f junit", "stylelint": "node ./node_modules/.bin/stylelint --config './.stylelintrc.json' --max-warnings 0 '**/resources/**/*.scss'", + "stylelint-fix": "node ./node_modules/.bin/stylelint --config './.stylelintrc.json' --max-warnings 0 '**/resources/**/*.scss' --fix", "stylelint-ci": "node ./node_modules/.bin/stylelint --config './.stylelintrc.json' --max-warnings 0 '**/resources/**/*.scss' -f json" }, "devDependencies": { diff --git a/resources/sass/back/inputs/_color.scss b/resources/sass/back/inputs/_color.scss new file mode 100644 index 00000000..15f7746d --- /dev/null +++ b/resources/sass/back/inputs/_color.scss @@ -0,0 +1,101 @@ +.sketch-picker { + display: flex; + width: 100% !important; + flex-direction: column; + padding: 0 !important; + border: 0 !important; + box-shadow: none !important; +} + +.sketch-picker, +.sketch-picker .flexbox-fix { + gap: 0.375rem; +} + +.sketch-picker > div, +.sketch-picker .flexbox-fix > div { + padding: 0 !important; + margin: 0 !important; +} + +.sketch-picker > div:first-child { + border-radius: calc(var(--radius) - 2px); + aspect-ratio: 1 / 1; +} + +.sketch-picker > div:last-child { + justify-content: space-between; + padding-top: 0.375rem !important; +} + +.sketch-picker > div:nth-child(3) > div { + flex: auto !important; +} + +.sketch-picker > div:last-child > div { + width: 20px !important; + height: 20px !important; +} + +.sketch-picker > div:last-child > div > span > div { + border-radius: calc(var(--radius) - 2px) !important; + box-shadow: none !important; + outline: 1px solid hsl(var(--input)) !important; +} + +.sketch-picker > div:nth-child(2) > div:first-child { + display: flex; + flex-direction: column; + gap: 0.375rem; +} + +.sketch-picker > div:nth-child(2) > div:last-child { + display: none; +} + +.sketch-picker > div:nth-child(3) > div:first-child { + width: 16rem; +} + +.sketch-picker > div:nth-child(2) > div:first-child > div { + height: 20px !important; + border-radius: calc(var(--radius) - 2px); + margin: 0 !important; + cursor: pointer; + outline: 1px solid hsl(var(--input)); +} + +/* stylelint-disable-next-line selector-max-compound-selectors */ +.sketch-picker > div:first-child > div > div > div:last-child > div { + width: 10px !important; + height: 10px !important; + border-radius: 50% !important; + background-color: #fff; + box-shadow: none !important; + transform: translate(-5px, -5px) !important; +} + +/* stylelint-disable-next-line selector-max-compound-selectors */ +.sketch-picker > div:nth-child(2) > div:first-child > div > div > div > div > div { + width: 0.5rem !important; + height: 20px !important; + border: 1px hsl(var(--input)) solid; + border-radius: 0 !important; + margin-top: 0 !important; + background: #fff !important; + box-shadow: none !important; + transform: translateX(-4px) !important; +} + +.sketch-picker input { + width: 100% !important; + height: 2.5rem; + padding: 0.5rem 0.75rem !important; + border: 1px hsl(var(--input)) solid !important; + border-radius: calc(var(--radius) - 2px) !important; + background-color: hsl(var(--background)); + box-shadow: none !important; + color: var(--foreground); + outline: none; + text-align: center; +} diff --git a/resources/ts/back/Components/BtnOptionnalLinkWithTooltip.tsx b/resources/ts/back/Components/BtnOptionnalLinkWithTooltip.tsx index 6937ee7a..53133bd4 100644 --- a/resources/ts/back/Components/BtnOptionnalLinkWithTooltip.tsx +++ b/resources/ts/back/Components/BtnOptionnalLinkWithTooltip.tsx @@ -49,6 +49,27 @@ export default function BtnOptionnalLinkWithTooltip({ onClick, ...props }: BtnOptionnalLinkWithTooltipProps) { + let innerContent: ReactNode = content; + + if (link !== null) { + if (externalLink) { + innerContent = ( + + {content} + + ); + } else { + innerContent = {content}; + } + } + return ( @@ -63,24 +84,7 @@ export default function BtnOptionnalLinkWithTooltip({ style={style} {...props} > - {link !== null ? ( - externalLink ? ( - - {content} - - ) : ( - {content} - ) - ) : ( - content - )} + {innerContent} {tooltipContent} diff --git a/resources/ts/back/Components/Documents/AssociatedDocumentList.tsx b/resources/ts/back/Components/Documents/AssociatedDocumentList.tsx index 14fcdde9..da75d141 100644 --- a/resources/ts/back/Components/Documents/AssociatedDocumentList.tsx +++ b/resources/ts/back/Components/Documents/AssociatedDocumentList.tsx @@ -7,11 +7,11 @@ import str from "@/hooks/use-string"; import DataTable from "@/back/Components/Table/DataTable"; import useTrans from "@/hooks/use-translations"; import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { AppEnv, Resource } from "@/back/types/global"; import { TranslationField } from "@/back/types/i18n"; import { DocumentModel } from "@/back/types/others"; import { Views } from "@/lib/utils"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; interface Props { documents: Resource; @@ -32,9 +32,9 @@ function AssociatedDocumentList(props: Props) { field={column.id} /> ), - cell: ({ row }: { row: Row }) => { - return RenderTranslationCell(row.getValue("name")); - }, + cell: ({ row }: { row: Row }) => ( + + ), }, { accessorKey: "path", diff --git a/resources/ts/back/Components/DynamicPages/DynamicInputs.tsx b/resources/ts/back/Components/DynamicPages/DynamicInputs.tsx index 2996097c..00fa52a3 100644 --- a/resources/ts/back/Components/DynamicPages/DynamicInputs.tsx +++ b/resources/ts/back/Components/DynamicPages/DynamicInputs.tsx @@ -1,6 +1,5 @@ // * Packages import { usePage } from "@inertiajs/react"; -import { useEffect, useRef } from "react"; // * Other import SimpleString from "@/back/Components/Inputs/SimpleString"; import SimpleNumber from "@/back/Components/Inputs/SimpleNumber"; @@ -14,8 +13,8 @@ import SimpleColorPicker from "@/back/Components/Inputs/SimpleColorPicker"; import SimpleYoutubeId from "@/back/Components/Inputs/SimpleYoutubeId"; import SimpleVimeoId from "@/back/Components/Inputs/SimpleVimeoId"; import EnumSelect from "@/back/Components/Inputs/EnumSelect"; -import { ModelSelect } from "@/back/Components/Inputs/ModelSelect"; import StaticRouteSelect from "@/back/Components/Inputs/StaticRouteSelect"; +import DynamicWrapperModelSelect from "@/back/Components/DynamicPages/DynamicWrapperModelSelect"; import { LaravelEnum } from "@/back/types/global"; import { ConfigField, @@ -25,13 +24,12 @@ import { import str from "@/hooks/use-string"; import useTrans from "@/hooks/use-translations"; import { - extractExcludedIdFromExists, extractLaravelValidationValue, extractMinMaxFromValidation, extractRequiredValidation, - extractTableFromExists, } from "@/hooks/use-laravel-validation"; +/* eslint-disable no-unused-vars */ type DynamicInputsProps = { name: string; config: ConfigField[]; @@ -44,6 +42,7 @@ type DynamicInputsProps = { reset: (name?: string) => void; parentErrors?: Record | null; }; +/* eslint-enable no-unused-vars */ // Allows to get specific input from enum value. export default function DynamicInputs({ @@ -332,55 +331,14 @@ export default function DynamicInputs({ ); // Model select. case enumDynamicFieldTypes.model.value: - // Extract only the model name from the validation. - const targetModel = - extractTableFromExists(field.validation) || - "dynamic_pages"; - - // Add a custom prefix in the last part of the name. - const newName = fieldName.replace( - /([^.\s]+)$/, - "reserved_$1", - ); - - // Set a state at false. - const initializedRef = useRef(false); - - // Set the model name in the custom key only once. - useEffect(() => { - if (initializedRef.current) return; - initializedRef.current = true; - - // If the value isn't already present in content. - if ( - content && - !content[ - `reserved_${field.key}` as keyof typeof content - ] - ) { - setData(newName, targetModel); - } - }, [newName, targetModel]); - return ( - ); // Static route select. diff --git a/resources/ts/back/Components/DynamicPages/DynamicList.tsx b/resources/ts/back/Components/DynamicPages/DynamicList.tsx index 0e9b102c..ec40d6c0 100644 --- a/resources/ts/back/Components/DynamicPages/DynamicList.tsx +++ b/resources/ts/back/Components/DynamicPages/DynamicList.tsx @@ -38,6 +38,7 @@ import { import { ConfigField, DynamicInternalField } from "@/back/types/dynamic-pages"; import { cn } from "@/lib/utils"; +/* eslint-disable no-unused-vars */ type DynamicListProps = { name: string; parentName: string; @@ -52,6 +53,7 @@ type DynamicListProps = { ) => void; reset: (name?: string) => void; }; +/* eslint-enable no-unused-vars */ // Allows to get recursive list inputs. export default function DynamicList({ @@ -140,8 +142,8 @@ export default function DynamicList({ ) => { // Get the current list of elements. const list = Array.isArray(content?.[fieldKey as keyof typeof content]) - // @ts-expect-error - ? [...content[fieldKey as keyof typeof content]] + ? // @ts-expect-error Weird error type. + [...content[fieldKey as keyof typeof content]] : []; // Remove the targeted element. list.splice(index, 1); diff --git a/resources/ts/back/Components/DynamicPages/DynamicWrapperModelSelect.tsx b/resources/ts/back/Components/DynamicPages/DynamicWrapperModelSelect.tsx new file mode 100644 index 00000000..79a86eec --- /dev/null +++ b/resources/ts/back/Components/DynamicPages/DynamicWrapperModelSelect.tsx @@ -0,0 +1,74 @@ +// * Packages +import { useEffect, useRef } from "react"; +// * Other +import { ModelSelect } from "@/back/Components/Inputs/ModelSelect"; +import { + extractExcludedIdFromExists, + extractRequiredValidation, + extractTableFromExists, +} from "@/hooks/use-laravel-validation"; +import { ConfigField, DynamicInternalField } from "@/back/types/dynamic-pages"; + +/* eslint-disable no-unused-vars */ +type DynamicWrapperModelSelectProps = { + field: ConfigField; + fieldName: string; + fieldValue: string | number | boolean | File | Date; + content: DynamicInternalField | null; + setData: ( + name: string, + value: string | number | boolean | File | object | null, + ) => void; + getTrans: (fieldLabel: string) => string; +}; +/* eslint-enable no-unused-vars */ + +export default function DynamicWrapperModelSelect({ + field, + fieldName, + fieldValue, + content, + setData, + getTrans, +}: DynamicWrapperModelSelectProps) { + // Extract only the model name from the validation. + const targetModel = + extractTableFromExists(field.validation) || "dynamic_pages"; + + // Add a custom prefix in the last part of the name. + const newName = fieldName.replace(/([^.\s]+)$/, "reserved_$1"); + + // Set a state at false. + const initializedRef = useRef(false); + + // Set the model name in the custom key only once. + useEffect(() => { + if (initializedRef.current) return; + initializedRef.current = true; + + // If the value isn't already present in content. + if ( + content && + !content[`reserved_${field.key}` as keyof typeof content] + ) { + setData(newName, targetModel); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [newName, targetModel]); + + return ( + + ); +} diff --git a/resources/ts/back/Components/Inputs/EnumSelect.tsx b/resources/ts/back/Components/Inputs/EnumSelect.tsx index 4e83af9f..f4c664df 100644 --- a/resources/ts/back/Components/Inputs/EnumSelect.tsx +++ b/resources/ts/back/Components/Inputs/EnumSelect.tsx @@ -29,7 +29,9 @@ type EnumSelectProps = { required?: boolean; disabled?: boolean; parentErrors?: Record | null; + // eslint-disable-next-line no-unused-vars setData: (name: string, value: number | null) => void; + // eslint-disable-next-line no-unused-vars onSelectValue?: (value: number | null) => void; }; diff --git a/resources/ts/back/Components/Inputs/SimpleColorPicker.tsx b/resources/ts/back/Components/Inputs/SimpleColorPicker.tsx index 571aefb0..92d99ee4 100644 --- a/resources/ts/back/Components/Inputs/SimpleColorPicker.tsx +++ b/resources/ts/back/Components/Inputs/SimpleColorPicker.tsx @@ -31,6 +31,7 @@ type SimpleColorPickerProps = { required?: boolean; disabled?: boolean; parentErrors?: Record | null; + /* eslint-disable no-unused-vars */ setData: (name: string, value: string | null) => void; }; @@ -87,15 +88,15 @@ export default function SimpleColorPicker({ /** * Convert ColorResult → HEXA. * - * @param color ColorResult + * @param targetColor ColorResult * @return string */ - function toHEXA(color: ColorResult): string { - const r = color.rgb.r.toString(16).padStart(2, "0"); - const g = color.rgb.g.toString(16).padStart(2, "0"); - const b = color.rgb.b.toString(16).padStart(2, "0"); + function toHEXA(targetColor: ColorResult): string { + const r = targetColor.rgb.r.toString(16).padStart(2, "0"); + const g = targetColor.rgb.g.toString(16).padStart(2, "0"); + const b = targetColor.rgb.b.toString(16).padStart(2, "0"); const a = - Math.round((color.rgb.a ?? 1) * 255) + Math.round((targetColor.rgb.a ?? 1) * 255) .toString(16) .padStart(2, "0") ?? "ff"; return `#${r}${g}${b}${a}`; @@ -143,11 +144,11 @@ export default function SimpleColorPicker({ /** * Update color via picker. * - * @param color ColorResult + * @param targetColor ColorResult * @return void */ - function handleChangeComplete(color: ColorResult): void { - const hex = toHEXA(color); + function handleChangeComplete(targetColor: ColorResult): void { + const hex = toHEXA(targetColor); setColor(hex); setData(name, hex); } @@ -195,6 +196,7 @@ export default function SimpleColorPicker({ useEffect(() => { if (value !== color) setColor(value); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [value]); return ( @@ -239,94 +241,6 @@ export default function SimpleColorPicker({ disableAlpha={false} presetColors={presetColors} /> - {/* Force custom style */} - {/* Random Color */} diff --git a/resources/ts/back/Components/Inputs/Slugifycator.tsx b/resources/ts/back/Components/Inputs/Slugifycator.tsx index 182e783d..34f7abca 100644 --- a/resources/ts/back/Components/Inputs/Slugifycator.tsx +++ b/resources/ts/back/Components/Inputs/Slugifycator.tsx @@ -6,14 +6,16 @@ import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithT import str from "@/hooks/use-string"; import useTrans from "@/hooks/use-translations"; -interface Props { - setData: (name: string, value: string) => void; +interface SlugifycatorProps { value: string; targetValue: string; wordCounter?: boolean; disabled?: boolean; + // eslint-disable-next-line no-unused-vars + setData: (name: string, value: string) => void; } -function Slugifycator(props: Props) { + +export default function Slugifycator(props: SlugifycatorProps) { const { value, targetValue, @@ -52,5 +54,3 @@ function Slugifycator(props: Props) { ); } - -export default Slugifycator; diff --git a/resources/ts/back/Components/Inputs/StaticRouteSelect.tsx b/resources/ts/back/Components/Inputs/StaticRouteSelect.tsx index 15799c01..3343f6a9 100644 --- a/resources/ts/back/Components/Inputs/StaticRouteSelect.tsx +++ b/resources/ts/back/Components/Inputs/StaticRouteSelect.tsx @@ -14,7 +14,7 @@ interface Props { setData: (name: string, value: number | null) => void; } -function StaticRouteSelect(props: Props) { +export default function StaticRouteSelect(props: Props) { const { name, selected, required, label, setData } = props; const enumStaticRoutes = usePage().props @@ -41,5 +41,3 @@ function StaticRouteSelect(props: Props) { /> ); } - -export default StaticRouteSelect; diff --git a/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageInputs.tsx b/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageInputs.tsx index e31fb157..a17c997f 100644 --- a/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageInputs.tsx +++ b/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageInputs.tsx @@ -10,6 +10,7 @@ type ImageInputsProps = { caption: string | null; hasCaption: boolean; }; + // eslint-disable-next-line no-unused-vars onChange: (value: ImageInputsProps["value"]) => void; errors?: Record; loading?: boolean; diff --git a/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageNodeView.tsx b/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageNodeView.tsx index 44fb607e..455bc6f0 100644 --- a/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageNodeView.tsx +++ b/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Image/ImageNodeView.tsx @@ -40,16 +40,6 @@ import str from "@/hooks/use-string"; import { cn } from "@/lib/utils"; import { parseStyleString } from "@/hooks/use-inline-style"; -type ImageAttrs = { - src: string; - alt: string; - width: number; - height: number; - caption: string | null; - style: string; - float: FloatOption; -}; - export type AllowedAligns = "left" | "center" | "right"; export type FloatOption = "left" | "right"; @@ -88,6 +78,16 @@ const PLACEMENT_STYLES: Record = { "float-right": FLOAT_STYLES.right, }; +type ImageAttrs = { + src: string; + alt: string; + width: number; + height: number; + caption: string | null; + style: string; + float: FloatOption; +}; + export default function ImageNodeView(props: NodeViewProps) { const { node, updateAttributes, editor, selected } = props; const attrs = node.attrs as ImageAttrs; diff --git a/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Replace/FindReplaceButton.tsx b/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Replace/FindReplaceButton.tsx index ecbbcfb6..4f6576d3 100644 --- a/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Replace/FindReplaceButton.tsx +++ b/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Replace/FindReplaceButton.tsx @@ -29,6 +29,28 @@ export default function FindReplaceButton({ editor }: { editor: Editor }) { // Duration of modal closing animation. const animationTime = 200; + /** + * Reset the component. + * + * @return void + */ + const resetComponent = (): void => { + setSearchText(""); + setReplaceText(""); + setMatchCase(false); + }; + + /** + * Close modal and reset component. + * + * @param status boolean + * @return void + */ + const closeModal = (status: boolean = false): void => { + setOpen(status); + setTimeout(() => resetComponent(), animationTime); + }; + /** * Search and replace specific text. * @@ -53,28 +75,6 @@ export default function FindReplaceButton({ editor }: { editor: Editor }) { closeModal(); }; - /** - * Reset the component. - * - * @return void - */ - const resetComponent = (): void => { - setSearchText(""); - setReplaceText(""); - setMatchCase(false); - }; - - /** - * Close modal and reset component. - * - * @param status boolean - * @return void - */ - const closeModal = (status: boolean = false): void => { - setOpen(status); - setTimeout(() => resetComponent(), animationTime); - }; - return ( closeModal(status)}> diff --git a/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Table/TableButton.tsx b/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Table/TableButton.tsx index be44abc1..370be735 100644 --- a/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Table/TableButton.tsx +++ b/resources/ts/back/Components/Inputs/Wysiwyg/Extensions/Table/TableButton.tsx @@ -86,16 +86,6 @@ export default function TableButton({ editor, disabled }: TableProps) { setHeader(true); }; - /** - * Insert tableClose modal and reset component. - * - * @return void - */ - const handleInsertTable = (): void => { - insert(); - closeModal(); - }; - /** * Close modal and reset component. * @@ -106,6 +96,16 @@ export default function TableButton({ editor, disabled }: TableProps) { setTimeout(() => resetComponent(), animationTime); }; + /** + * Insert tableClose modal and reset component. + * + * @return void + */ + const handleInsertTable = (): void => { + insert(); + closeModal(); + }; + // Set size of the current table on hover. useEffect(() => { setHover({ row: rows, column: cols }); diff --git a/resources/ts/back/Components/Inputs/Wysiwyg/SimpleWysiwyg.tsx b/resources/ts/back/Components/Inputs/Wysiwyg/SimpleWysiwyg.tsx index 77cb17bd..034f0864 100644 --- a/resources/ts/back/Components/Inputs/Wysiwyg/SimpleWysiwyg.tsx +++ b/resources/ts/back/Components/Inputs/Wysiwyg/SimpleWysiwyg.tsx @@ -38,6 +38,7 @@ type SimpleWysiwygProps = { required?: boolean; disabled?: boolean; parentErrors?: Record | null; + // eslint-disable-next-line no-unused-vars setData: (name: string, value: string) => void; }; @@ -136,6 +137,7 @@ export default function SimpleWysiwyg({ setEditor(e); return () => e.destroy(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); // Sync content if parent change. diff --git a/resources/ts/back/Components/News/AssociatedNewsList.tsx b/resources/ts/back/Components/News/AssociatedNewsList.tsx index a202d59c..376addc0 100644 --- a/resources/ts/back/Components/News/AssociatedNewsList.tsx +++ b/resources/ts/back/Components/News/AssociatedNewsList.tsx @@ -1,16 +1,15 @@ // * Packages import { Row } from "@tanstack/react-table"; -import { usePage } from "@inertiajs/react"; import { NewspaperIcon } from "lucide-react"; // * Components shadcn import { Badge } from "@/components/ui/badge"; // * Other import DataTable from "@/back/Components/Table/DataTable"; import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton"; -import { AppEnv, Resource } from "@/back/types/global"; +import { Resource } from "@/back/types/global"; import { NewsModel } from "@/back/types/others"; import NewsStatusBadge from "@/back/Components/News/NewsStatusBadge"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; import useTrans from "@/hooks/use-translations"; @@ -21,9 +20,6 @@ interface Props { } function AssociatedNewsList(props: Props) { const { news } = props; - const { appEnv } = usePage().props as unknown as { - appEnv: AppEnv; - }; const columns = [ { @@ -36,9 +32,9 @@ function AssociatedNewsList(props: Props) { field={column.id} /> ), - cell: ({ row }: { row: Row }) => { - return RenderTranslationCell(row.getValue("title")); - }, + cell: ({ row }: { row: Row }) => ( + + ), }, { accessorKey: "status", diff --git a/resources/ts/back/Components/PageConfigs/ConfigDetails.tsx b/resources/ts/back/Components/PageConfigs/ConfigDetails.tsx index 58c65fe4..a689e562 100644 --- a/resources/ts/back/Components/PageConfigs/ConfigDetails.tsx +++ b/resources/ts/back/Components/PageConfigs/ConfigDetails.tsx @@ -43,7 +43,7 @@ export default function ConfigDetails({ config }: ConfigDetailsProps) { const hasChildren = !!field.children?.length; const accordionKey = `${field.key}-${index}`; - const rowContent = (hasChildren: boolean = false) => ( + const rowContent = (targetHasChildren: boolean = false) => (

{getEnumDynamicFieldType(field.type)?.label} @@ -55,7 +55,7 @@ export default function ConfigDetails({ config }: ConfigDetailsProps) {

{field.validation || "—"}
- {!hasChildren &&
} + {!targetHasChildren &&
}
); diff --git a/resources/ts/back/Components/PageConfigs/DynamicFields.tsx b/resources/ts/back/Components/PageConfigs/DynamicFields.tsx index 67259233..ee438699 100644 --- a/resources/ts/back/Components/PageConfigs/DynamicFields.tsx +++ b/resources/ts/back/Components/PageConfigs/DynamicFields.tsx @@ -71,7 +71,8 @@ export default function DynamicFields({ let currentId = startId; const withIds = fields.map((field) => { - const id = currentId++; + currentId += 1; + const id = currentId; // Add the key in sensitive array. const currentParentKey = `${parentKey}.${field.key}`; @@ -197,18 +198,6 @@ export default function DynamicFields({ ); }; - /** - * Remove a specific field. - * @param fieldId string - * @returns void - */ - const removeField = (fieldId: number): void => { - const targetField = fields.filter((field) => field.id === fieldId)[0]; - - removeSensitiveField(targetField.key); - setFields((prev) => prev.filter((field) => field.id !== fieldId)); - }; - /** * Remove sensitive field list. * @param keyToRemove string @@ -221,6 +210,18 @@ export default function DynamicFields({ setLocalErrors({}); }; + /** + * Remove a specific field. + * @param fieldId string + * @returns void + */ + const removeField = (fieldId: number): void => { + const targetField = fields.filter((field) => field.id === fieldId)[0]; + + removeSensitiveField(targetField.key); + setFields((prev) => prev.filter((field) => field.id !== fieldId)); + }; + /** * Save the new order. * @param event DragEndEvent @@ -249,11 +250,11 @@ export default function DynamicFields({ /** * Remove all local ids. - * @param fields ConfigInternalField[] + * @param currentFields ConfigInternalField[] * @returns */ - const removeIds = (fields: ConfigInternalField[]): ConfigField[] => { - return fields.map(({ id, children, ...rest }) => ({ + const removeIds = (currentFields: ConfigInternalField[]): ConfigField[] => { + return currentFields.map(({ children, ...rest }) => ({ ...rest, ...(children ? { children: removeIds(children) } : {}), })) as ConfigField[]; @@ -267,11 +268,13 @@ export default function DynamicFields({ setData(name, payload); prevValueRef.current = payloadStr; } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [fields]); // Update fields when copying config from another locale. useEffect(() => { setFields(() => addIdsRecursively(value ?? [])); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedConfig]); return ( diff --git a/resources/ts/back/Components/PageConfigs/FieldGroup.tsx b/resources/ts/back/Components/PageConfigs/FieldGroup.tsx index cab6a27d..82c40088 100644 --- a/resources/ts/back/Components/PageConfigs/FieldGroup.tsx +++ b/resources/ts/back/Components/PageConfigs/FieldGroup.tsx @@ -39,6 +39,7 @@ import useTrans from "@/hooks/use-translations"; import str from "@/hooks/use-string"; import { cn } from "@/lib/utils"; +/* eslint-disable no-unused-vars */ type FieldGroupProps = { currentId: number; currentIndex: number; @@ -63,6 +64,7 @@ type FieldGroupProps = { setParentAccordionState: (key: string) => void; limitMaxChildren: number; }; +/* eslint-enable no-unused-vars */ export default function FieldGroup({ currentId, diff --git a/resources/ts/back/Components/PageConfigs/ImportConfigJson.tsx b/resources/ts/back/Components/PageConfigs/ImportConfigJson.tsx index 82a4af09..4299c2b9 100644 --- a/resources/ts/back/Components/PageConfigs/ImportConfigJson.tsx +++ b/resources/ts/back/Components/PageConfigs/ImportConfigJson.tsx @@ -1,5 +1,5 @@ // * Packages -import { useRef, useState } from "react"; +import { ChangeEvent, DragEvent, useRef, useState } from "react"; import { JsonEditor, IconReplacements, @@ -41,6 +41,7 @@ type JsonObject = { }; type ImportConfigJsonProps = { + // eslint-disable-next-line no-unused-vars onConfirm: (data: JsonObject[], overwrite: boolean) => void; }; @@ -188,13 +189,28 @@ export default function ImportConfigJson({ onConfirm }: ImportConfigJsonProps) { } }; + /** + * Reset component. + * + * @return void + */ + const resetComponent = (): void => { + setIsOpen(false); + setTimeout(() => { + setJsonText([]); + setGlobalErrors({}); + setEditorErrors({}); + setOverwrite(false); + }, 200); + }; + /** * Action when changing file. * * @param event * @return void */ - const handleFileChange = (e: React.ChangeEvent): void => { + const handleFileChange = (e: ChangeEvent): void => { const file = e.target.files?.[0]; if (file) processFile(file); }; @@ -205,7 +221,7 @@ export default function ImportConfigJson({ onConfirm }: ImportConfigJsonProps) { * @param event * @return void */ - const handleDrop = (event: React.DragEvent): void => { + const handleDrop = (event: DragEvent): void => { event.preventDefault(); setIsDragging(false); @@ -234,21 +250,6 @@ export default function ImportConfigJson({ onConfirm }: ImportConfigJsonProps) { } }; - /** - * Reset component. - * - * @return void - */ - const resetComponent = (): void => { - setIsOpen(false); - setTimeout(() => { - setJsonText([]); - setGlobalErrors({}); - setEditorErrors({}); - setOverwrite(false); - }, 200); - }; - return ( <> {/* Dropzone */} diff --git a/resources/ts/back/Components/RenderTranslationCell.tsx b/resources/ts/back/Components/Table/RenderTranslationCell.tsx similarity index 96% rename from resources/ts/back/Components/RenderTranslationCell.tsx rename to resources/ts/back/Components/Table/RenderTranslationCell.tsx index a7658248..03f120ad 100644 --- a/resources/ts/back/Components/RenderTranslationCell.tsx +++ b/resources/ts/back/Components/Table/RenderTranslationCell.tsx @@ -44,7 +44,7 @@ function useGetTranslationValue( * @param value - Translation field containing localized values * @return A ReactNode ready to be rendered inside a table cell */ -function RenderTranslationCell({ +export default function RenderTranslationCell({ value, }: { value?: TranslationField; @@ -67,5 +67,3 @@ function RenderTranslationCell({ ); } - -export default RenderTranslationCell; diff --git a/resources/ts/back/Layouts/AuthenticatedLayout.tsx b/resources/ts/back/Layouts/AuthenticatedLayout.tsx index b6960a0e..bd7a063d 100644 --- a/resources/ts/back/Layouts/AuthenticatedLayout.tsx +++ b/resources/ts/back/Layouts/AuthenticatedLayout.tsx @@ -27,11 +27,13 @@ function LayoutContent({ }: Omit & { children: ReactNode }) { const { open } = useSidebar(); const [isSm, setIsSm] = useState(false); - const sidebarVar = !isSm - ? open + + let sidebarVar = "0px"; + if (!isSm) { + sidebarVar = open ? "var(--sidebar-width)" - : "var(--sidebar-width-icon)" - : "0px"; + : "var(--sidebar-width-icon)"; + } useEffect(() => { const mediaQuery = window.matchMedia("(max-width: 767px)"); diff --git a/resources/ts/back/Pages/ActivityLogs/Index.tsx b/resources/ts/back/Pages/ActivityLogs/Index.tsx index b05faed2..fcb84890 100644 --- a/resources/ts/back/Pages/ActivityLogs/Index.tsx +++ b/resources/ts/back/Pages/ActivityLogs/Index.tsx @@ -153,7 +153,7 @@ const getColumns = (activityLogsEventEnum: ActivityLogsEventEnumProps) => { ), cell: ({ row }: { row: Row }) => { const modelClass = row.getValue("model_class"); - const { event, model_id } = row.original; + const { event, model_id: modelId } = row.original; const modelSplit = modelClass.split("\\"); const modelName = modelSplit[modelSplit.length - 1]; @@ -164,7 +164,7 @@ const getColumns = (activityLogsEventEnum: ActivityLogsEventEnumProps) => { diff --git a/resources/ts/back/Pages/CompanyActivities/Index.tsx b/resources/ts/back/Pages/CompanyActivities/Index.tsx index 92eb3496..734fdb7f 100644 --- a/resources/ts/back/Pages/CompanyActivities/Index.tsx +++ b/resources/ts/back/Pages/CompanyActivities/Index.tsx @@ -28,7 +28,7 @@ import { AuthProp, Resource } from "@/back/types/global"; import { CompanyActivityModel } from "@/back/types/others"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { useFormatedDate } from "@/hooks/use-formated-value"; const getColumns = () => { @@ -55,9 +55,9 @@ const getColumns = () => { field={column.id} /> ), - cell: ({ row }: { row: Row }) => { - return RenderTranslationCell(row.getValue("name")); - }, + cell: ({ row }: { row: Row }) => ( + + ), }, { accessorKey: "color", diff --git a/resources/ts/back/Pages/CompanyActivities/Show.tsx b/resources/ts/back/Pages/CompanyActivities/Show.tsx index b0452541..d6350125 100644 --- a/resources/ts/back/Pages/CompanyActivities/Show.tsx +++ b/resources/ts/back/Pages/CompanyActivities/Show.tsx @@ -10,6 +10,7 @@ import DetailsTable from "@/back/Components/Table/DetailsTable"; import ModelActions from "@/back/Components/ModelActions"; import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; import AssociatedCompaniesList from "@/back/Components/AssociatedCompaniesList"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; import { AuthProp, Resource, SingleResource } from "@/back/types/global"; @@ -17,7 +18,6 @@ import { TranslationField } from "@/back/types/i18n"; import { CompanyActivityModel } from "@/back/types/others"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = () => { const GetTranslation = (name: string, options?: UseTransOptions) => { @@ -36,9 +36,9 @@ const getColumns = () => { header: str(GetTranslation("validation.attributes.name")) .ucFirst() .value(), - cell: ({ value }: { value: TranslationField }) => { - return RenderTranslationCell(value); - }, + cell: ({ value }: { value: TranslationField }) => ( + + ), }, { accessorKey: "color", diff --git a/resources/ts/back/Pages/CompanySectors/Index.tsx b/resources/ts/back/Pages/CompanySectors/Index.tsx index ae7db1c1..d4a3e7eb 100644 --- a/resources/ts/back/Pages/CompanySectors/Index.tsx +++ b/resources/ts/back/Pages/CompanySectors/Index.tsx @@ -18,12 +18,12 @@ import DataTableSearch from "@/back/Components/Table/DataTableSearch"; import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton"; import SoftdeleteWarning from "@/back/Components/SoftdeleteWarning"; import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { Views } from "@/lib/utils"; import { AppEnv, AuthProp, Resource } from "@/back/types/global"; import { CompanySectorModel } from "@/back/types/others"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; import { useFormatedDate } from "@/hooks/use-formated-value"; const getColumns = () => { @@ -50,9 +50,9 @@ const getColumns = () => { field={column.id} /> ), - cell: ({ row }: { row: Row }) => { - return RenderTranslationCell(row.getValue("name")); - }, + cell: ({ row }: { row: Row }) => ( + + ), }, { accessorKey: "companies", diff --git a/resources/ts/back/Pages/CompanySectors/Show.tsx b/resources/ts/back/Pages/CompanySectors/Show.tsx index fb1d16ad..160c1225 100644 --- a/resources/ts/back/Pages/CompanySectors/Show.tsx +++ b/resources/ts/back/Pages/CompanySectors/Show.tsx @@ -10,6 +10,7 @@ import DetailsTable from "@/back/Components/Table/DetailsTable"; import ModelActions from "@/back/Components/ModelActions"; import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; import AssociatedCompaniesList from "@/back/Components/AssociatedCompaniesList"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; import { AuthProp, Resource, SingleResource } from "@/back/types/global"; @@ -17,7 +18,6 @@ import { CompanySectorModel } from "@/back/types/others"; import { TranslationField } from "@/back/types/i18n"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = () => { const GetTranslation = (name: string, options?: UseTransOptions) => { @@ -36,9 +36,9 @@ const getColumns = () => { header: str(GetTranslation("validation.attributes.name")) .ucFirst() .value(), - cell: ({ value }: { value: TranslationField }) => { - return RenderTranslationCell(value); - }, + cell: ({ value }: { value: TranslationField }) => ( + + ), }, { accessorKey: "published", diff --git a/resources/ts/back/Pages/Document/Index.tsx b/resources/ts/back/Pages/Document/Index.tsx index f21d6ba0..76516875 100644 --- a/resources/ts/back/Pages/Document/Index.tsx +++ b/resources/ts/back/Pages/Document/Index.tsx @@ -19,11 +19,10 @@ import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithT import DocumentStatusBadge from "@/back/Components/Documents/DocumentStatusBadge"; import Filters from "@/back/Components/Documents/Filters"; import { cn, Views } from "@/lib/utils"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { useFormatedDate } from "@/hooks/use-formated-value"; import { AppEnv, AuthProp, Resource } from "@/back/types/global"; import { DocumentModel, DocumentCategoryModel } from "@/back/types/others"; -import { TranslationField } from "@/back/types/i18n"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; @@ -86,9 +85,7 @@ const getColumns = (appEnv: AppEnv, viewAnyDocumentCategories: boolean) => { )} - {RenderTranslationCell( - row.getValue("name") as TranslationField, - )} +
); }, diff --git a/resources/ts/back/Pages/DocumentCategory/Index.tsx b/resources/ts/back/Pages/DocumentCategory/Index.tsx index a84ed01c..dc91323f 100644 --- a/resources/ts/back/Pages/DocumentCategory/Index.tsx +++ b/resources/ts/back/Pages/DocumentCategory/Index.tsx @@ -11,6 +11,7 @@ import DataTable from "@/back/Components/Table/DataTable"; import DataTableSearch from "@/back/Components/Table/DataTableSearch"; import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton"; import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import SoftdeleteWarning from "@/back/Components/SoftdeleteWarning"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; @@ -18,7 +19,6 @@ import { AppEnv, AuthProp, Resource } from "@/back/types/global"; import { DocumentCategoryModel } from "@/back/types/others"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = () => { const GetTranslation = (name: string, options?: UseTransOptions) => { @@ -44,9 +44,9 @@ const getColumns = () => { field={column.id} /> ), - cell: ({ row }: { row: Row }) => { - return RenderTranslationCell(row.getValue("name")); - }, + cell: ({ row }: { row: Row }) => ( + + ), }, { accessorKey: "documents", diff --git a/resources/ts/back/Pages/DocumentCategory/Show.tsx b/resources/ts/back/Pages/DocumentCategory/Show.tsx index e03233ef..e4e4ff86 100644 --- a/resources/ts/back/Pages/DocumentCategory/Show.tsx +++ b/resources/ts/back/Pages/DocumentCategory/Show.tsx @@ -8,6 +8,9 @@ import { Badge } from "@/components/ui/badge"; import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout"; import DetailsTable from "@/back/Components/Table/DetailsTable"; import ModelActions from "@/back/Components/ModelActions"; +import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; +import AssociatedDocumentList from "@/back/Components/Documents/AssociatedDocumentList"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; import { @@ -20,9 +23,6 @@ import { DocumentTagModel } from "@/back/types/others"; import { TranslationField } from "@/back/types/i18n"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; -import AssociatedDocumentList from "@/back/Components/Documents/AssociatedDocumentList"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = (appEnv: AppEnv) => { const GetTranslation = (name: string, options?: UseTransOptions) => { @@ -41,9 +41,9 @@ const getColumns = (appEnv: AppEnv) => { header: str(GetTranslation("validation.attributes.name")) .ucFirst() .value(), - cell: ({ value }: { value: TranslationField }) => { - return RenderTranslationCell(value); - }, + cell: ({ value }: { value: TranslationField }) => ( + + ), }, { accessorKey: "slug", diff --git a/resources/ts/back/Pages/DocumentTag/Index.tsx b/resources/ts/back/Pages/DocumentTag/Index.tsx index 8f556509..1c442b49 100644 --- a/resources/ts/back/Pages/DocumentTag/Index.tsx +++ b/resources/ts/back/Pages/DocumentTag/Index.tsx @@ -16,6 +16,7 @@ import DataTable from "@/back/Components/Table/DataTable"; import DataTableSearch from "@/back/Components/Table/DataTableSearch"; import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton"; import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import SoftdeleteWarning from "@/back/Components/SoftdeleteWarning"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; @@ -23,7 +24,6 @@ import { AppEnv, AuthProp, Resource } from "@/back/types/global"; import { DocumentTagModel } from "@/back/types/others"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = () => { const GetTranslation = (name: string, options?: UseTransOptions) => { @@ -49,9 +49,9 @@ const getColumns = () => { field={column.id} /> ), - cell: ({ row }: { row: Row }) => { - return RenderTranslationCell(row.getValue("name")); - }, + cell: ({ row }: { row: Row }) => ( + + ), }, { accessorKey: "color", diff --git a/resources/ts/back/Pages/DocumentTag/Show.tsx b/resources/ts/back/Pages/DocumentTag/Show.tsx index f01f6cfc..c89a7acc 100644 --- a/resources/ts/back/Pages/DocumentTag/Show.tsx +++ b/resources/ts/back/Pages/DocumentTag/Show.tsx @@ -13,6 +13,9 @@ import { import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout"; import DetailsTable from "@/back/Components/Table/DetailsTable"; import ModelActions from "@/back/Components/ModelActions"; +import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; +import AssociatedDocumentList from "@/back/Components/Documents/AssociatedDocumentList"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; import { @@ -25,9 +28,6 @@ import { DocumentTagModel } from "@/back/types/others"; import { TranslationField } from "@/back/types/i18n"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; -import AssociatedDocumentList from "@/back/Components/Documents/AssociatedDocumentList"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = (appEnv: AppEnv) => { const GetTranslation = (name: string, options?: UseTransOptions) => { @@ -46,9 +46,9 @@ const getColumns = (appEnv: AppEnv) => { header: str(GetTranslation("validation.attributes.name")) .ucFirst() .value(), - cell: ({ value }: { value: TranslationField }) => { - return RenderTranslationCell(value); - }, + cell: ({ value }: { value: TranslationField }) => ( + + ), }, { accessorKey: "slug", diff --git a/resources/ts/back/Pages/DynamicPages/Index.tsx b/resources/ts/back/Pages/DynamicPages/Index.tsx index 6728391a..12110b54 100644 --- a/resources/ts/back/Pages/DynamicPages/Index.tsx +++ b/resources/ts/back/Pages/DynamicPages/Index.tsx @@ -27,14 +27,13 @@ import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton import SoftdeleteWarning from "@/back/Components/SoftdeleteWarning"; import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; import DynamicStatusBadge from "@/back/Components/DynamicPages/DynamicStatusBadge"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { useFormatedDate } from "@/hooks/use-formated-value"; import { Views } from "@/lib/utils"; import { AppEnv, AuthProp, Resource } from "@/back/types/global"; import { DynamicPageModel, PageConfigModel } from "@/back/types/dynamic-pages"; -import { TranslationField } from "@/back/types/i18n"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = ( appEnv: AppEnv, @@ -67,9 +66,7 @@ const getColumns = ( ), cell: ({ row }: { row: Row }) => (
- {RenderTranslationCell( - row.getValue("title") as TranslationField, - )} + {row.original.isRoot && ( diff --git a/resources/ts/back/Pages/DynamicPages/Show.tsx b/resources/ts/back/Pages/DynamicPages/Show.tsx index 56f504f9..d6872ec3 100644 --- a/resources/ts/back/Pages/DynamicPages/Show.tsx +++ b/resources/ts/back/Pages/DynamicPages/Show.tsx @@ -16,6 +16,8 @@ import DetailsTable from "@/back/Components/Table/DetailsTable"; import ModelActions from "@/back/Components/ModelActions"; import DynamicStatusBadge from "@/back/Components/DynamicPages/DynamicStatusBadge"; import RecursiveContent from "@/back/Components/DynamicPages/DynamicPageDetails"; +import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; import { AppEnv, AuthProp, SingleResource } from "@/back/types/global"; @@ -26,8 +28,6 @@ import { import { TranslationField } from "@/back/types/i18n"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = ( appEnv: AppEnv, @@ -51,8 +51,9 @@ const getColumns = ( header: str(GetTranslation("validation.attributes.title")) .ucFirst() .value(), - cell: ({ value }: { value: TranslationField }) => - RenderTranslationCell(value), + cell: ({ value }: { value: TranslationField }) => ( + + ), }, { accessorKey: "parent_page", diff --git a/resources/ts/back/Pages/News/Index.tsx b/resources/ts/back/Pages/News/Index.tsx index b4e34df6..1368e04d 100644 --- a/resources/ts/back/Pages/News/Index.tsx +++ b/resources/ts/back/Pages/News/Index.tsx @@ -19,13 +19,13 @@ import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; import NewsStatusBadge from "@/back/Components/News/NewsStatusBadge"; import SoftdeleteWarning from "@/back/Components/SoftdeleteWarning"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; import { AppEnv, AuthProp, Resource } from "@/back/types/global"; import { NewsModel, NewsCategoryModel } from "@/back/types/others"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = (appEnv: AppEnv, viewAnyNewsCategories: boolean) => { const GetTranslation = (name: string, options?: UseTransOptions) => { @@ -51,9 +51,9 @@ const getColumns = (appEnv: AppEnv, viewAnyNewsCategories: boolean) => { field={column.id} /> ), - cell: ({ row }: { row: Row }) => { - return RenderTranslationCell(row.getValue("title")); - }, + cell: ({ row }: { row: Row }) => ( + + ), }, { accessorKey: "categories", diff --git a/resources/ts/back/Pages/News/Show.tsx b/resources/ts/back/Pages/News/Show.tsx index 7188b5b8..e154c24d 100644 --- a/resources/ts/back/Pages/News/Show.tsx +++ b/resources/ts/back/Pages/News/Show.tsx @@ -8,6 +8,9 @@ import { Badge } from "@/components/ui/badge"; import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout"; import DetailsTable from "@/back/Components/Table/DetailsTable"; import ModelActions from "@/back/Components/ModelActions"; +import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; +import NewsStatusBadge from "@/back/Components/News/NewsStatusBadge"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; import { AppEnv, AuthProp, SingleResource } from "@/back/types/global"; @@ -19,10 +22,7 @@ import { import { TranslationField } from "@/back/types/i18n"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; -import NewsStatusBadge from "@/back/Components/News/NewsStatusBadge"; import useLocale from "@/store/use-locale-store"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = ( appEnv: AppEnv, @@ -73,9 +73,9 @@ const getColumns = ( header: str(GetTranslation("validation.attributes.title")) .ucFirst() .value(), - cell: ({ value }: { value: TranslationField }) => { - return RenderTranslationCell(value); - }, + cell: ({ value }: { value: TranslationField }) => ( + + ), }, { accessorKey: "slug", diff --git a/resources/ts/back/Pages/NewsCategory/Index.tsx b/resources/ts/back/Pages/NewsCategory/Index.tsx index 7a56e153..a16f00e9 100644 --- a/resources/ts/back/Pages/NewsCategory/Index.tsx +++ b/resources/ts/back/Pages/NewsCategory/Index.tsx @@ -11,6 +11,7 @@ import DataTable from "@/back/Components/Table/DataTable"; import DataTableSearch from "@/back/Components/Table/DataTableSearch"; import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton"; import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import SoftdeleteWarning from "@/back/Components/SoftdeleteWarning"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; @@ -18,7 +19,6 @@ import { AuthProp, Resource } from "@/back/types/global"; import { NewsCategoryModel } from "@/back/types/others"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = () => { const GetTranslation = (name: string, options?: UseTransOptions) => { @@ -44,9 +44,9 @@ const getColumns = () => { field={column.id} /> ), - cell: ({ row }: { row: Row }) => { - return RenderTranslationCell(row.getValue("name")); - }, + cell: ({ row }: { row: Row }) => ( + + ), }, { accessorKey: "news", diff --git a/resources/ts/back/Pages/NewsCategory/Show.tsx b/resources/ts/back/Pages/NewsCategory/Show.tsx index 47640cfa..96c0fecc 100644 --- a/resources/ts/back/Pages/NewsCategory/Show.tsx +++ b/resources/ts/back/Pages/NewsCategory/Show.tsx @@ -8,6 +8,9 @@ import { Badge } from "@/components/ui/badge"; import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout"; import DetailsTable from "@/back/Components/Table/DetailsTable"; import ModelActions from "@/back/Components/ModelActions"; +import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; +import AssociatedNewsList from "@/back/Components/News/AssociatedNewsList"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; import { @@ -20,9 +23,6 @@ import { NewsCategoryModel } from "@/back/types/others"; import { TranslationField } from "@/back/types/i18n"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; -import AssociatedNewsList from "@/back/Components/News/AssociatedNewsList"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = (appEnv: AppEnv) => { const GetTranslation = (name: string, options?: UseTransOptions) => { @@ -41,9 +41,9 @@ const getColumns = (appEnv: AppEnv) => { header: str(GetTranslation("validation.attributes.name")) .ucFirst() .value(), - cell: ({ value }: { value: TranslationField }) => { - return RenderTranslationCell(value); - }, + cell: ({ value }: { value: TranslationField }) => ( + + ), }, { accessorKey: "slug", diff --git a/resources/ts/back/Pages/NewsTag/Index.tsx b/resources/ts/back/Pages/NewsTag/Index.tsx index 4650720b..f54c3442 100644 --- a/resources/ts/back/Pages/NewsTag/Index.tsx +++ b/resources/ts/back/Pages/NewsTag/Index.tsx @@ -16,6 +16,7 @@ import DataTable from "@/back/Components/Table/DataTable"; import DataTableSearch from "@/back/Components/Table/DataTableSearch"; import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton"; import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import SoftdeleteWarning from "@/back/Components/SoftdeleteWarning"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; @@ -23,7 +24,6 @@ import { AuthProp, Resource } from "@/back/types/global"; import { NewsTagModel } from "@/back/types/others"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = () => { const GetTranslation = (name: string, options?: UseTransOptions) => { @@ -49,9 +49,9 @@ const getColumns = () => { field={column.id} /> ), - cell: ({ row }: { row: Row }) => { - return RenderTranslationCell(row.getValue("name")); - }, + cell: ({ row }: { row: Row }) => ( + + ), }, { accessorKey: "color", diff --git a/resources/ts/back/Pages/NewsTag/Show.tsx b/resources/ts/back/Pages/NewsTag/Show.tsx index a8210cae..fa5ca826 100644 --- a/resources/ts/back/Pages/NewsTag/Show.tsx +++ b/resources/ts/back/Pages/NewsTag/Show.tsx @@ -13,6 +13,9 @@ import { import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout"; import DetailsTable from "@/back/Components/Table/DetailsTable"; import ModelActions from "@/back/Components/ModelActions"; +import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; +import AssociatedNewsList from "@/back/Components/News/AssociatedNewsList"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; import { @@ -25,9 +28,6 @@ import { NewsTagModel } from "@/back/types/others"; import { TranslationField } from "@/back/types/i18n"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; -import AssociatedNewsList from "@/back/Components/News/AssociatedNewsList"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = (appEnv: AppEnv) => { const GetTranslation = (name: string, options?: UseTransOptions) => { @@ -46,9 +46,9 @@ const getColumns = (appEnv: AppEnv) => { header: str(GetTranslation("validation.attributes.name")) .ucFirst() .value(), - cell: ({ value }: { value: TranslationField }) => { - return RenderTranslationCell(value); - }, + cell: ({ value }: { value: TranslationField }) => ( + + ), }, { accessorKey: "slug", diff --git a/resources/ts/back/Pages/PageConfigs/Form.tsx b/resources/ts/back/Pages/PageConfigs/Form.tsx index 6fdf4fbe..4fef73ee 100644 --- a/resources/ts/back/Pages/PageConfigs/Form.tsx +++ b/resources/ts/back/Pages/PageConfigs/Form.tsx @@ -130,6 +130,7 @@ export default function Form({ if (isEmpty && selectedConfig !== null) { setSelectedConfig(null); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [data.config]); useEffect(() => { @@ -140,6 +141,7 @@ export default function Form({ .value(); setData("config", model?.config[lowerSelectedLocale] ?? []); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedConfig]); return ( @@ -231,7 +233,7 @@ export default function Form({ className="w-[var(--radix-select-trigger-width)]" > {otherConfigs.map(([configLocale, config]) => { - configLocale = str(configLocale) + const strConfigLocale = str(configLocale) .upperCase() .value(); const localeFields = Object.values(config) @@ -239,12 +241,12 @@ export default function Form({ .join(", "); return ( - {configLocale}:{" "} + {strConfigLocale}:{" "} {localeFields} ); diff --git a/resources/ts/back/Pages/PageConfigs/Index.tsx b/resources/ts/back/Pages/PageConfigs/Index.tsx index e7a90768..9eab7432 100644 --- a/resources/ts/back/Pages/PageConfigs/Index.tsx +++ b/resources/ts/back/Pages/PageConfigs/Index.tsx @@ -12,14 +12,13 @@ import DataTableSearch from "@/back/Components/Table/DataTableSearch"; import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton"; import SoftdeleteWarning from "@/back/Components/SoftdeleteWarning"; import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; import { AuthProp, Resource } from "@/back/types/global"; import { PageConfigModel } from "@/back/types/dynamic-pages"; -import { TranslationField } from "@/back/types/i18n"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = () => { const GetTranslation = (name: string, options?: UseTransOptions) => { @@ -43,11 +42,9 @@ const getColumns = () => { field={column.id} /> ), - cell: ({ row }: { row: Row }) => { - return RenderTranslationCell( - row.getValue("label") as TranslationField, - ); - }, + cell: ({ row }: { row: Row }) => ( + + ), }, { accessorKey: "view", diff --git a/resources/ts/back/Pages/PageConfigs/Show.tsx b/resources/ts/back/Pages/PageConfigs/Show.tsx index 1bf9f7e2..84ef7216 100644 --- a/resources/ts/back/Pages/PageConfigs/Show.tsx +++ b/resources/ts/back/Pages/PageConfigs/Show.tsx @@ -9,6 +9,8 @@ import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout"; import DetailsTable from "@/back/Components/Table/DetailsTable"; import ModelActions from "@/back/Components/ModelActions"; import ConfigDetails from "@/back/Components/PageConfigs/ConfigDetails"; +import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; +import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; import { Views } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; import { AppEnv, AuthProp, SingleResource } from "@/back/types/global"; @@ -16,8 +18,6 @@ import { ConfigField, PageConfigModel } from "@/back/types/dynamic-pages"; import { TranslationField } from "@/back/types/i18n"; import str from "@/hooks/use-string"; import useTrans, { UseTransOptions } from "@/hooks/use-translations"; -import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; -import RenderTranslationCell from "@/back/Components/RenderTranslationCell"; const getColumns = (appEnv: AppEnv) => { const GetTranslation = (name: string, options?: UseTransOptions) => { @@ -36,9 +36,9 @@ const getColumns = (appEnv: AppEnv) => { header: str(GetTranslation("validation.custom.label")) .ucFirst() .value(), - cell: ({ value }: { value: TranslationField }) => { - return RenderTranslationCell(value); - }, + cell: ({ value }: { value: TranslationField }) => ( + + ), }, { accessorKey: "view",