migration

This commit is contained in:
Théo LAGACHE
2025-05-16 15:54:17 +02:00
parent 01019fe1a3
commit 6f2523e524
285 changed files with 15492 additions and 46090 deletions
@@ -1,46 +1,44 @@
'use client'
"use client";
import React, {useState} from 'react'
import {cn} from "@/lib/utils";
import React, { ComponentType, useState } from "react";
import { cn } from "@/lib/utils";
import {PaginationNavigation} from "@/components/wrappers/common/pagination/pagination-navigation";
import { PaginationNavigation } from "@/components/wrappers/common/pagination/pagination-navigation";
export type cardsWithPaginationProps = {
className?: string
organizationSlug?:string
data: Array<{}>;
cardItem: React.ComponentType;
cardsPerPage?: number
numberOfColumns?: number
maxVisiblePages?: number
extendedProps?: any
interface CardsWithPaginationProps<T> {
className?: string;
data: any[];
organizationSlug?: string;
cardItem: ComponentType<{ data: T; organizationSlug?: string; extendedProps?: any }>;
cardsPerPage?: number;
numberOfColumns?: number;
maxVisiblePages?: number;
extendedProps?: any;
}
export function CardsWithPagination<T>(props: CardsWithPaginationProps<T>) {
const { className, organizationSlug, data, cardItem, cardsPerPage = 5, numberOfColumns = 1, maxVisiblePages = 3 } = props;
export const CardsWithPagination = (props: cardsWithPaginationProps) => {
const CardItem = cardItem;
const {className,organizationSlug, data, cardItem, cardsPerPage = 5, numberOfColumns = 1, maxVisiblePages = 3} = props
const [currentPage, setCurrentPage] = useState(1);
const totalPages = Math.ceil(data.length / cardsPerPage);
const CardItem = cardItem
const [currentPage, setCurrentPage] = useState(1)
const totalPages = Math.ceil(data.length / cardsPerPage)
const indexOfLastCard = currentPage * cardsPerPage
const indexOfFirstCard = indexOfLastCard - cardsPerPage
const currentCards = data.slice(indexOfFirstCard, indexOfLastCard)
const indexOfLastCard = currentPage * cardsPerPage;
const indexOfFirstCard = indexOfLastCard - cardsPerPage;
const currentCards = data.slice(indexOfFirstCard, indexOfLastCard);
const goToPage = (pageNumber: number) => {
setCurrentPage(pageNumber)
}
setCurrentPage(pageNumber);
};
const goToPrevPage = () => {
goToPage(Math.max(1, currentPage - 1))
}
goToPage(Math.max(1, currentPage - 1));
};
const goToNextPage = () => {
goToPage(Math.min(totalPages, currentPage + 1))
}
goToPage(Math.min(totalPages, currentPage + 1));
};
return (
<div className={cn("flex flex-col h-full justify-between", className)}>
@@ -56,7 +54,8 @@ export const CardsWithPagination = (props: cardsWithPaginationProps) => {
goToPage={goToPage}
goToPrevPage={goToPrevPage}
goToNextPage={goToNextPage}
maxVisiblePages={maxVisiblePages}/>
maxVisiblePages={maxVisiblePages}
/>
</div>
)
}
);
}