Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

Add RecordsPerPageSelector and minor refactor

Khuram Niazbc65599f8352
diff --git a/__tests__/TasksContainer.spec.tsx b/__tests__/TasksContainer.spec.tsx
index 531846a..e206bf2 100644
--- a/__tests__/TasksContainer.spec.tsx
+++ b/__tests__/TasksContainer.spec.tsx
@@ -175,7 +175,7 @@ describe("TasksContainer Component", () => {
render(<TasksContainer activityTypes={mockActivityTypes} />);
await waitFor(() => {
- expect(getTasksList).toHaveBeenCalledWith(1, 10, undefined, [
+ expect(getTasksList).toHaveBeenCalledWith(1, 25, undefined, [
"in-progress",
"needs-attention",
]);
@@ -475,7 +475,7 @@ describe("TasksContainer Component", () => {
it("should apply activity type filter", async () => {
await waitFor(() => {
- expect(getTasksList).toHaveBeenCalledWith(1, 10, "type-1", [
+ expect(getTasksList).toHaveBeenCalledWith(1, 25, "type-1", [
"in-progress",
"needs-attention",
]);
@@ -494,7 +494,7 @@ describe("TasksContainer Component", () => {
await user.click(inProgressCheckbox);
await waitFor(() => {
- expect(getTasksList).toHaveBeenCalledWith(1, 10, "type-1", [
+ expect(getTasksList).toHaveBeenCalledWith(1, 25, "type-1", [
"needs-attention",
]);
});
@@ -557,7 +557,7 @@ describe("TasksContainer Component", () => {
await user.click(loadMoreButton);
await waitFor(() => {
- expect(getTasksList).toHaveBeenCalledWith(2, 10, undefined, [
+ expect(getTasksList).toHaveBeenCalledWith(2, 25, undefined, [
"in-progress",
"needs-attention",
]);
diff --git a/__tests__/TasksPageClient.spec.tsx b/__tests__/TasksPageClient.spec.tsx
index 072e446..c40ba74 100644
--- a/__tests__/TasksPageClient.spec.tsx
+++ b/__tests__/TasksPageClient.spec.tsx
@@ -377,7 +377,7 @@ describe("TasksPageClient Component", () => {
await waitFor(() => {
expect(getTasksList).toHaveBeenCalledWith(
1,
- 10,
+ 25,
"type-1",
expect.any(Array)
);
@@ -408,7 +408,7 @@ describe("TasksPageClient Component", () => {
await waitFor(() => {
expect(getTasksList).toHaveBeenCalledWith(
1,
- 10,
+ 25,
"type-1",
expect.any(Array)
);
@@ -424,7 +424,7 @@ describe("TasksPageClient Component", () => {
await waitFor(() => {
expect(getTasksList).toHaveBeenCalledWith(
1,
- 10,
+ 25,
undefined,
expect.any(Array)
);
diff --git a/__tests__/task.actions.spec.ts b/__tests__/task.actions.spec.ts
index 501ea0b..09031c9 100644
--- a/__tests__/task.actions.spec.ts
+++ b/__tests__/task.actions.spec.ts
@@ -90,7 +90,7 @@ describe("taskActions", () => {
},
orderBy: [{ priority: "desc" }, { createdAt: "desc" }, { updatedAt: "desc" }],
skip: 0,
- take: 10,
+ take: 25,
});
expect(prisma.task.count).toHaveBeenCalledWith({
where: { userId: mockUser.id },
diff --git a/src/actions/activity.actions.ts b/src/actions/activity.actions.ts
index 93e8dfc..1511d79 100644
--- a/src/actions/activity.actions.ts
+++ b/src/actions/activity.actions.ts
@@ -4,6 +4,7 @@ import { handleError } from "@/lib/utils";
import { Activity } from "@/models/activity.model";
import { AddActivityFormSchema } from "@/models/addActivityForm.schema";
import { getCurrentUser } from "@/utils/user.utils";
+import { APP_CONSTANTS } from "@/lib/constants";
import { z } from "zod";
export const getAllActivityTypes = async (): Promise<any | undefined> => {
@@ -54,7 +55,7 @@ export const createActivityType = async (
export const getActivitiesList = async (
page: number = 1,
- limit: number = 10
+ limit: number = APP_CONSTANTS.RECORDS_PER_PAGE
): Promise<any | undefined> => {
try {
const user = await getCurrentUser();
diff --git a/src/actions/company.actions.ts b/src/actions/company.actions.ts
index 88cc520..5d139b0 100644
--- a/src/actions/company.actions.ts
+++ b/src/actions/company.actions.ts
@@ -3,12 +3,13 @@ import prisma from "@/lib/db";
import { handleError } from "@/lib/utils";
import { AddCompanyFormSchema } from "@/models/addCompanyForm.schema";
import { getCurrentUser } from "@/utils/user.utils";
+import { APP_CONSTANTS } from "@/lib/constants";
import { revalidatePath } from "next/cache";
import { z } from "zod";
export const getCompanyList = async (
- page = 1,
- limit = 10,
+ page: number = 1,
+ limit: number = APP_CONSTANTS.RECORDS_PER_PAGE,
countBy?: string,
): Promise<any | undefined> => {
try {
diff --git a/src/actions/job.actions.ts b/src/actions/job.actions.ts
index 51829b2..e9d3795 100644
--- a/src/actions/job.actions.ts
+++ b/src/actions/job.actions.ts
@@ -4,6 +4,7 @@ import { handleError } from "@/lib/utils";
import { AddJobFormSchema } from "@/models/addJobForm.schema";
import { JOB_TYPES, JobStatus } from "@/models/job.model";
import { getCurrentUser } from "@/utils/user.utils";
+import { APP_CONSTANTS } from "@/lib/constants";
import { revalidatePath } from "next/cache";
import { z } from "zod";
@@ -28,8 +29,8 @@ export const getJobSourceList = async (): Promise<any | undefined> => {
};
export const getJobsList = async (
- page = 1,
- limit = 10,
+ page: number = 1,
+ limit: number = APP_CONSTANTS.RECORDS_PER_PAGE,
filter?: string
): Promise<any | undefined> => {
try {
diff --git a/src/actions/jobLocation.actions.ts b/src/actions/jobLocation.actions.ts
index ee0c556..52f9e7b 100644
--- a/src/actions/jobLocation.actions.ts
+++ b/src/actions/jobLocation.actions.ts
@@ -2,6 +2,7 @@
import prisma from "@/lib/db";
import { handleError } from "@/lib/utils";
import { getCurrentUser } from "@/utils/user.utils";
+import { APP_CONSTANTS } from "@/lib/constants";
export const getAllJobLocations = async (): Promise<any | undefined> => {
try {
@@ -14,8 +15,8 @@ export const getAllJobLocations = async (): Promise<any | undefined> => {
};
export const getJobLocationsList = async (
- page = 1,
- limit = 10,
+ page: number = 1,
+ limit: number = APP_CONSTANTS.RECORDS_PER_PAGE,
countBy?: string
): Promise<any | undefined> => {
try {
diff --git a/src/actions/jobtitle.actions.ts b/src/actions/jobtitle.actions.ts
index e01011e..ea2480a 100644
--- a/src/actions/jobtitle.actions.ts
+++ b/src/actions/jobtitle.actions.ts
@@ -2,6 +2,7 @@
import prisma from "@/lib/db";
import { handleError } from "@/lib/utils";
import { getCurrentUser } from "@/utils/user.utils";
+import { APP_CONSTANTS } from "@/lib/constants";
export const getAllJobTitles = async (): Promise<any | undefined> => {
try {
@@ -22,8 +23,8 @@ export const getAllJobTitles = async (): Promise<any | undefined> => {
};
export const getJobTitleList = async (
- page = 1,
- limit = 10,
+ page: number = 1,
+ limit: number = APP_CONSTANTS.RECORDS_PER_PAGE,
countBy?: string
): Promise<any | undefined> => {
try {
diff --git a/src/actions/profile.actions.ts b/src/actions/profile.actions.ts
index 06b351f..5ab49dd 100644
--- a/src/actions/profile.actions.ts
+++ b/src/actions/profile.actions.ts
@@ -8,6 +8,7 @@ import { AddSummarySectionFormSchema } from "@/models/addSummaryForm.schema";
import { CreateResumeFormSchema } from "@/models/createResumeForm.schema";
import { ResumeSection, SectionType, Summary } from "@/models/profile.model";
import { getCurrentUser } from "@/utils/user.utils";
+import { APP_CONSTANTS } from "@/lib/constants";
import { revalidatePath } from "next/cache";
import { z } from "zod";
import path from "path";
@@ -15,8 +16,8 @@ import fs from "fs";
import { writeFile } from "fs/promises";
export const getResumeList = async (
- page = 1,
- limit = 15
+ page: number = 1,
+ limit: number = APP_CONSTANTS.RECORDS_PER_PAGE
): Promise<any | undefined> => {
try {
const user = await getCurrentUser();
diff --git a/src/actions/task.actions.ts b/src/actions/task.actions.ts
index da4aad8..8a2b728 100644
--- a/src/actions/task.actions.ts
+++ b/src/actions/task.actions.ts
@@ -4,11 +4,12 @@ import { handleError } from "@/lib/utils";
import { Task, TaskStatus } from "@/models/task.model";
import { AddTaskFormSchema } from "@/models/addTaskForm.schema";
import { getCurrentUser } from "@/utils/user.utils";
+import { APP_CONSTANTS } from "@/lib/constants";
import { z } from "zod";
export const getTasksList = async (
page: number = 1,
- limit: number = 10,
+ limit: number = APP_CONSTANTS.RECORDS_PER_PAGE,
filter?: string,
statusFilter?: TaskStatus[]
): Promise<any | undefined> => {
diff --git a/src/components/RecordsCount.tsx b/src/components/RecordsCount.tsx
new file mode 100644
index 0000000..7618ff1
--- /dev/null
+++ b/src/components/RecordsCount.tsx
@@ -0,0 +1,24 @@
+"use client";
+
+type RecordsCountProps = {
+ count: number;
+ total: number;
+ label?: string;
+};
+
+export function RecordsCount({
+ count,
+ total,
+ label = "records",
+}: RecordsCountProps) {
+ return (
+ <div className="text-xs text-muted-foreground">
+ Showing{" "}
+ <strong>
+ 1 to {count}
+ </strong>{" "}
+ of
+ <strong> {total}</strong> {label}
+ </div>
+ );
+}
diff --git a/src/components/RecordsPerPageSelector.tsx b/src/components/RecordsPerPageSelector.tsx
new file mode 100644
index 0000000..9bd5173
--- /dev/null
+++ b/src/components/RecordsPerPageSelector.tsx
@@ -0,0 +1,40 @@
+"use client";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "./ui/select";
+import { APP_CONSTANTS } from "@/lib/constants";
+
+type RecordsPerPageSelectorProps = {
+ value: number;
+ onChange: (value: number) => void;
+};
+
+export function RecordsPerPageSelector({
+ value,
+ onChange,
+}: RecordsPerPageSelectorProps) {
+ return (
+ <div className="flex items-center gap-2">
+ <span className="text-xs text-muted-foreground">Records per page</span>
+ <Select
+ value={String(value)}
+ onValueChange={(val) => onChange(Number(val))}
+ >
+ <SelectTrigger className="w-[70px] h-8">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {APP_CONSTANTS.RECORDS_PER_PAGE_OPTIONS.map((option) => (
+ <SelectItem key={option} value={String(option)}>
+ {option}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </div>
+ );
+}
diff --git a/src/components/activities/ActivitiesContainer.tsx b/src/components/activities/ActivitiesContainer.tsx
index d3ffacb..b30494c 100644
--- a/src/components/activities/ActivitiesContainer.tsx
+++ b/src/components/activities/ActivitiesContainer.tsx
@@ -24,6 +24,8 @@ import Loading from "../Loading";
import { ActivityBanner } from "./ActivityBanner";
import { differenceInMinutes } from "date-fns";
import { APP_CONSTANTS } from "@/lib/constants";
+import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
+import { RecordsCount } from "../RecordsCount";
function ActivitiesContainer() {
const [activityFormOpen, setActivityFormOpen] = useState<boolean>(false);
@@ -34,6 +36,9 @@ function ActivitiesContainer() {
const [page, setPage] = useState<number>(1);
const [totalActivities, setTotalActivities] = useState<number>(0);
const [loading, setLoading] = useState(false);
+ const [recordsPerPage, setRecordsPerPage] = useState<number>(
+ APP_CONSTANTS.RECORDS_PER_PAGE,
+ );
const closeActivityForm = () => setActivityFormOpen(false);
@@ -46,10 +51,10 @@ function ActivitiesContainer() {
setTimeElapsed(0);
}, []);
- const loadActivities = useCallback(async (page: number) => {
+ const loadActivities = useCallback(async (page: number, limit: number) => {
setLoading(true);
try {
- const { data, success, message, total } = await getActivitiesList(page);
+ const { data, success, message, total } = await getActivitiesList(page, limit);
if (success) {
setActivitiesList((prev) => (page === 1 ? data : [...prev, ...data]));
setTotalActivities(total);
@@ -73,8 +78,8 @@ function ActivitiesContainer() {
}, []);
const reloadActivities = useCallback(async () => {
- await loadActivities(1);
- }, [loadActivities]);
+ await loadActivities(1, recordsPerPage);
+ }, [loadActivities, recordsPerPage]);
const stopActivity = useCallback(
async (autoStop: boolean = false) => {
@@ -174,15 +179,14 @@ function ActivitiesContainer() {
useEffect(() => {
const init = async () => {
- await Promise.all([loadActivities(1), fetchActiveActivity()]);
+ await Promise.all([loadActivities(1, recordsPerPage), fetchActiveActivity()]);
};
init();
return () => {
stopTimer(); // Cleanup the timer on unmount
};
- // Need to run this once, so no dependency trigger
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
+ }, [recordsPerPage]);
useEffect(() => {
if (currentActivity) {
@@ -240,13 +244,18 @@ function ActivitiesContainer() {
onStartActivity={startActivity}
activityExist={Boolean(currentActivity)}
/>
- <div className="text-xs text-muted-foreground">
- Showing{" "}
- <strong>
- {1} to {activitiesList.length}
- </strong>{" "}
- of
- <strong> {totalActivities}</strong> activities
+ <div className="flex items-center justify-between mt-4">
+ <RecordsCount
+ count={activitiesList.length}
+ total={totalActivities}
+ label="activities"
+ />
+ {totalActivities > APP_CONSTANTS.RECORDS_PER_PAGE && (
+ <RecordsPerPageSelector
+ value={recordsPerPage}
+ onChange={setRecordsPerPage}
+ />
+ )}
</div>
</>
)}
@@ -255,7 +264,7 @@ function ActivitiesContainer() {
<Button
size="sm"
variant="outline"
- onClick={() => loadActivities(page + 1)}
+ onClick={() => loadActivities(page + 1, recordsPerPage)}
disabled={loading}
className="btn btn-primary"
>
diff --git a/src/components/admin/CompaniesContainer.tsx b/src/components/admin/CompaniesContainer.tsx
index eff23f2..9e2a77a 100644
--- a/src/components/admin/CompaniesContainer.tsx
+++ b/src/components/admin/CompaniesContainer.tsx
@@ -8,6 +8,8 @@ import { getCompanyById, getCompanyList } from "@/actions/company.actions";
import { APP_CONSTANTS } from "@/lib/constants";
import Loading from "../Loading";
import { Button } from "../ui/button";
+import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
+import { RecordsCount } from "../RecordsCount";
function CompaniesContainer() {
const [companies, setCompanies] = useState<Company[]>([]);
@@ -16,8 +18,9 @@ function CompaniesContainer() {
const [dialogOpen, setDialogOpen] = useState(false);
const [editCompany, setEditCompany] = useState(null);
const [loading, setLoading] = useState<boolean>(false);
-
- const recordsPerPage = APP_CONSTANTS.RECORDS_PER_PAGE;
+ const [recordsPerPage, setRecordsPerPage] = useState<number>(
+ APP_CONSTANTS.RECORDS_PER_PAGE,
+ );
const loadCompanies = useCallback(
async (page: number) => {
@@ -47,7 +50,7 @@ function CompaniesContainer() {
useEffect(() => {
(async () => await loadCompanies(1))();
- }, [loadCompanies]);
+ }, [loadCompanies, recordsPerPage]);
const onEditCompany = async (companyId: string) => {
const company = await getCompanyById(companyId);
@@ -82,13 +85,18 @@ function CompaniesContainer() {
reloadCompanies={reloadCompanies}
editCompany={onEditCompany}
/>
- <div className="text-xs text-muted-foreground">
- Showing{" "}
- <strong>
- {1} to {companies.length}
- </strong>{" "}
- of
- <strong> {totalCompanies}</strong> companies
+ <div className="flex items-center justify-between mt-4">
+ <RecordsCount
+ count={companies.length}
+ total={totalCompanies}
+ label="companies"
+ />
+ {totalCompanies > APP_CONSTANTS.RECORDS_PER_PAGE && (
+ <RecordsPerPageSelector
+ value={recordsPerPage}
+ onChange={setRecordsPerPage}
+ />
+ )}
</div>
</>
)}
diff --git a/src/components/admin/JobLocationsContainer.tsx b/src/components/admin/JobLocationsContainer.tsx
index d5fc0ad..fd4dfa2 100644
--- a/src/components/admin/JobLocationsContainer.tsx
+++ b/src/components/admin/JobLocationsContainer.tsx
@@ -7,14 +7,17 @@ import JobLocationsTable from "./JobLocationsTable";
import { getJobLocationsList } from "@/actions/jobLocation.actions";
import Loading from "../Loading";
import { Button } from "../ui/button";
+import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
+import { RecordsCount } from "../RecordsCount";
function JobLocationsContainer() {
const [locations, setLocations] = useState<JobTitle[]>([]);
const [totalJobLocations, setTotalJobLocations] = useState<number>(0);
const [page, setPage] = useState<number>(1);
const [loading, setLoading] = useState<boolean>(false);
-
- const recordsPerPage = APP_CONSTANTS.RECORDS_PER_PAGE;
+ const [recordsPerPage, setRecordsPerPage] = useState<number>(
+ APP_CONSTANTS.RECORDS_PER_PAGE,
+ );
const loadJobLocations = useCallback(
async (page: number) => {
@@ -40,7 +43,7 @@ function JobLocationsContainer() {
useEffect(() => {
(async () => await loadJobLocations(1))();
- }, [loadJobLocations]);
+ }, [loadJobLocations, recordsPerPage]);
return (
<>
@@ -62,13 +65,18 @@ function JobLocationsContainer() {
jobLocations={locations}
reloadJobLocations={reloadJobLocations}
/>
- <div className="text-xs text-muted-foreground">
- Showing{" "}
- <strong>
- {1} to {locations.length}
- </strong>{" "}
- of
- <strong> {totalJobLocations}</strong> job locations
+ <div className="flex items-center justify-between mt-4">
+ <RecordsCount
+ count={locations.length}
+ total={totalJobLocations}
+ label="job locations"
+ />
+ {totalJobLocations > APP_CONSTANTS.RECORDS_PER_PAGE && (
+ <RecordsPerPageSelector
+ value={recordsPerPage}
+ onChange={setRecordsPerPage}
+ />
+ )}
</div>
</>
)}
diff --git a/src/components/admin/JobTitlesContainer.tsx b/src/components/admin/JobTitlesContainer.tsx
index 6d04c37..14d1876 100644
--- a/src/components/admin/JobTitlesContainer.tsx
+++ b/src/components/admin/JobTitlesContainer.tsx
@@ -7,14 +7,17 @@ import JobTitlesTable from "./JobTitlesTable";
import { getJobTitleList } from "@/actions/jobtitle.actions";
import Loading from "../Loading";
import { Button } from "../ui/button";
+import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
+import { RecordsCount } from "../RecordsCount";
function JobTitlesContainer() {
const [titles, setTitles] = useState<JobTitle[]>([]);
const [totalJobTitles, setTotalJobTitles] = useState<number>(0);
const [page, setPage] = useState<number>(1);
const [loading, setLoading] = useState<boolean>(false);
-
- const recordsPerPage = APP_CONSTANTS.RECORDS_PER_PAGE;
+ const [recordsPerPage, setRecordsPerPage] = useState<number>(
+ APP_CONSTANTS.RECORDS_PER_PAGE,
+ );
const loadJobTitles = useCallback(
async (page: number) => {
@@ -40,7 +43,7 @@ function JobTitlesContainer() {
useEffect(() => {
(async () => await loadJobTitles(1))();
- }, [loadJobTitles]);
+ }, [loadJobTitles, recordsPerPage]);
return (
<>
@@ -62,13 +65,18 @@ function JobTitlesContainer() {
jobTitles={titles}
reloadJobTitles={reloadJobTitles}
/>
- <div className="text-xs text-muted-foreground">
- Showing{" "}
- <strong>
- {1} to {titles.length}
- </strong>{" "}
- of
- <strong> {totalJobTitles}</strong> job titles
+ <div className="flex items-center justify-between mt-4">
+ <RecordsCount
+ count={titles.length}
+ total={totalJobTitles}
+ label="job titles"
+ />
+ {totalJobTitles > APP_CONSTANTS.RECORDS_PER_PAGE && (
+ <RecordsPerPageSelector
+ value={recordsPerPage}
+ onChange={setRecordsPerPage}
+ />
+ )}
</div>
</>
)}
diff --git a/src/components/myjobs/JobsContainer.tsx b/src/components/myjobs/JobsContainer.tsx
index 1f7fc4e..3e0ca32 100644
--- a/src/components/myjobs/JobsContainer.tsx
+++ b/src/components/myjobs/JobsContainer.tsx
@@ -40,6 +40,8 @@ import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { AddJob } from "./AddJob";
import MyJobsTable from "./MyJobsTable";
import { format } from "date-fns";
+import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
+import { RecordsCount } from "../RecordsCount";
type MyJobsProps = {
statuses: JobStatus[];
@@ -74,8 +76,11 @@ function JobsContainer({
const [filterKey, setFilterKey] = useState<string>();
const [editJob, setEditJob] = useState(null);
const [loading, setLoading] = useState(false);
+ const [recordsPerPage, setRecordsPerPage] = useState<number>(
+ APP_CONSTANTS.RECORDS_PER_PAGE,
+ );
- const jobsPerPage = APP_CONSTANTS.RECORDS_PER_PAGE;
+ const jobsPerPage = recordsPerPage;
const loadJobs = useCallback(
async (page: number, filter?: string) => {
@@ -164,7 +169,7 @@ function JobsContainer({
useEffect(() => {
(async () => await loadJobs(1))();
- }, [loadJobs]);
+ }, [loadJobs, recordsPerPage]);
const onFilterChange = (filterBy: string) => {
if (filterBy === "none") {
@@ -268,13 +273,18 @@ function JobsContainer({
editJob={onEditJob}
onChangeJobStatus={onChangeJobStatus}
/>
- <div className="text-xs text-muted-foreground">
- Showing{" "}
- <strong>
- {1} to {jobs.length}
- </strong>{" "}
- of
- <strong> {totalJobs}</strong> jobs
+ <div className="flex items-center justify-between mt-4">
+ <RecordsCount
+ count={jobs.length}
+ total={totalJobs}
+ label="jobs"
+ />
+ {totalJobs > APP_CONSTANTS.RECORDS_PER_PAGE && (
+ <RecordsPerPageSelector
+ value={recordsPerPage}
+ onChange={setRecordsPerPage}
+ />
+ )}
</div>
</>
)}
diff --git a/src/components/profile/ProfileContainer.tsx b/src/components/profile/ProfileContainer.tsx
index 842363c..41d7baa 100644
--- a/src/components/profile/ProfileContainer.tsx
+++ b/src/components/profile/ProfileContainer.tsx
@@ -10,10 +10,10 @@ import ResumeTable from "./ResumeTable";
import { toast } from "../ui/use-toast";
import { PlusCircle } from "lucide-react";
import { Button } from "../ui/button";
+import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
+import { RecordsCount } from "../RecordsCount";
const ProfileContainer = () => {
- const recordsPerPage = APP_CONSTANTS.RECORDS_PER_PAGE;
-
const [resumes, setResumes] = useState<Resume[]>([]);
const [resumeDialogOpen, setResumeDialogOpen] = useState(false);
@@ -21,6 +21,9 @@ const ProfileContainer = () => {
const [totalResumes, setTotalResumes] = useState<number>(0);
const [page, setPage] = useState<number>(1);
const [loading, setLoading] = useState(false);
+ const [recordsPerPage, setRecordsPerPage] = useState<number>(
+ APP_CONSTANTS.RECORDS_PER_PAGE,
+ );
const loadResumes = useCallback(
async (page: number) => {
@@ -52,7 +55,7 @@ const ProfileContainer = () => {
useEffect(() => {
(async () => await loadResumes(1))();
- }, [loadResumes]);
+ }, [loadResumes, recordsPerPage]);
const createResume = () => {
setResumeToEdit(null);
@@ -105,13 +108,18 @@ const ProfileContainer = () => {
editResume={onEditResume}
reloadResumes={reloadResumes}
/>
- <div className="text-xs text-muted-foreground">
- Showing{" "}
- <strong>
- {1} to {resumes.length}
- </strong>{" "}
- of
- <strong> {totalResumes}</strong> resumes
+ <div className="flex items-center justify-between mt-4">
+ <RecordsCount
+ count={resumes.length}
+ total={totalResumes}
+ label="resumes"
+ />
+ {totalResumes > APP_CONSTANTS.RECORDS_PER_PAGE && (
+ <RecordsPerPageSelector
+ value={recordsPerPage}
+ onChange={setRecordsPerPage}
+ />
+ )}
</div>
</>
)}
diff --git a/src/components/tasks/TasksContainer.tsx b/src/components/tasks/TasksContainer.tsx
index 2476da5..5e0f0de 100644
--- a/src/components/tasks/TasksContainer.tsx
+++ b/src/components/tasks/TasksContainer.tsx
@@ -28,6 +28,8 @@ import {
SelectTrigger,
SelectValue,
} from "../ui/select";
+import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
+import { RecordsCount } from "../RecordsCount";
import {
DropdownMenu,
DropdownMenuCheckboxItem,
@@ -71,8 +73,11 @@ function TasksContainer({
const [statusFilter, setStatusFilter] = useState<TaskStatus[]>(
DEFAULT_STATUS_FILTER,
);
+ const [recordsPerPage, setRecordsPerPage] = useState<number>(
+ APP_CONSTANTS.RECORDS_PER_PAGE,
+ );
- const tasksPerPage = APP_CONSTANTS.RECORDS_PER_PAGE;
+ const tasksPerPage = recordsPerPage;
const loadTasks = useCallback(
async (pageNum: number, filter?: string, statuses?: TaskStatus[]) => {
@@ -187,7 +192,7 @@ function TasksContainer({
useEffect(() => {
(async () => await loadTasks(1, filterKey, statusFilter))();
- }, [loadTasks, filterKey, statusFilter]);
+ }, [loadTasks, filterKey, statusFilter, recordsPerPage]);
const onGroupByChange = (value: string) => {
setGroupBy(
@@ -284,13 +289,18 @@ function TasksContainer({
onStartActivity={onStartActivity}
groupBy={groupBy}
/>
- <div className="text-xs text-muted-foreground mt-4">
- Showing{" "}
- <strong>
- {1} to {tasks.length}
- </strong>{" "}
- of
- <strong> {totalTasks}</strong> tasks
+ <div className="flex items-center justify-between mt-4">
+ <RecordsCount
+ count={tasks.length}
+ total={totalTasks}
+ label="tasks"
+ />
+ {totalTasks > APP_CONSTANTS.RECORDS_PER_PAGE && (
+ <RecordsPerPageSelector
+ value={recordsPerPage}
+ onChange={setRecordsPerPage}
+ />
+ )}
</div>
</>
)}
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index 9b5a602..4433c6f 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -8,11 +8,12 @@ import {
Wrench,
} from "lucide-react";
-export enum APP_CONSTANTS {
- RECORDS_PER_PAGE = 10,
- ACTIVITY_MAX_DURATION_MINUTES = 8 * 60, // 8 Hours
- ACTIVITY_MAX_DURATION_MS = 8 * 60 * 60 * 1000, // 8 hours in milliseconds
-}
+export const APP_CONSTANTS = {
+ RECORDS_PER_PAGE: 25,
+ RECORDS_PER_PAGE_OPTIONS: [25, 50, 100],
+ ACTIVITY_MAX_DURATION_MINUTES: 8 * 60, // 8 Hours
+ ACTIVITY_MAX_DURATION_MS: 8 * 60 * 60 * 1000, // 8 hours in milliseconds
+} as const;
export const SIDEBAR_LINKS = [
{