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.

refactor: remove RecordsPerPageSelector from various components and use APP_CONSTANTS.RECORDS_PER_PAGE directly

Khuram Niaz2e8a07997b53
diff --git a/src/components/RecordsPerPageSelector.tsx b/src/components/RecordsPerPageSelector.tsx
deleted file mode 100644
index 9bd5173..0000000
--- a/src/components/RecordsPerPageSelector.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-"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 897a7d5..4e3056d 100644
--- a/src/components/activities/ActivitiesContainer.tsx
+++ b/src/components/activities/ActivitiesContainer.tsx
@@ -18,7 +18,6 @@ import { Activity } from "@/models/activity.model";
import { toast } from "../ui/use-toast";
import Loading from "../Loading";
import { APP_CONSTANTS } from "@/lib/constants";
-import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
import { RecordsCount } from "../RecordsCount";
import { useActivity } from "@/context/ActivityContext";
@@ -29,9 +28,6 @@ function ActivitiesContainer() {
const [totalActivities, setTotalActivities] = useState<number>(0);
const [initialLoading, setInitialLoading] = useState(false);
const [loadingMore, setLoadingMore] = useState(false);
- const [recordsPerPage, setRecordsPerPage] = useState<number>(
- APP_CONSTANTS.RECORDS_PER_PAGE,
- );
const [searchTerm, setSearchTerm] = useState("");
const hasSearched = useRef(false);
const sentinelRef = useRef<HTMLDivElement>(null);
@@ -77,8 +73,8 @@ function ActivitiesContainer() {
);
const reloadActivities = useCallback(async () => {
- await loadActivities(1, recordsPerPage, searchTerm || undefined);
- }, [loadActivities, recordsPerPage, searchTerm]);
+ await loadActivities(1, APP_CONSTANTS.RECORDS_PER_PAGE, searchTerm || undefined);
+ }, [loadActivities, searchTerm]);
const handleStartActivity = async (activityId: string) => {
const success = await startActivity(activityId);
@@ -88,8 +84,8 @@ function ActivitiesContainer() {
};
useEffect(() => {
- loadActivities(1, recordsPerPage);
- }, [loadActivities, recordsPerPage]);
+ loadActivities(1, APP_CONSTANTS.RECORDS_PER_PAGE);
+ }, [loadActivities]);
// Reload activities when an activity is stopped (via global banner or otherwise)
useEffect(() => {
@@ -107,7 +103,7 @@ function ActivitiesContainer() {
if (searchTerm === "" && !hasSearched.current) return;
const timer = setTimeout(() => {
- loadActivities(1, recordsPerPage, searchTerm || undefined);
+ loadActivities(1, APP_CONSTANTS.RECORDS_PER_PAGE, searchTerm || undefined);
}, 300);
return () => clearTimeout(timer);
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -126,7 +122,7 @@ function ActivitiesContainer() {
!loadingMore &&
activitiesList.length < totalActivities
) {
- loadActivities(page + 1, recordsPerPage, searchTerm || undefined);
+ loadActivities(page + 1, APP_CONSTANTS.RECORDS_PER_PAGE, searchTerm || undefined);
}
},
{ threshold: 0.1 },
@@ -138,7 +134,6 @@ function ActivitiesContainer() {
activitiesList.length,
totalActivities,
page,
- recordsPerPage,
searchTerm,
initialLoading,
loadingMore,
@@ -148,7 +143,12 @@ function ActivitiesContainer() {
return (
<Card>
<CardHeader className="flex-row justify-between items-center">
- <CardTitle>Activities</CardTitle>
+ <div className="flex items-baseline gap-2">
+ <CardTitle>Activities</CardTitle>
+ {!initialLoading && totalActivities > 0 && (
+ <RecordsCount count={activitiesList.length} total={totalActivities} label="activities" />
+ )}
+ </div>
<div className="flex items-center gap-2">
<div className="relative">
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
@@ -198,19 +198,6 @@ function ActivitiesContainer() {
onStartActivity={handleStartActivity}
activityExist={Boolean(currentActivity)}
/>
- <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>
</>
)}
{activitiesList.length < totalActivities && (
diff --git a/src/components/admin/ActivityTypesContainer.tsx b/src/components/admin/ActivityTypesContainer.tsx
index f7b8a47..8688f46 100644
--- a/src/components/admin/ActivityTypesContainer.tsx
+++ b/src/components/admin/ActivityTypesContainer.tsx
@@ -5,7 +5,6 @@ import { getActivityTypeList } from "@/actions/activity.actions";
import { APP_CONSTANTS } from "@/lib/constants";
import Loading from "../Loading";
import { Button } from "../ui/button";
-import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
import { RecordsCount } from "../RecordsCount";
import ActivityTypesTable from "./ActivityTypesTable";
import AddActivityType from "./AddActivityType";
@@ -15,15 +14,11 @@ function ActivityTypesContainer() {
const [totalActivityTypes, setTotalActivityTypes] = useState<number>(0);
const [page, setPage] = useState<number>(1);
const [loading, setLoading] = useState<boolean>(false);
- const [recordsPerPage, setRecordsPerPage] = useState<number>(
- APP_CONSTANTS.RECORDS_PER_PAGE,
- );
-
const loadActivityTypes = useCallback(
async (page: number) => {
setLoading(true);
try {
- const { data, total } = await getActivityTypeList(page, recordsPerPage);
+ const { data, total } = await getActivityTypeList(page, APP_CONSTANTS.RECORDS_PER_PAGE);
if (data) {
setActivityTypes((prev) => (page === 1 ? data : [...prev, ...data]));
setTotalActivityTypes(total);
@@ -33,7 +28,7 @@ function ActivityTypesContainer() {
setLoading(false);
}
},
- [recordsPerPage],
+ [],
);
const reloadActivityTypes = useCallback(async () => {
@@ -42,14 +37,19 @@ function ActivityTypesContainer() {
useEffect(() => {
(async () => await loadActivityTypes(1))();
- }, [loadActivityTypes, recordsPerPage]);
+ }, [loadActivityTypes]);
return (
<>
<div className="col-span-3">
<Card>
<CardHeader className="flex-row justify-between items-center">
- <CardTitle>Activity Types / Projects</CardTitle>
+ <div className="flex items-baseline gap-2">
+ <CardTitle>Activity Types / Projects</CardTitle>
+ {!loading && totalActivityTypes > 0 && (
+ <RecordsCount count={activityTypes.length} total={totalActivityTypes} label="activity types" />
+ )}
+ </div>
<div className="flex items-center">
<div className="ml-auto flex items-center gap-2">
<AddActivityType reloadActivityTypes={reloadActivityTypes} />
@@ -64,19 +64,6 @@ function ActivityTypesContainer() {
activityTypes={activityTypes}
reloadActivityTypes={reloadActivityTypes}
/>
- <div className="flex items-center justify-between mt-4">
- <RecordsCount
- count={activityTypes.length}
- total={totalActivityTypes}
- label="activity types"
- />
- {totalActivityTypes > APP_CONSTANTS.RECORDS_PER_PAGE && (
- <RecordsPerPageSelector
- value={recordsPerPage}
- onChange={setRecordsPerPage}
- />
- )}
- </div>
</>
)}
{activityTypes.length < totalActivityTypes && (
diff --git a/src/components/admin/CompaniesContainer.tsx b/src/components/admin/CompaniesContainer.tsx
index 9e2a77a..8942637 100644
--- a/src/components/admin/CompaniesContainer.tsx
+++ b/src/components/admin/CompaniesContainer.tsx
@@ -8,7 +8,6 @@ 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() {
@@ -18,16 +17,12 @@ function CompaniesContainer() {
const [dialogOpen, setDialogOpen] = useState(false);
const [editCompany, setEditCompany] = useState(null);
const [loading, setLoading] = useState<boolean>(false);
- const [recordsPerPage, setRecordsPerPage] = useState<number>(
- APP_CONSTANTS.RECORDS_PER_PAGE,
- );
-
const loadCompanies = useCallback(
async (page: number) => {
setLoading(true);
const { data, total } = await getCompanyList(
page,
- recordsPerPage,
+ APP_CONSTANTS.RECORDS_PER_PAGE,
"applied"
);
if (data) {
@@ -37,7 +32,7 @@ function CompaniesContainer() {
setLoading(false);
}
},
- [recordsPerPage]
+ []
);
const reloadCompanies = useCallback(async () => {
@@ -50,7 +45,7 @@ function CompaniesContainer() {
useEffect(() => {
(async () => await loadCompanies(1))();
- }, [loadCompanies, recordsPerPage]);
+ }, [loadCompanies]);
const onEditCompany = async (companyId: string) => {
const company = await getCompanyById(companyId);
@@ -63,7 +58,12 @@ function CompaniesContainer() {
<div className="col-span-3">
<Card x-chunk="dashboard-06-chunk-0">
<CardHeader className="flex-row justify-between items-center">
- <CardTitle>Companies</CardTitle>
+ <div className="flex items-baseline gap-2">
+ <CardTitle>Companies</CardTitle>
+ {!loading && totalCompanies > 0 && (
+ <RecordsCount count={companies.length} total={totalCompanies} label="companies" />
+ )}
+ </div>
<div className="flex items-center">
<div className="ml-auto flex items-center gap-2">
<AddCompany
@@ -85,19 +85,6 @@ function CompaniesContainer() {
reloadCompanies={reloadCompanies}
editCompany={onEditCompany}
/>
- <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>
</>
)}
{companies.length < totalCompanies && (
diff --git a/src/components/admin/JobLocationsContainer.tsx b/src/components/admin/JobLocationsContainer.tsx
index fd4dfa2..328c502 100644
--- a/src/components/admin/JobLocationsContainer.tsx
+++ b/src/components/admin/JobLocationsContainer.tsx
@@ -7,7 +7,6 @@ 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() {
@@ -15,16 +14,12 @@ function JobLocationsContainer() {
const [totalJobLocations, setTotalJobLocations] = useState<number>(0);
const [page, setPage] = useState<number>(1);
const [loading, setLoading] = useState<boolean>(false);
- const [recordsPerPage, setRecordsPerPage] = useState<number>(
- APP_CONSTANTS.RECORDS_PER_PAGE,
- );
-
const loadJobLocations = useCallback(
async (page: number) => {
setLoading(true);
const { data, total } = await getJobLocationsList(
page,
- recordsPerPage,
+ APP_CONSTANTS.RECORDS_PER_PAGE,
"applied"
);
if (data) {
@@ -34,7 +29,7 @@ function JobLocationsContainer() {
setLoading(false);
}
},
- [recordsPerPage]
+ []
);
const reloadJobLocations = useCallback(async () => {
@@ -43,14 +38,19 @@ function JobLocationsContainer() {
useEffect(() => {
(async () => await loadJobLocations(1))();
- }, [loadJobLocations, recordsPerPage]);
+ }, [loadJobLocations]);
return (
<>
<div className="col-span-3">
<Card x-chunk="dashboard-06-chunk-0">
<CardHeader className="flex-row justify-between items-center">
- <CardTitle>Job Locations</CardTitle>
+ <div className="flex items-baseline gap-2">
+ <CardTitle>Job Locations</CardTitle>
+ {!loading && totalJobLocations > 0 && (
+ <RecordsCount count={locations.length} total={totalJobLocations} label="job locations" />
+ )}
+ </div>
<div className="flex items-center">
<div className="ml-auto flex items-center gap-2">
{/* <AddCompany reloadCompanies={reloadJobLocations} /> */}
@@ -65,19 +65,6 @@ function JobLocationsContainer() {
jobLocations={locations}
reloadJobLocations={reloadJobLocations}
/>
- <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>
</>
)}
{locations.length < totalJobLocations && (
diff --git a/src/components/admin/JobSourcesContainer.tsx b/src/components/admin/JobSourcesContainer.tsx
index c82ef2b..7ab45d0 100644
--- a/src/components/admin/JobSourcesContainer.tsx
+++ b/src/components/admin/JobSourcesContainer.tsx
@@ -7,7 +7,6 @@ import JobSourcesTable from "./JobSourcesTable";
import { getJobSourceList } from "@/actions/jobSource.actions";
import Loading from "../Loading";
import { Button } from "../ui/button";
-import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
import { RecordsCount } from "../RecordsCount";
function JobSourcesContainer() {
@@ -15,16 +14,12 @@ function JobSourcesContainer() {
const [totalJobSources, setTotalJobSources] = useState<number>(0);
const [page, setPage] = useState<number>(1);
const [loading, setLoading] = useState<boolean>(false);
- const [recordsPerPage, setRecordsPerPage] = useState<number>(
- APP_CONSTANTS.RECORDS_PER_PAGE,
- );
-
const loadJobSources = useCallback(
async (page: number) => {
setLoading(true);
const { data, total } = await getJobSourceList(
page,
- recordsPerPage,
+ APP_CONSTANTS.RECORDS_PER_PAGE,
"applied"
);
if (data) {
@@ -34,7 +29,7 @@ function JobSourcesContainer() {
setLoading(false);
}
},
- [recordsPerPage]
+ []
);
const reloadJobSources = useCallback(async () => {
@@ -43,14 +38,19 @@ function JobSourcesContainer() {
useEffect(() => {
(async () => await loadJobSources(1))();
- }, [loadJobSources, recordsPerPage]);
+ }, [loadJobSources]);
return (
<>
<div className="col-span-3">
<Card x-chunk="dashboard-06-chunk-0">
<CardHeader className="flex-row justify-between items-center">
- <CardTitle>Job Sources</CardTitle>
+ <div className="flex items-baseline gap-2">
+ <CardTitle>Job Sources</CardTitle>
+ {!loading && totalJobSources > 0 && (
+ <RecordsCount count={sources.length} total={totalJobSources} label="job sources" />
+ )}
+ </div>
<div className="flex items-center">
<div className="ml-auto flex items-center gap-2">
</div>
@@ -64,19 +64,6 @@ function JobSourcesContainer() {
jobSources={sources}
reloadJobSources={reloadJobSources}
/>
- <div className="flex items-center justify-between mt-4">
- <RecordsCount
- count={sources.length}
- total={totalJobSources}
- label="job sources"
- />
- {totalJobSources > APP_CONSTANTS.RECORDS_PER_PAGE && (
- <RecordsPerPageSelector
- value={recordsPerPage}
- onChange={setRecordsPerPage}
- />
- )}
- </div>
</>
)}
{sources.length < totalJobSources && (
diff --git a/src/components/admin/JobTitlesContainer.tsx b/src/components/admin/JobTitlesContainer.tsx
index 14d1876..9f82583 100644
--- a/src/components/admin/JobTitlesContainer.tsx
+++ b/src/components/admin/JobTitlesContainer.tsx
@@ -7,7 +7,6 @@ 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() {
@@ -15,16 +14,12 @@ function JobTitlesContainer() {
const [totalJobTitles, setTotalJobTitles] = useState<number>(0);
const [page, setPage] = useState<number>(1);
const [loading, setLoading] = useState<boolean>(false);
- const [recordsPerPage, setRecordsPerPage] = useState<number>(
- APP_CONSTANTS.RECORDS_PER_PAGE,
- );
-
const loadJobTitles = useCallback(
async (page: number) => {
setLoading(true);
const { data, total } = await getJobTitleList(
page,
- recordsPerPage,
+ APP_CONSTANTS.RECORDS_PER_PAGE,
"applied"
);
if (data) {
@@ -34,7 +29,7 @@ function JobTitlesContainer() {
setLoading(false);
}
},
- [recordsPerPage]
+ []
);
const reloadJobTitles = useCallback(async () => {
@@ -43,14 +38,19 @@ function JobTitlesContainer() {
useEffect(() => {
(async () => await loadJobTitles(1))();
- }, [loadJobTitles, recordsPerPage]);
+ }, [loadJobTitles]);
return (
<>
<div className="col-span-3">
<Card x-chunk="dashboard-06-chunk-0">
<CardHeader className="flex-row justify-between items-center">
- <CardTitle>Job Titles</CardTitle>
+ <div className="flex items-baseline gap-2">
+ <CardTitle>Job Titles</CardTitle>
+ {!loading && totalJobTitles > 0 && (
+ <RecordsCount count={titles.length} total={totalJobTitles} label="job titles" />
+ )}
+ </div>
<div className="flex items-center">
<div className="ml-auto flex items-center gap-2">
{/* <AddCompany reloadCompanies={reloadJobTitles} /> */}
@@ -65,19 +65,6 @@ function JobTitlesContainer() {
jobTitles={titles}
reloadJobTitles={reloadJobTitles}
/>
- <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>
</>
)}
{titles.length < totalJobTitles && (
diff --git a/src/components/admin/TagsContainer.tsx b/src/components/admin/TagsContainer.tsx
index 0d24e23..db897d1 100644
--- a/src/components/admin/TagsContainer.tsx
+++ b/src/components/admin/TagsContainer.tsx
@@ -6,7 +6,6 @@ import { getTagList } from "@/actions/tag.actions";
import { APP_CONSTANTS } from "@/lib/constants";
import Loading from "../Loading";
import { Button } from "../ui/button";
-import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
import { RecordsCount } from "../RecordsCount";
import TagsTable from "./TagsTable";
import AddTag from "./AddTag";
@@ -16,15 +15,11 @@ function TagsContainer() {
const [totalTags, setTotalTags] = useState<number>(0);
const [page, setPage] = useState<number>(1);
const [loading, setLoading] = useState<boolean>(false);
- const [recordsPerPage, setRecordsPerPage] = useState<number>(
- APP_CONSTANTS.RECORDS_PER_PAGE,
- );
-
const loadTags = useCallback(
async (page: number) => {
setLoading(true);
try {
- const { data, total } = await getTagList(page, recordsPerPage);
+ const { data, total } = await getTagList(page, APP_CONSTANTS.RECORDS_PER_PAGE);
if (data) {
setTags((prev) => (page === 1 ? data : [...prev, ...data]));
setTotalTags(total);
@@ -34,7 +29,7 @@ function TagsContainer() {
setLoading(false);
}
},
- [recordsPerPage],
+ [],
);
const reloadTags = useCallback(async () => {
@@ -43,14 +38,19 @@ function TagsContainer() {
useEffect(() => {
(async () => await loadTags(1))();
- }, [loadTags, recordsPerPage]);
+ }, [loadTags]);
return (
<>
<div className="col-span-3">
<Card>
<CardHeader className="flex-row justify-between items-center">
- <CardTitle>Skills/Tags</CardTitle>
+ <div className="flex items-baseline gap-2">
+ <CardTitle>Skills/Tags</CardTitle>
+ {!loading && totalTags > 0 && (
+ <RecordsCount count={tags.length} total={totalTags} label="skills" />
+ )}
+ </div>
<div className="flex items-center">
<div className="ml-auto flex items-center gap-2">
<AddTag reloadTags={reloadTags} />
@@ -62,19 +62,6 @@ function TagsContainer() {
{tags.length > 0 && (
<>
<TagsTable tags={tags} reloadTags={reloadTags} />
- <div className="flex items-center justify-between mt-4">
- <RecordsCount
- count={tags.length}
- total={totalTags}
- label="skills"
- />
- {totalTags > APP_CONSTANTS.RECORDS_PER_PAGE && (
- <RecordsPerPageSelector
- value={recordsPerPage}
- onChange={setRecordsPerPage}
- />
- )}
- </div>
</>
)}
{tags.length < totalTags && (
diff --git a/src/components/myjobs/JobsContainer.tsx b/src/components/myjobs/JobsContainer.tsx
index 736902b..40fa94e 100644
--- a/src/components/myjobs/JobsContainer.tsx
+++ b/src/components/myjobs/JobsContainer.tsx
@@ -43,7 +43,6 @@ import { AddJob } from "./AddJob";
import MyJobsTable from "./MyJobsTable";
import { NoteDialog } from "./NoteDialog";
import { format } from "date-fns";
-import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
import { RecordsCount } from "../RecordsCount";
type MyJobsProps = {
@@ -98,9 +97,6 @@ function JobsContainer({
const [editJob, setEditJob] = useState(null);
const [initialLoading, setInitialLoading] = useState(false);
const [loadingMore, setLoadingMore] = useState(false);
- const [recordsPerPage, setRecordsPerPage] = useState<number>(
- APP_CONSTANTS.RECORDS_PER_PAGE,
- );
const [noteDialogOpen, setNoteDialogOpen] = useState(false);
const [noteJobId, setNoteJobId] = useState("");
const hasSearched = useRef(false);
@@ -159,7 +155,7 @@ function JobsContainer({
setAppliedFilter(ap);
}, [queryParams]);
- const jobsPerPage = recordsPerPage;
+ const jobsPerPage = APP_CONSTANTS.RECORDS_PER_PAGE;
const loadJobs = useCallback(
async (page: number, filter?: string, search?: string) => {
@@ -354,7 +350,12 @@ function JobsContainer({
<>
<Card x-chunk="dashboard-06-chunk-0">
<CardHeader className="flex-col gap-3 sm:flex-row sm:justify-between sm:items-center">
- <CardTitle>My Jobs</CardTitle>
+ <div className="flex items-baseline gap-2">
+ <CardTitle>My Jobs</CardTitle>
+ {!initialLoading && totalJobs > 0 && (
+ <RecordsCount count={jobs.length} total={totalJobs} label="jobs" />
+ )}
+ </div>
<div className="flex flex-wrap items-center gap-2">
{companyLabel && (
<button
@@ -457,19 +458,6 @@ function JobsContainer({
onChangeJobStatus={onChangeJobStatus}
onAddNote={onAddNote}
/>
- <div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mt-4">
- <RecordsCount
- count={jobs.length}
- total={totalJobs}
- label="jobs"
- />
- {totalJobs > APP_CONSTANTS.RECORDS_PER_PAGE && (
- <RecordsPerPageSelector
- value={recordsPerPage}
- onChange={setRecordsPerPage}
- />
- )}
- </div>
</>
)}
{jobs.length < totalJobs && (
diff --git a/src/components/profile/ProfileContainer.tsx b/src/components/profile/ProfileContainer.tsx
index c37903c..bb263ab 100644
--- a/src/components/profile/ProfileContainer.tsx
+++ b/src/components/profile/ProfileContainer.tsx
@@ -16,7 +16,6 @@ import DocumentTable from "./ResumeTable";
import { toast } from "../ui/use-toast";
import { ChevronDown, PlusCircle } from "lucide-react";
import { Button } from "../ui/button";
-import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
import { RecordsCount } from "../RecordsCount";
import {
DropdownMenu,
@@ -38,15 +37,11 @@ const ProfileContainer = () => {
const [totalCoverLetters, setTotalCoverLetters] = 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) => {
const { data, total, success, message } = await getResumeList(
page,
- recordsPerPage,
+ APP_CONSTANTS.RECORDS_PER_PAGE,
);
if (success && data) {
setResumes((prev) => (page === 1 ? data : [...prev, ...data]));
@@ -60,7 +55,7 @@ const ProfileContainer = () => {
});
}
},
- [recordsPerPage],
+ [],
);
const loadCoverLetters = useCallback(async () => {
@@ -95,7 +90,7 @@ const ProfileContainer = () => {
useEffect(() => {
(async () => await loadDocuments(1))();
- }, [loadDocuments, recordsPerPage]);
+ }, [loadDocuments]);
const documents: ProfileDocument[] = useMemo(() => {
const resumeDocs: ProfileDocument[] = resumes.map((r) => ({
@@ -157,7 +152,12 @@ const ProfileContainer = () => {
return (
<Card>
<CardHeader className="flex-row justify-between items-center">
- <CardTitle>Profile</CardTitle>
+ <div className="flex items-baseline gap-2">
+ <CardTitle>Profile</CardTitle>
+ {!loading && totalDocuments > 0 && (
+ <RecordsCount count={documents.length} total={totalDocuments} label="documents" />
+ )}
+ </div>
<div className="flex items-center">
<DropdownMenu>
<DropdownMenuTrigger asChild>
@@ -209,19 +209,6 @@ const ProfileContainer = () => {
editCoverLetter={onEditCoverLetter}
reloadDocuments={reloadDocuments}
/>
- <div className="flex items-center justify-between mt-4">
- <RecordsCount
- count={documents.length}
- total={totalDocuments}
- label="documents"
- />
- {totalDocuments > APP_CONSTANTS.RECORDS_PER_PAGE && (
- <RecordsPerPageSelector
- value={recordsPerPage}
- onChange={setRecordsPerPage}
- />
- )}
- </div>
</>
)}
{resumes.length < totalResumes && (
diff --git a/src/components/questions/QuestionsContainer.tsx b/src/components/questions/QuestionsContainer.tsx
index f120042..a79cf0c 100644
--- a/src/components/questions/QuestionsContainer.tsx
+++ b/src/components/questions/QuestionsContainer.tsx
@@ -18,7 +18,6 @@ import {
import { toast } from "../ui/use-toast";
import { Question } from "@/models/question.model";
import { Tag } from "@/models/job.model";
-import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
import { RecordsCount } from "../RecordsCount";
import { APP_CONSTANTS } from "@/lib/constants";
import Loading from "../Loading";
@@ -42,9 +41,6 @@ function QuestionsContainer({
const [editQuestion, setEditQuestion] = useState<Question | null>(null);
const [loading, setLoading] = useState(false);
const [dialogOpen, setDialogOpen] = useState(false);
- const [recordsPerPage, setRecordsPerPage] = useState<number>(
- APP_CONSTANTS.RECORDS_PER_PAGE
- );
const [searchTerm, setSearchTerm] = useState("");
const hasSearched = useRef(false);
@@ -53,7 +49,7 @@ function QuestionsContainer({
setLoading(true);
const result = await getQuestionsList(
pageNum,
- recordsPerPage,
+ APP_CONSTANTS.RECORDS_PER_PAGE,
filter,
search
);
@@ -72,7 +68,7 @@ function QuestionsContainer({
}
setLoading(false);
},
- [recordsPerPage]
+ []
);
const reloadQuestions = useCallback(async () => {
@@ -119,7 +115,7 @@ function QuestionsContainer({
useEffect(() => {
loadQuestions(1, filterKey, searchTerm || undefined);
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [loadQuestions, filterKey, recordsPerPage]);
+ }, [loadQuestions, filterKey]);
// Debounced search
useEffect(() => {
@@ -139,7 +135,12 @@ function QuestionsContainer({
<>
<Card className="h-full">
<CardHeader className="flex-row justify-between items-center">
- <CardTitle>Question Bank</CardTitle>
+ <div className="flex items-baseline gap-2">
+ <CardTitle>Question Bank</CardTitle>
+ {!loading && totalQuestions > 0 && (
+ <RecordsCount count={questions.length} total={totalQuestions} label="questions" />
+ )}
+ </div>
<div className="flex items-center">
<div className="ml-auto flex items-center gap-2">
<div className="relative">
@@ -175,21 +176,6 @@ function QuestionsContainer({
onEdit={onEditQuestion}
onDelete={onDeleteQuestion}
/>
- {questions.length > 0 && (
- <div className="flex items-center justify-between mt-4">
- <RecordsCount
- count={questions.length}
- total={totalQuestions}
- label="questions"
- />
- {totalQuestions > APP_CONSTANTS.RECORDS_PER_PAGE && (
- <RecordsPerPageSelector
- value={recordsPerPage}
- onChange={setRecordsPerPage}
- />
- )}
- </div>
- )}
</>
)}
{!loading && questions.length < totalQuestions && (
diff --git a/src/components/tasks/TasksContainer.tsx b/src/components/tasks/TasksContainer.tsx
index 9d06d24..d625936 100644
--- a/src/components/tasks/TasksContainer.tsx
+++ b/src/components/tasks/TasksContainer.tsx
@@ -30,7 +30,6 @@ import {
SelectTrigger,
SelectValue,
} from "../ui/select";
-import { RecordsPerPageSelector } from "../RecordsPerPageSelector";
import { RecordsCount } from "../RecordsCount";
import {
DropdownMenu,
@@ -77,9 +76,6 @@ function TasksContainer({
const [statusFilter, setStatusFilter] = useState<TaskStatus[]>(
DEFAULT_STATUS_FILTER,
);
- const [recordsPerPage, setRecordsPerPage] = useState<number>(
- APP_CONSTANTS.RECORDS_PER_PAGE,
- );
const [searchTerm, setSearchTerm] = useState("");
const hasSearched = useRef(false);
const sentinelRef = useRef<HTMLDivElement>(null);
@@ -90,7 +86,7 @@ function TasksContainer({
setMounted(true);
}, []);
- const tasksPerPage = recordsPerPage;
+ const tasksPerPage = APP_CONSTANTS.RECORDS_PER_PAGE;
const loadTasks = useCallback(
async (
@@ -215,7 +211,7 @@ function TasksContainer({
(async () =>
await loadTasks(1, filterKey, statusFilter, searchTerm || undefined))();
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [loadTasks, filterKey, statusFilter, recordsPerPage]);
+ }, [loadTasks, filterKey, statusFilter]);
// Debounced search effect
useEffect(() => {
@@ -292,7 +288,12 @@ function TasksContainer({
<>
<Card x-chunk="dashboard-tasks-chunk-0" className="h-full">
<CardHeader className="flex-row justify-between items-center">
- <CardTitle>My Tasks</CardTitle>
+ <div className="flex items-baseline gap-2">
+ <CardTitle>My Tasks</CardTitle>
+ {!initialLoading && totalTasks > 0 && (
+ <RecordsCount count={tasks.length} total={totalTasks} label="tasks" />
+ )}
+ </div>
<div className="flex items-center">
<div className="ml-auto flex items-center gap-2">
<div className="relative">
@@ -396,19 +397,6 @@ function TasksContainer({
onStartActivity={onStartActivity}
groupBy={groupBy}
/>
- <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>
</>
)}
{!initialLoading && tasks.length === 0 && (
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index fb7b181..25e8fe5 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -12,7 +12,6 @@ import {
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
RECENT_NUM_JOBS_ACTIVITIES: 7,