I need this Ui frontend using Next, Tailwind , typescript with backend code using controller in node js. Here is job mongodb model:const mongoose = require("mongoose") const Schema = mongoose.Schema
// Define the TimeSlot schema const TimeSlotSchema = new Schema( { startTime: { type: String, default: "" }, endTime: { type: String, default: "" }, }, { _id: false }, )
// Define the DaySchedule schema const DayScheduleSchema = new Schema( { enabled: { type: Boolean, default: false }, timeSlots: { type: [TimeSlotSchema], default: () => [{ startTime: "", endTime: "" }] }, }, { _id: false }, )
const JobSchema = new Schema( { currentStep: { type: Number, required: true, default: 0 }, userId: { type: String, required: true }, title: { type: String, required: false }, description: { type: String, required: false }, jobType: { type: String, required: false, default: "support" }, urgencyType: { type: String, required: false, enum: ["standard", "last_minute"], default: "standard" }, splitJobs: { type: Boolean, default: false }, parentJobId: { type: String }, // Reference to the original job if this is a split job supportTypes: { type: [String], required: false }, activities: { dailyLiving: { type: Boolean, default: false }, dailyLivingActivities: { type: [String], default: [] }, personalCare: { type: Boolean, default: false }, personalCareActivities: { type: [String], default: [] }, nursing: { type: Boolean, default: false }, nursingActivities: { type: [String], default: [] }, alliedHealth: { type: Boolean, default: false }, alliedHealthActivities: { type: [String], default: [] }, }, location: { suburb: { type: String, required: false }, postcode: { type: String, required: false }, }, schedule: { frequency: { type: String, required: false }, sessionsPerWeek: { type: Number, required: false }, hoursPerWeek: { type: Number, required: false }, startDate: { type: String, required: false }, startDateSpecif: { type: String, required: false }, // Added startDateSpecif field flexible: { type: Boolean, default: true }, preferredDays: { type: [String], default: [] }, // Add daySchedules as a map of day names to DaySchedule objects daySchedules: { type: Map, of: DayScheduleSchema, default: () => { const defaultSchedules = new Map() ;["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"].forEach((day) => { defaultSchedules.set(day, { enabled: false, timeSlots: [{ startTime: "", endTime: "" }], }) }) return defaultSchedules }, }, }, requirements: { equipmentProvided: { type: Boolean, required: false }, workerGenderPreference: { type: String }, preferredQualities: { type: String }, }, status: { type: String, required: true, enum: ["draft", "active", "filled", "closed"], default: "draft", }, }, { timestamps: true }, )
module.exports = mongoose.models.Job || mongoose.model("Job", JobSchema) with my micro seervice api: import { api } from "../api-service"
// Interface for time slots export interface TimeSlot { startTime: string endTime: string }
// Interface for day schedule export interface DaySchedule { enabled: boolean timeSlots: TimeSlot[] } export interface JobData { currentStep:number _id?: string // Added _id for MongoDB documents userId: string title: string description: string jobType: string urgencyType: "standard" | "last_minute" splitJobs: boolean parentJobId?: string supportTypes: string[] activities: { dailyLiving: boolean dailyLivingActivities: string[] personalCare: boolean personalCareActivities: string[] nursing: boolean nursingActivities: string[] alliedHealth: boolean alliedHealthActivities: string[] } location: { suburb: string postcode: string } schedule: { frequency: string sessionsPerWeek: number hoursPerWeek: number startDate: string startDateSpecif: string flexible: boolean preferredDays?: string[] daySchedules?: Record<string, DaySchedule> } requirements: { equipmentProvided: boolean workerGenderPreference?: string preferredQualities?: string } status: "draft" | "active" | "filled" | "closed" createdAt?: string | Date updatedAt?: string | Date responses?: number // Added responses field }
export const jobService = {
// Get jobs filtered by status
getJobs: (status: string) => api.get<{ message: string; jobs: JobData[] }>(/provider/jobs${status ?
?status=${status} : ''}
),
// Get a specific job
getJob: (id: string) => api.get<{ message: string; job: JobData }>(/provider/client/job/${id}
),
// Create a new job createJob: (job: JobData) => api.post<{ message: string; job: JobData }>("/provider/client/add-job", job),
// Create multiple jobs createMultipleJobs: (jobs: JobData[]) => api.post<{ message: string; jobs: JobData[] }>("/provider/client/jobs/multiple", { jobs }),
// Update an existing job
updateJob: (id: string, job: Partial<JobData>) => api.put<{ message: string; job: JobData }>(/provider/client/jobstatus/${id}
, job),
updateJobDetails: (id: string, job: JobData) => api.put<{ message: string; job: JobData }>(/provider/client/update/${id}
, job),
// Delete a job
deleteJob: (id: string) => api.delete<{ message: string }>(/api/jobs/${id}
),
// Get related jobs (for split jobs)
getRelatedJobs: (id: string) =>
api.get<{
message: string
isParent: boolean
parentJob?: JobData
relatedJobs: JobData[]
}>(/api/jobs/${id}/related
),
}
Loading...
i want filter job functionality where u done
Loading...
its working fine but you need adjustment for service . Currently I am using for each service has different options. like for allied health: "use client"
import { ActivityOption } from "@/components/jobs/activity-option"
interface AlliedHealthStepProps { formData: any updateFormData: (data: any) => void }
export default function AlliedHealthStep({ formData, updateFormData }: AlliedHealthStepProps) { const handleActivityChange = (activity: string, checked: boolean) => { let newActivities = [...(formData.activities.alliedHealthActivities || [])]
if (checked) {
newActivities.push(activity)
} else {
newActivities = newActivities.filter((a) => a !== activity)
}
updateFormData({
activities: {
...formData.activities,
alliedHealthActivities: newActivities,
},
})
}
const isActivitySelected = (activity: string) => { return formData.activities.alliedHealthActivities?.includes(activity) || false }
return ( <div className="mt-8 space-y-6"> <h2 className="text-xl font-semibold">What allied health activities do you want to include?</h2>
<div className="space-y-4">
<ActivityOption
id="physiotherapy"
title="Physiotherapy"
description="Assessment and treatment to restore movement and function after injury, illness, or disability."
checked={isActivitySelected("physiotherapy")}
onChange={(checked) => handleActivityChange("physiotherapy", checked)}
trainingRequired="Physiotherapy qualification required"
/>
<ActivityOption
id="occupational_therapy"
title="Occupational therapy"
description="Support to develop, recover, or maintain daily living and work skills."
checked={isActivitySelected("occupational_therapy")}
onChange={(checked) => handleActivityChange("occupational_therapy", checked)}
trainingRequired="Occupational therapy qualification required"
/>
<ActivityOption
id="speech_therapy"
title="Speech therapy"
description="Assessment and treatment of communication problems and swallowing difficulties."
checked={isActivitySelected("speech_therapy")}
onChange={(checked) => handleActivityChange("speech_therapy", checked)}
trainingRequired="Speech pathology qualification required"
/>
<ActivityOption
id="psychology"
title="Psychology"
description="Assessment and therapy to support mental health and emotional wellbeing."
checked={isActivitySelected("psychology")}
onChange={(checked) => handleActivityChange("psychology", checked)}
trainingRequired="Psychology qualification required"
/>
<ActivityOption
id="dietetics"
title="Dietetics"
description="Nutritional assessment and advice to support health and manage medical conditions."
checked={isActivitySelected("dietetics")}
onChange={(checked) => handleActivityChange("dietetics", checked)}
trainingRequired="Dietitian qualification required"
/>
<ActivityOption
id="podiatry"
title="Podiatry"
description="Assessment, diagnosis, and treatment of conditions affecting the feet and lower limbs."
checked={isActivitySelected("podiatry")}
onChange={(checked) => handleActivityChange("podiatry", checked)}
trainingRequired="Podiatry qualification required"
/>
</div>
</div>
) } sample save json data: "use client"
import { ActivityOption } from "@/components/jobs/activity-option"
interface AlliedHealthStepProps { formData: any updateFormData: (data: any) => void }
export default function AlliedHealthStep({ formData, updateFormData }: AlliedHealthStepProps) { const handleActivityChange = (activity: string, checked: boolean) => { let newActivities = [...(formData.activities.alliedHealthActivities || [])]
if (checked) {
newActivities.push(activity)
} else {
newActivities = newActivities.filter((a) => a !== activity)
}
updateFormData({
activities: {
...formData.activities,
alliedHealthActivities: newActivities,
},
})
}
const isActivitySelected = (activity: string) => { return formData.activities.alliedHealthActivities?.includes(activity) || false }
return ( <div className="mt-8 space-y-6"> <h2 className="text-xl font-semibold">What allied health activities do you want to include?</h2>
<div className="space-y-4">
<ActivityOption
id="physiotherapy"
title="Physiotherapy"
description="Assessment and treatment to restore movement and function after injury, illness, or disability."
checked={isActivitySelected("physiotherapy")}
onChange={(checked) => handleActivityChange("physiotherapy", checked)}
trainingRequired="Physiotherapy qualification required"
/>
<ActivityOption
id="occupational_therapy"
title="Occupational therapy"
description="Support to develop, recover, or maintain daily living and work skills."
checked={isActivitySelected("occupational_therapy")}
onChange={(checked) => handleActivityChange("occupational_therapy", checked)}
trainingRequired="Occupational therapy qualification required"
/>
<ActivityOption
id="speech_therapy"
title="Speech therapy"
description="Assessment and treatment of communication problems and swallowing difficulties."
checked={isActivitySelected("speech_therapy")}
onChange={(checked) => handleActivityChange("speech_therapy", checked)}
trainingRequired="Speech pathology qualification required"
/>
<ActivityOption
id="psychology"
title="Psychology"
description="Assessment and therapy to support mental health and emotional wellbeing."
checked={isActivitySelected("psychology")}
onChange={(checked) => handleActivityChange("psychology", checked)}
trainingRequired="Psychology qualification required"
/>
<ActivityOption
id="dietetics"
title="Dietetics"
description="Nutritional assessment and advice to support health and manage medical conditions."
checked={isActivitySelected("dietetics")}
onChange={(checked) => handleActivityChange("dietetics", checked)}
trainingRequired="Dietitian qualification required"
/>
<ActivityOption
id="podiatry"
title="Podiatry"
description="Assessment, diagnosis, and treatment of conditions affecting the feet and lower limbs."
checked={isActivitySelected("podiatry")}
onChange={(checked) => handleActivityChange("podiatry", checked)}
trainingRequired="Podiatry qualification required"
/>
</div>
</div>
) }