diff --git a/backend/internal/models/job.go b/backend/internal/models/job.go index ebc3139..4b27d9b 100755 --- a/backend/internal/models/job.go +++ b/backend/internal/models/job.go @@ -19,6 +19,7 @@ type Job struct { // Employment EmploymentType *string `json:"employmentType,omitempty" db:"employment_type"` // full-time, part-time, dispatch, contract + WorkMode *string `json:"workMode,omitempty" db:"work_mode"` // onsite, hybrid, remote WorkingHours *string `json:"workingHours,omitempty" db:"working_hours"` // Location diff --git a/backend/internal/services/job_service.go b/backend/internal/services/job_service.go index cac7696..37360f0 100644 --- a/backend/internal/services/job_service.go +++ b/backend/internal/services/job_service.go @@ -64,10 +64,10 @@ func (s *JobService) CreateJob(req dto.CreateJobRequest) (*models.Job, error) { } func (s *JobService) GetJobs(filter dto.JobFilterQuery) ([]models.JobWithCompany, int, error) { - baseQuery := ` + baseQuery := ` SELECT j.id, j.company_id, j.title, j.description, j.salary_min, j.salary_max, j.salary_type, - j.employment_type, j.location, j.status, j.is_featured, j.created_at, j.updated_at, + j.employment_type, j.work_mode, j.location, j.status, j.is_featured, j.created_at, j.updated_at, c.name as company_name, c.logo_url as company_logo_url, r.name as region_name, ci.name as city_name FROM jobs j @@ -75,7 +75,7 @@ func (s *JobService) GetJobs(filter dto.JobFilterQuery) ([]models.JobWithCompany LEFT JOIN regions r ON j.region_id = r.id LEFT JOIN cities ci ON j.city_id = ci.id WHERE 1=1` - countQuery := `SELECT COUNT(*) FROM jobs j WHERE 1=1` + countQuery := `SELECT COUNT(*) FROM jobs j WHERE 1=1` var args []interface{} argId := 1 diff --git a/frontend/src/app/vagas/page.tsx b/frontend/src/app/vagas/page.tsx index 15e1cee..9cc381c 100644 --- a/frontend/src/app/vagas/page.tsx +++ b/frontend/src/app/vagas/page.tsx @@ -24,6 +24,7 @@ function JobsContent() { const [searchTerm, setSearchTerm] = useState("") const [locationFilter, setLocationFilter] = useState("all") const [typeFilter, setTypeFilter] = useState("all") + const [workModeFilter, setWorkModeFilter] = useState("all") const [sortBy, setSortBy] = useState("recent") const [showFilters, setShowFilters] = useState(false) @@ -71,7 +72,7 @@ function JobsContent() { // Reset page when filters change useEffect(() => { setCurrentPage(1) - }, [debouncedSearchTerm, locationFilter, typeFilter, sortBy]) + }, [debouncedSearchTerm, locationFilter, typeFilter, workModeFilter, sortBy]) // Extrair valores únicos para os filtros const uniqueLocations = useMemo(() => { @@ -84,6 +85,11 @@ function JobsContent() { return Array.from(new Set(types)) }, [jobs]) + const uniqueWorkModes = useMemo(() => { + const modes = jobs.map(job => job.workMode).filter(Boolean) as string[] + return Array.from(new Set(modes)) + }, [jobs]) + const filteredAndSortedJobs = useMemo(() => { let filtered = jobs.filter((job) => { const matchesSearch = @@ -92,8 +98,9 @@ function JobsContent() { job.description.toLowerCase().includes(debouncedSearchTerm.toLowerCase()) const matchesLocation = locationFilter === "all" || job.location.includes(locationFilter) const matchesType = typeFilter === "all" || job.type === typeFilter + const matchesWorkMode = workModeFilter === "all" || job.workMode === workModeFilter - return matchesSearch && matchesLocation && matchesType + return matchesSearch && matchesLocation && matchesType && matchesWorkMode }) // Ordenação @@ -115,7 +122,7 @@ function JobsContent() { } return filtered - }, [debouncedSearchTerm, locationFilter, typeFilter, sortBy, jobs]) + }, [debouncedSearchTerm, locationFilter, typeFilter, workModeFilter, sortBy, jobs]) // Pagination Logic const totalPages = Math.ceil(filteredAndSortedJobs.length / ITEMS_PER_PAGE) @@ -124,12 +131,13 @@ function JobsContent() { currentPage * ITEMS_PER_PAGE ) - const hasActiveFilters = searchTerm || locationFilter !== "all" || typeFilter !== "all" + const hasActiveFilters = searchTerm || locationFilter !== "all" || typeFilter !== "all" || workModeFilter !== "all" const clearFilters = () => { setSearchTerm("") setLocationFilter("all") setTypeFilter("all") + setWorkModeFilter("all") } return ( @@ -234,6 +242,23 @@ function JobsContent() { + +