-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1aed65e
commit e20c35c
Showing
3 changed files
with
37 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,43 @@ | ||
import {useRouter} from "next/navigation"; | ||
import { useRouter } from "next/navigation"; | ||
import { | ||
Select, | ||
SelectContent, | ||
SelectGroup, | ||
SelectItem, | ||
SelectLabel, | ||
SelectTrigger, | ||
SelectValue | ||
Select, | ||
SelectContent, | ||
SelectGroup, | ||
SelectItem, | ||
SelectLabel, | ||
SelectTrigger, | ||
SelectValue, | ||
} from "@components/ui/select"; | ||
|
||
interface ServiceSelectProps { | ||
selectedService: string; | ||
services: string[]; | ||
selectedService: string; | ||
services: string[]; | ||
} | ||
|
||
|
||
export function ServiceSelect({ selectedService, services }: ServiceSelectProps) { | ||
const router = useRouter(); | ||
const router = useRouter(); | ||
|
||
const handleItemClick = (newService: string) => { | ||
const params = new URLSearchParams(window.location.search); | ||
params.set("service", newService); | ||
router.push(`${window.location.pathname}?${params.toString()}`); | ||
}; | ||
const handleItemClick = (newService: string) => { | ||
const params = new URLSearchParams(window.location.search); | ||
params.set("service", newService); | ||
router.push(`${window.location.pathname}?${params.toString()}`); | ||
}; | ||
|
||
return ( | ||
<Select defaultValue={selectedService} onValueChange={(value) => handleItemClick(value)}> | ||
<SelectTrigger className="w-[180px]"> | ||
<SelectValue placeholder="Select a service" /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
<SelectGroup> | ||
<SelectLabel>Service</SelectLabel> | ||
{services.map((service) => ( | ||
<SelectItem key={service} value={service}> | ||
{service[0].toUpperCase() + service.slice(1)} | ||
</SelectItem> | ||
))} | ||
</SelectGroup> | ||
</SelectContent> | ||
</Select> | ||
); | ||
} | ||
return ( | ||
<Select defaultValue={selectedService} onValueChange={(value) => handleItemClick(value)}> | ||
<SelectTrigger className="w-[180px]"> | ||
<SelectValue placeholder="Select a service" /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
<SelectGroup> | ||
<SelectLabel>Service</SelectLabel> | ||
{services.map((service) => ( | ||
<SelectItem key={service} value={service}> | ||
{service[0].toUpperCase() + service.slice(1)} | ||
</SelectItem> | ||
))} | ||
</SelectGroup> | ||
</SelectContent> | ||
</Select> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters