Skip to content

Commit 921bb56

Browse files
feat: Implement the new interface to jobs, and update the pagination
1 parent 34ee26f commit 921bb56

3 files changed

Lines changed: 42 additions & 145 deletions

File tree

frontend/src/domains/jobs/presentation/components/JobsFiltersCard.tsx

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Badge } from "@/shared/ui/badge";
22
import { Card, CardContent } from "@/shared/ui/card";
33
import { Input } from "@/shared/ui/input";
4-
import type { JobFile, JobsMeta } from "@/domains/jobs/domain/job.types";
4+
import type { JobsPaginationMeta } from "@/domains/jobs/application/useJobsData";
55
import {
66
useMemo,
77
useState,
@@ -13,7 +13,6 @@ import {
1313
import {
1414
FiBriefcase,
1515
FiCheck,
16-
FiFileText,
1716
FiFilter,
1817
FiPlus,
1918
FiSearch,
@@ -30,10 +29,7 @@ interface JobsFiltersCardProps {
3029
onRemoveFilter: (filterToRemove: string) => void;
3130
onClearFilters: () => void;
3231
keywords: string[];
33-
selectedFile: string;
34-
setSelectedFile: Dispatch<SetStateAction<string>>;
35-
files: JobFile[];
36-
meta: JobsMeta;
32+
meta: JobsPaginationMeta;
3733
actions?: ReactNode;
3834
}
3935

@@ -56,11 +52,7 @@ export function JobsFiltersCard({
5652
onRemoveFilter,
5753
onClearFilters,
5854
keywords,
59-
selectedFile,
60-
setSelectedFile,
61-
files,
6255
meta,
63-
actions,
6456
}: JobsFiltersCardProps) {
6557
const [seeKeywordsModal, setSeeKeywordsModal] = useState(false);
6658
const [searchTerm, setSearchTerm] = useState("");
@@ -99,7 +91,10 @@ export function JobsFiltersCard({
9991
}
10092

10193
setSearch((current) => {
102-
const currentTerms = getSelectedFilters(current, []);
94+
const currentTerms = current
95+
.split(/[,;/]+/)
96+
.map((item) => item.trim())
97+
.filter(Boolean);
10398

10499
if (currentTerms.includes(nextTerm)) {
105100
return current;
@@ -132,7 +127,6 @@ export function JobsFiltersCard({
132127
<FiPlus className="h-4 w-4" />
133128
</button>
134129
</form>
135-
<div className="flex items-center gap-2">{actions}</div>
136130
</div>
137131

138132
<div className="flex flex-col gap-3 xl:flex-row xl:items-center xl:justify-between">
@@ -151,28 +145,7 @@ export function JobsFiltersCard({
151145
))}
152146
</select>
153147

154-
<select
155-
aria-label="Selecionar arquivo"
156-
className="h-12 min-w-[180px] rounded-2xl border border-slate-300 bg-white px-3 text-sm text-slate-900 focus:outline-none focus:ring-2 focus:ring-[#14AE5C]/40 dark:border-[#35506f] dark:bg-[#0b1527] dark:text-slate-100"
157-
value={selectedFile}
158-
onChange={(event) => setSelectedFile(event.target.value)}
159-
>
160-
{files.map((file) => (
161-
<option key={file.file} value={file.file}>
162-
{file.file}
163-
</option>
164-
))}
165-
</select>
166-
167148
<div>
168-
<Badge
169-
variant="secondary"
170-
className="gap-1.5 rounded-full border border-slate-300 bg-slate-100 px-3 py-1 text-xs text-slate-700 dark:border-[#35506f] dark:bg-[#24324c] dark:text-slate-100"
171-
>
172-
<FiFileText className="h-3.5 w-3.5" />
173-
{meta.file || "Sem arquivo"}
174-
</Badge>
175-
176149
<Badge className="gap-1.5 rounded-full bg-[#0c6b35] px-3 py-1 text-xs text-white">
177150
<FiBriefcase className="h-3.5 w-3.5" />
178151
{meta.total} vagas
@@ -239,4 +212,4 @@ export function JobsFiltersCard({
239212
)}
240213
</>
241214
);
242-
}
215+
}

frontend/src/domains/jobs/presentation/components/JobsTableCard.tsx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
TableRow,
1616
} from "@/shared/ui/table";
1717
import { cn } from "@/shared/lib/utils";
18-
import type { Job, JobsMeta } from "@/domains/jobs/domain/job.types";
18+
import type { Job } from "@/domains/jobs/domain/job.types";
19+
import type { JobsPaginationMeta } from "@/domains/jobs/application/useJobsData";
1920
import { useState } from "react";
2021
import {
2122
FiCheckSquare,
@@ -25,12 +26,12 @@ import {
2526
} from "react-icons/fi";
2627

2728
interface JobsTableCardProps {
28-
meta: JobsMeta;
29+
meta: JobsPaginationMeta;
2930
filteredJobs: Job[];
3031
paginatedJobs: Job[];
3132
loading: boolean;
3233
error: string;
33-
formatDate: (timestamp: JobsMeta["modifiedAt"]) => string;
34+
formatDate: () => string;
3435
currentPage: number;
3536
totalPages: number;
3637
pageSize: number;
@@ -80,8 +81,8 @@ function getPaginationItems(
8081

8182
function getJobId(job: Job, index: number) {
8283
return (
83-
job.link?.trim() ||
84-
[job.titulo, job.empresa, job.local, String(index)]
84+
job.url?.trim() ||
85+
[job.title, job.company, job.location, String(index)]
8586
.filter(Boolean)
8687
.join("|")
8788
);
@@ -130,7 +131,6 @@ export function JobsTableCard({
130131
paginatedJobs,
131132
loading,
132133
error,
133-
formatDate,
134134
currentPage,
135135
totalPages,
136136
pageSize,
@@ -139,7 +139,7 @@ export function JobsTableCard({
139139
}: JobsTableCardProps) {
140140
const [spamMarks, setSpamMarks] = useState<Record<string, boolean>>({});
141141
const [readMarks, setReadMarks] = useState<Record<string, boolean>>({});
142-
const resultsLabel = getResultsLabel(filteredJobs.length);
142+
const resultsLabel = getResultsLabel(meta.total);
143143
const paginationItems = getPaginationItems(currentPage, totalPages);
144144

145145
return (
@@ -177,28 +177,28 @@ export function JobsTableCard({
177177
<TableBody>
178178
{paginatedJobs.map((job, index) => {
179179
const jobId = getJobId(job, index);
180-
const keywords = getKeywordTags(job.palavra);
180+
const keywords = getKeywordTags(job.keyword);
181181
const isSpamMarked = Boolean(spamMarks[jobId]);
182182
const isReadMarked = Boolean(readMarks[jobId]);
183183

184184
return (
185185
<TableRow key={jobId}>
186186
<TableCell className="font-medium">
187-
{job.link ? (
187+
{job.url ? (
188188
<a
189-
href={job.link}
189+
href={job.url}
190190
target="_blank"
191191
rel="noreferrer"
192192
className="text-primary underline-offset-4 hover:underline dark:text-[#14AE5C]"
193193
>
194-
{job.titulo || "Abrir vaga"}
194+
{job.title || "Abrir vaga"}
195195
</a>
196196
) : (
197-
job.titulo || "-"
197+
job.title || "-"
198198
)}
199199
</TableCell>
200-
<TableCell>{job.empresa || "-"}</TableCell>
201-
<TableCell>{job.local || "-"}</TableCell>
200+
<TableCell>{job.company || "-"}</TableCell>
201+
<TableCell>{job.location || "-"}</TableCell>
202202
<TableCell>
203203
{keywords.length > 0 ? (
204204
<div className="flex flex-wrap gap-1 text-sm text-foreground/85">
@@ -220,7 +220,7 @@ export function JobsTableCard({
220220
</TableCell>
221221
<TableCell className="text-center align-middle">
222222
<StatusToggleButton
223-
label={`Marcar vaga como spam para ${job.titulo || "vaga"}`}
223+
label={`Marcar vaga como spam para ${job.title || "vaga"}`}
224224
pressed={isSpamMarked}
225225
activeClassName="text-[#0c6b35]"
226226
onClick={() =>
@@ -233,7 +233,7 @@ export function JobsTableCard({
233233
</TableCell>
234234
<TableCell className="text-center align-middle">
235235
<StatusToggleButton
236-
label={`Marcar vaga como lida para ${job.titulo || "vaga"}`}
236+
label={`Marcar vaga como lida para ${job.title || "vaga"}`}
237237
pressed={isReadMarked}
238238
activeClassName="text-[#0c6b35]"
239239
onClick={() =>
@@ -277,7 +277,6 @@ export function JobsTableCard({
277277
<div className="mt-4 border-t border-border/60 pt-4">
278278
<p className="text-sm text-muted-foreground">
279279
<span className="font-medium text-foreground">{resultsLabel}</span>
280-
<span> (Atualizado em {formatDate(meta.modifiedAt)})</span>
281280
</p>
282281

283282
<div className="mt-3 flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
@@ -360,7 +359,7 @@ export function JobsTableCard({
360359
onClick={() =>
361360
onPageChange(Math.min(totalPages, currentPage + 1))
362361
}
363-
disabled={currentPage === totalPages}
362+
disabled={currentPage === totalPages || totalPages === 0}
364363
className="flex h-9 min-w-9 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40"
365364
>
366365
<FiChevronRight className="h-4 w-4" />
@@ -371,4 +370,4 @@ export function JobsTableCard({
371370
</CardContent>
372371
</Card>
373372
);
374-
}
373+
}

0 commit comments

Comments
 (0)