cashflowy / switchless

component library using mui/joy
2 stars 0 forks source link

Pagination #6

Open Fahimansari opened 1 month ago

Fahimansari commented 1 month ago

@JOEL PETER SONY Pagination Component spec

Pagination

The below code is something that I am using right now. You can probably start from it and make sure that it's working correctly as an isolated component

'use client';
import * as React from 'react';
import { Pagination as MUIPagination } from "@mui/material";

export default function Pagination({count=1, disabled=false}){

  const handlePageChange = (event, page) => {
    const current = new URLSearchParams(Array.from(searchParams.entries()));
    current.set('page', page.toString());
    const search = current.toString();
    const query = search ? `?${search}` : '';
    router.replace(`${window.location.pathname}${query}`);
  };

  return(
    <MUIPagination count={count}
              variant='outlined'
              shape='rounded'
              onChange={handlePageChange}
              disabled={disabled} />
  )
}

https://www.loom.com/share/fc96d378fae1499c81b6a25ed5713a13?focus_title=1&muted=1&from_recorder=1

Pete-Sony commented 3 weeks ago

In brief This is a pagination component

Fahimansari commented 3 weeks ago

@Pete-Sony Yes