Compare commits
No commits in common. "448186c0256959d8839cf2376d2856f7cd5cc3d1" and "cd6e47903bdc6888365aa0070eae525e977f4557" have entirely different histories.
448186c025
...
cd6e47903b
|
|
@ -2,7 +2,6 @@ import React, { useState, useEffect, useRef } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useFilterStateState } from "../../zustand/Filter";
|
import { useFilterStateState } from "../../zustand/Filter";
|
||||||
import { useDebounce } from "../../utils/useDebounce";
|
import { useDebounce } from "../../utils/useDebounce";
|
||||||
import { PaginationParams } from "../../api/utils/PaginationParams";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
|
|
@ -15,16 +14,12 @@ const SearchField: React.FC<Props> = ({ placeholder, searchBy }) => {
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
const { setFilter,Filter } = useFilterStateState();
|
const { setFilter,Filter } = useFilterStateState();
|
||||||
const { page } = PaginationParams(location);
|
|
||||||
|
|
||||||
const handleInputChange = (value: string) => {
|
const handleInputChange = (value: string) => {
|
||||||
setSearchQuery(value);
|
setSearchQuery(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleInputChangeWithDebounce = useDebounce((value: string) => {
|
const handleInputChangeWithDebounce = useDebounce((value: string) => {
|
||||||
if(Number(page) > 1){
|
|
||||||
|
|
||||||
}
|
|
||||||
setFilter({
|
setFilter({
|
||||||
[searchBy]: value,
|
[searchBy]: value,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,20 +3,13 @@ import { useTranslation } from "react-i18next";
|
||||||
import { Divider, Select } from "antd";
|
import { Divider, Select } from "antd";
|
||||||
import usePagination from "../../Layout/Dashboard/usePagination";
|
import usePagination from "../../Layout/Dashboard/usePagination";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useFilterStateState } from "../../zustand/Filter";
|
|
||||||
|
|
||||||
const PaginationColumn = () => {
|
const PaginationColumn = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { Filter ,setFilter } = useFilterStateState();
|
|
||||||
|
|
||||||
|
|
||||||
const handleChange = (value: string) => {
|
const handleChange = (value: string) => {
|
||||||
navigate(`?per_page=${value}`);
|
navigate(`?per_page=${value}`);
|
||||||
|
|
||||||
setFilter({
|
|
||||||
per_page:value
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,9 @@ const PageTitleComponent = () => {
|
||||||
return (
|
return (
|
||||||
<div className='PageTitle'>
|
<div className='PageTitle'>
|
||||||
{(Array.isArray(PageTitle) ? PageTitle : [])?.map((item,index)=>{
|
{(Array.isArray(PageTitle) ? PageTitle : [])?.map((item,index)=>{
|
||||||
const lastItem = PageTitle?.length - 1 === index
|
|
||||||
return (
|
return (
|
||||||
<div key={index} className={`PageTitleItems ${lastItem ? "PageTitleLastItem" : ""} `} onClick={()=>handleNavigate(item?.path)}>
|
<div key={index} className='PageTitleItems' onClick={()=>handleNavigate(item?.path)}>
|
||||||
{item?.name} {lastItem ? "" : "/"}
|
{item?.name} /
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useLocation, useNavigate } from "react-router-dom";
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
import { PaginationAntd, PaginationMeta } from "../../types/Table";
|
import { PaginationAntd, PaginationMeta } from "../../types/Table";
|
||||||
import { useFilterStateState } from "../../zustand/Filter";
|
|
||||||
|
|
||||||
interface Data {
|
interface Data {
|
||||||
meta: PaginationMeta;
|
meta: PaginationMeta;
|
||||||
|
|
@ -10,7 +9,6 @@ interface Data {
|
||||||
const usePagination = (data: Data) => {
|
const usePagination = (data: Data) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { Filter ,setFilter } = useFilterStateState();
|
|
||||||
|
|
||||||
const [pagination, setPagination] = useState<PaginationAntd>({
|
const [pagination, setPagination] = useState<PaginationAntd>({
|
||||||
current: data?.meta?.current_page || 1,
|
current: data?.meta?.current_page || 1,
|
||||||
|
|
@ -29,11 +27,7 @@ const usePagination = (data: Data) => {
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
const handlePageChange = (page: number) => {
|
const handlePageChange = (page: number) => {
|
||||||
// navigate(`?page=${page}`);
|
navigate(`?page=${page}`);
|
||||||
setFilter({
|
|
||||||
...Filter,
|
|
||||||
page:page
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return { pagination, handlePageChange };
|
return { pagination, handlePageChange };
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ const App: React.FC = () => {
|
||||||
console.log(filterState,"filterState");
|
console.log(filterState,"filterState");
|
||||||
|
|
||||||
const response = useGetAllQuestion({
|
const response = useGetAllQuestion({
|
||||||
nullable_parent:"null",
|
|
||||||
pagination: true,
|
pagination: true,
|
||||||
...filterState,
|
...filterState,
|
||||||
content:Filter?.content,
|
content:Filter?.content,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ const App: React.FC = () => {
|
||||||
const content = Filter?.content ;
|
const content = Filter?.content ;
|
||||||
|
|
||||||
const response = useGetAllQuestion({
|
const response = useGetAllQuestion({
|
||||||
nullable_parent:"null",
|
|
||||||
lessonsIds: [lesson_id],
|
lessonsIds: [lesson_id],
|
||||||
pagination: true,
|
pagination: true,
|
||||||
...filterState,
|
...filterState,
|
||||||
|
|
|
||||||
|
|
@ -48,18 +48,16 @@
|
||||||
outline: none;
|
outline: none;
|
||||||
border: none;
|
border: none;
|
||||||
min-width: 120px;
|
min-width: 120px;
|
||||||
border-radius: 6px;
|
border-radius: 10px;
|
||||||
padding: 6px 10px;
|
padding: 10px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
background: var(--primary);
|
background: var(--primary);
|
||||||
color: var(--white);
|
color: var(--white);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 7px;
|
gap: 5px;
|
||||||
font-size: 14px;
|
|
||||||
svg {
|
svg {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,7 @@
|
||||||
.PageTitle{
|
.PageTitle{
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
margin-block: 10px;
|
|
||||||
.PageTitleItems{
|
.PageTitleItems{
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: #6A7287;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.PageTitleLastItem{
|
|
||||||
color: #202C4B !important;
|
|
||||||
}
|
}
|
||||||
|
|
@ -3,7 +3,6 @@ import useAxios from "./useAxios";
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
import { PaginationParams } from "../utils/PaginationParams";
|
import { PaginationParams } from "../utils/PaginationParams";
|
||||||
import { filterParams } from "../utils/filterParams";
|
import { filterParams } from "../utils/filterParams";
|
||||||
import { useFilterStateState } from "../../zustand/Filter";
|
|
||||||
function useGetQuery(
|
function useGetQuery(
|
||||||
KEY: string | string[],
|
KEY: string | string[],
|
||||||
url: string,
|
url: string,
|
||||||
|
|
@ -14,11 +13,10 @@ function useGetQuery(
|
||||||
const { show, pagination, ...remainingParams } = params;
|
const { show, pagination, ...remainingParams } = params;
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { Filter ,setFilter } = useFilterStateState();
|
|
||||||
const page = Filter?.page ;
|
const { page, per_page } = PaginationParams(location);
|
||||||
const per_page = Filter?.per_page ;
|
|
||||||
// const { per_page } = PaginationParams(location);
|
|
||||||
|
|
||||||
|
console.log(remainingParams)
|
||||||
const paramToSend = pagination
|
const paramToSend = pagination
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user