0
votes

I finally decided to seek help from people who will be more knowledgeable than me with this problem..

I have a table, very simple, and I would like this one to take up all the remaining space on the page, knowing that before it there is a list of inputs..

I tried several tricks, but after several hours I think you'll find the solution pretty quickly...^^

Main function :

export default function Interventions(){
return (
    <div className="dark:bg-slate-800 px-4 sm:px-6 lg:px-8">
        <InterventionSearchInput/>
        <InterventionsTable/>
    </div>
)

}

InterventionSearchInput :

export function InterventionSearchInput(props){

return(
    <div className="text-center space-y-3 mt-4 mb-4">
        <div className="space-x-2 flex justify-center" style={{flexFlow:'row wrap'}}>
            <input
                type="text"
                name="id_intervention"
                id="id_intervention"
                placeholder="N° d'intervention"
                className="max-w-[140px] mt-1 border border-gray-300 dark:border-gray-500 dark:bg-slate-700 dark:text-gray-300 dark:placeholder-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:border-indigo-500 sm:text-sm hover:bg-indigo-50 dark:hover:bg-slate-600"
            />
            <input
                type="text"
                name="idInterne"
                id="idInterne"
                placeholder="Id Interne"
                className="max-w-[140px] mt-1 border border-gray-300 dark:border-gray-500 dark:bg-slate-700 dark:text-gray-300 dark:placeholder-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:border-indigo-500 sm:text-sm hover:bg-indigo-50 dark:hover:bg-slate-600"
            />
            <input
                type="text"
                name="IdTicket"
                id="IdTicket"
                placeholder="Id Ticket"
                className="max-w-[140px] mt-1 border border-gray-300 dark:border-gray-500 dark:bg-slate-700 dark:text-gray-300 dark:placeholder-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:border-indigo-500 sm:text-sm hover:bg-indigo-50 dark:hover:bg-slate-600"
            />
            <input
                type="text"
                name="site"
                id="site"
                placeholder="Site"
                className="max-w-[140px] mt-1 border border-gray-300 dark:border-gray-500 dark:bg-slate-700 dark:text-gray-300 dark:placeholder-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:border-indigo-500 sm:text-sm hover:bg-indigo-50 dark:hover:bg-slate-600"
            />
            <input
                type="date"
                name="dateStart"
                id="dateStart"
                className="mt-1 border border-gray-300 dark:border-gray-500 dark:bg-slate-700 dark:text-gray-300 dark:placeholder-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:border-indigo-500 sm:text-sm hover:bg-indigo-50 dark:hover:bg-slate-600"
            />
            <input
                type="date"
                name="dateEnd"
                id="dateEnd"
                className="mt-1 border border-gray-300 dark:border-gray-500 dark:bg-slate-700 dark:text-gray-300 dark:placeholder-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:border-indigo-500 sm:text-sm hover:bg-indigo-50 dark:hover:bg-slate-600"
            />
            <StatutListSearch setStatutSearch={props.setStatutSearch} statutSearch={props.statutSearch} setStatutSearchId={props.setStatutSearchId}/>
            <button
                onClick={() => csvInter()}
                disabled={props.loaderCSV}
                className="inline-block px-4 py-2 text-xs font-medium text-center text-yellow-500 uppercase transition bg-transparent border-2 border-yellow-500 rounded shadow ripple hover:shadow-lg hover:bg-yellow-100 focus:outline-none"
            >
                {props.loaderCSV && (
                    <svg role="status"
                         className="inline w-4 h-4 mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-yellow-400"
                         viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
                        <path
                            d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
                            fill="currentColor"/>
                        <path
                            d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
                            fill="currentFill"/>
                    </svg>
                )}
                {props.loaderCSV && <span>CSV en cours de création</span>}
                {!props.loaderCSV && <span>CSV</span>}
            </button>
        </div>

    </div>
)

}

InterventionsTable :

export function InterventionsTable(props){

return(
    loading ?
        <LoaderTable type="spin" color="#00b0f0"/>
        :
        <div className="dark:bg-slate-800 flex flex-col">
            <div className="-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8">
                <div className="inline-block min-w-full py-2 align-middle md:px-6 lg:px-8">
                    <div onScroll={handleScroll}
                         className="shadow ring-1 ring-black ring-opacity-5 md:rounded-lg overflow-y-scroll Xsm:max-h-[50vh] sm:max-h-[60vh] md:max-h-[65vh] lg:max-h-[70vh] xl:max-h-[75vh] 2xl:max-h-[85vh] xxl:max-h-[89vh]">
                        <table className="min-w-full divide-y divide-gray-300 dark:divide-gray-500">
                            <thead className="bg-gray-50 sticky top-0">
                            <tr className="divide-x divide-gray-200 dark:divide-gray-500">
                                <th scope="col"
                                    className="dark:bg-slate-700 dark:text-gray-300 py-3.5 pl-4 pr-4 text-left text-xs font-semibold text-gray-900">
                                    <a href="#"
                                       onClick={() => {
                                           orderID === 'asc' ?
                                               changeOrder('desc', 'tri_id_inter_listing')
                                               :
                                               changeOrder('asc', 'tri_id_inter_listing')
                                       }}
                                       className="group inline-flex">
                                        Id Interne
                                        <span
                                            className="ml-2 flex-none rounded bg-gray-200 text-gray-900 group-hover:bg-gray-300">
                                    {
                                        orderID === 'asc' ?
                                            <ChevronDownIcon className="h-5 w-5" aria-hidden="true"/>
                                            :
                                            <ChevronUpIcon className="h-5 w-5" aria-hidden="true"/>
                                    }
                                </span>
                                    </a>
                                </th>
                                <th scope="col"
                                    className="dark:bg-slate-700 dark:text-gray-300 py-3.5 pl-4 pr-4 text-left text-xs font-semibold text-gray-900">
                                    <a href="#"
                                       onClick={() => {
                                           orderIDInterne === 'asc' ?
                                               changeOrder('desc', 'tri_id_client')
                                               :
                                               changeOrder('asc', 'tri_id_client')
                                       }}
                                       className="group inline-flex">
                                        Id Client
                                        <span
                                            className="ml-2 flex-none rounded bg-gray-200 text-gray-900 group-hover:bg-gray-300">
                                    {
                                        orderIDInterne === 'asc' ?
                                            <ChevronDownIcon className="h-5 w-5" aria-hidden="true"/>
                                            :
                                            <ChevronUpIcon className="h-5 w-5" aria-hidden="true"/>
                                    }
                                </span>
                                    </a>
                                </th>
                                <th scope="col"
                                    className="dark:bg-slate-700 dark:text-gray-300 py-3.5 pl-4 pr-4 text-left text-xs font-semibold text-gray-900">
                                    <a href="#"
                                       onClick={() => {
                                           orderDate === 'asc' ?
                                               changeOrder('desc', 'tri_date_h_rdv')
                                               :
                                               changeOrder('asc', 'tri_date_h_rdv')
                                       }}
                                       className="group inline-flex">
                                        Date RDV
                                        <span
                                            className="ml-2 flex-none rounded bg-gray-200 text-gray-900 group-hover:bg-gray-300">
                                    {
                                        orderDate === 'asc' ?
                                            <ChevronDownIcon className="h-5 w-5" aria-hidden="true"/>
                                            :
                                            <ChevronUpIcon className="h-5 w-5" aria-hidden="true"/>
                                    }
                                </span>
                                    </a>
                                </th>

                                <th scope="col"
                                    className="dark:bg-slate-700 dark:text-gray-300 py-3.5 pl-4 pr-4 text-left text-xs font-semibold text-gray-900">
                                    <a href="#"
                                       onClick={() => {
                                           orderTech === 'asc' ?
                                               changeOrder('desc', 'tri_technician')
                                               :
                                               changeOrder('asc', 'tri_technician')
                                       }}
                                       className="group inline-flex">
                                        Partenaire
                                        <span
                                            className="ml-2 flex-none rounded bg-gray-200 text-gray-900 group-hover:bg-gray-300">
                                    {
                                        orderTech === 'asc' ?
                                            <ChevronDownIcon className="h-5 w-5" aria-hidden="true"/>
                                            :
                                            <ChevronUpIcon className="h-5 w-5" aria-hidden="true"/>
                                    }
                                </span>
                                    </a>
                                </th>
                                <th scope="col"
                                    className="dark:bg-slate-700 dark:text-gray-300 py-3.5 pl-4 pr-4 text-left text-xs font-semibold text-gray-900">
                                    <a href="#"
                                       onClick={() => {
                                           orderSite === 'asc' ?
                                               changeOrder('desc', 'tri_site')
                                               :
                                               changeOrder('asc', 'tri_site')
                                       }}
                                       className="group inline-flex">
                                        Site
                                        <span
                                            className="ml-2 flex-none rounded bg-gray-200 text-gray-900 group-hover:bg-gray-300">
                                    {
                                        orderSite === 'asc' ?
                                            <ChevronDownIcon className="h-5 w-5" aria-hidden="true"/>
                                            :
                                            <ChevronUpIcon className="h-5 w-5" aria-hidden="true"/>
                                    }
                                </span>
                                    </a>
                                </th>
                                <th scope="col"
                                    className="dark:bg-slate-700 dark:text-gray-300 py-3.5 pl-4 pr-4 text-left text-xs font-semibold text-gray-900">
                                    <a href="#"
                                       onClick={() => {
                                           orderAdresse === 'asc' ?
                                               changeOrder('desc', 'tri_adresse')
                                               :
                                               changeOrder('asc', 'tri_adresse')
                                       }}
                                       className="group inline-flex">
                                        Adresse
                                        <span
                                            className="ml-2 flex-none rounded bg-gray-200 text-gray-900 group-hover:bg-gray-300">
                                    {
                                        orderAdresse === 'asc' ?
                                            <ChevronDownIcon className="h-5 w-5" aria-hidden="true"/>
                                            :
                                            <ChevronUpIcon className="h-5 w-5" aria-hidden="true"/>
                                    }
                                </span>
                                    </a>
                                </th>
                                <th scope="col"
                                    className="dark:bg-slate-700 dark:text-gray-300 py-3.5 pl-4 pr-4 text-left text-xs font-semibold text-gray-900">
                                    <a href="#"
                                       onClick={() => {
                                           orderVille === 'asc' ?
                                               changeOrder('desc', 'tri_ville')
                                               :
                                               changeOrder('asc', 'tri_ville')
                                       }}
                                       className="group inline-flex">
                                        Ville
                                        <span
                                            className="ml-2 flex-none rounded bg-gray-200 text-gray-900 group-hover:bg-gray-300">
                                    {
                                        orderVille === 'asc' ?
                                            <ChevronDownIcon className="h-5 w-5" aria-hidden="true"/>
                                            :
                                            <ChevronUpIcon className="h-5 w-5" aria-hidden="true"/>
                                    }
                                </span>
                                    </a>
                                </th>
                                <th scope="col"
                                    className="dark:bg-slate-700 dark:text-gray-300 py-3.5 pl-4 pr-4 text-left text-xs font-semibold text-gray-900">
                                    <a href="#"
                                       onClick={() => {
                                           orderCP === 'asc' ?
                                               changeOrder('desc', 'tri_cp')
                                               :
                                               changeOrder('asc', 'tri_cp')
                                       }}
                                       className="group inline-flex">
                                        CP
                                        <span
                                            className="ml-2 flex-none rounded bg-gray-200 text-gray-900 group-hover:bg-gray-300">
                                    {
                                        orderCP === 'asc' ?
                                            <ChevronDownIcon className="h-5 w-5" aria-hidden="true"/>
                                            :
                                            <ChevronUpIcon className="h-5 w-5" aria-hidden="true"/>
                                    }
                                </span>
                                    </a>
                                </th>
                                <th scope="col"
                                    className="dark:bg-slate-700 dark:text-gray-300 py-3.5 pl-4 pr-4 text-left text-xs font-semibold text-gray-900">
                                    <a href="#"
                                       className="group inline-flex">
                                        Dossier de clôture
                                    </a>
                                </th>
                                <th scope="col"
                                    className="dark:bg-slate-700 dark:text-gray-300 py-3.5 pl-4 pr-4 text-left text-xs font-semibold text-gray-900">
                                    <a href="#"
                                       onClick={() => {
                                           orderStatut === 'asc' ?
                                               changeOrder('desc', 'tri_statut')
                                               :
                                               changeOrder('asc', 'tri_statut')
                                       }}
                                       className="group inline-flex">
                                        Statut
                                        <span
                                            className="ml-2 flex-none rounded bg-gray-200 text-gray-900 group-hover:bg-gray-300">
                                    {
                                        orderStatut === 'asc' ?
                                            <ChevronDownIcon className="h-5 w-5" aria-hidden="true"/>
                                            :
                                            <ChevronUpIcon className="h-5 w-5" aria-hidden="true"/>
                                    }
                                </span>
                                    </a>
                                </th>
                            </tr>
                            </thead>
                            <tbody
                                className="divide-y divide-gray-200 bg-white h-48 max-h-screen overflow-y-scroll dark:bg-slate-700 dark:divide-gray-500">
                            {
                                items.map((c, index) => (
                                    <tr onClick={(e) => {
                                        e.preventDefault()
                                        e.stopPropagation()
                                        props.setShowMTicket(!props.showMTicket)
                                        props.setIdInter(c.id)
                                    }}
                                        key={index}
                                        className="divide-x divide-gray-200 dark:divide-gray-500 hover:bg-sky-100 dark:hover:bg-slate-600">
                                        <td className="whitespace-wrap py-4 pl-4 pr-4 text-xs font-medium text-gray-900 cursor-pointer dark:text-gray-300">{c.id}</td>
                                        <td className="whitespace-wrap py-4 pl-4 pr-4 text-xs text-gray-500 max-w-xs cursor-pointer dark:text-gray-300">{c.num_inter_apporteur}</td>
                                        <td className="whitespace-wrap py-4 pl-4 pr-4 text-xs text-gray-500 cursor-pointer dark:text-gray-300">{c.planning_date_begin}</td>
                                        <td className="whitespace-wrap py-4 pl-4 pr-4 text-xs font-medium text-gray-500 cursor-pointer dark:text-gray-300">{c.prenomTECH} {c.nomTECH}</td>
                                        <td className="whitespace-wrap py-4 pl-4 pr-4 text-xs text-gray-500 cursor-pointer dark:text-gray-300">{c.site}</td>
                                        <td className="whitespace-wrap py-4 pl-4 pr-4 text-xs text-gray-500 cursor-pointer dark:text-gray-300">{c.adresse}</td>
                                        <td className="whitespace-wrap py-4 pl-4 pr-4 text-xs text-gray-500 cursor-pointer dark:text-gray-300">{c.ville}</td>
                                        <td className="whitespace-wrap py-4 pl-4 pr-4 text-xs text-gray-500 cursor-pointer dark:text-gray-300">{c.cp_site}</td>
                                        <td className="whitespace-wrap py-4 pl-4 pr-4 text-xs text-gray-500 cursor-pointer">
                                            {
                                                props.isLoadingDL ?
                                                    <Loader type="spin" color="orange"/>
                                                    :
                                                    <>
                                                        <svg xmlns="http://www.w3.org/2000/svg"
                                                             className="h-6 w-6 m-auto" fill="none"
                                                             viewBox="0 0 24 24" stroke="orange"
                                                             stroke-width="2" data-tip data-for='duplicata'
                                                             onClick={(e) => {
                                                                 e.preventDefault()
                                                                 e.stopPropagation()
                                                                 props.setIsLoadingDL(true)
                                                                 props.dlFolderCloture(c.id, c.login_intervention);
                                                             }}>
                                                            <path stroke-linecap="round" stroke-linejoin="round"
                                                                  d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"/>
                                                        </svg>
                                                        <ReactTooltip id='duplicata' type='light'
                                                                      effect='solid'>
                                                            <span>Télécharger le dossier de clôture</span>
                                                        </ReactTooltip>
                                                    </>
                                            }
                                        </td>
                                        <td className="whitespace-wrap py-4 pl-4 pr-4 text-xs text-gray-500 cursor-pointer dark:text-gray-300 text-center">
                                    <span className={
                                        c.statut === "11" || c.statut === "4" ?
                                            "inline-block py-1 px-2  dark:text-gray-300 border-2   border-green-500 rounded-full"
                                            :
                                            c.statut === "5" ?
                                                "inline-block py-1 px-2 dark:text-gray-300 border-2 border-violet-500 rounded-full"
                                                :
                                                c.statut === "1" ?
                                                    "inline-block py-1 px-2 dark:text-gray-300 border-2  border-orange-500 rounded-full"
                                                    :
                                                    "inline-block py-1 px-2  dark:text-gray-300 border-2   border-red-500 rounded-full"
                                    }>{c.libelle_statut}</span>
                                        </td>
                                    </tr>
                                ))
                            }
                            </tbody>
                        </table>
                    </div>
                    <div
                        className="hidden md:flex md:w-48 md:flex-col md:fixed fixed bottom-0 left-0 min-w-12rem">
                        <div className="max-w-7xl">
                            <div className="p-2 bg-blue-600 shadow-lg sm:p-3">
                                <div className="flex items-center justify-center flex-wrap">
                                    <div
                                        className="order-3 mt-2 flex-shrink-0 w-full sm:order-2 sm:mt-0 sm:w-auto font-medium text-white">
                                        <p>Interventions : {props.nbInter}</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
)

}

I removed all props and functions, only the css is important for the problem..

So to summarize, how to make the table take all the remaining height and keep the ratio when the page resizes, because currently when I resize, the "end" of the table is no longer visible.. I don't know if I was clear enough.

Image : [Table without resize][1] [Table after resize][2] [1]: https://i.stack.imgur.com/Yjh3E.png [2]: https://i.stack.imgur.com/A5DTl.png