Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianAnzinger committed Nov 28, 2024
1 parent 1aed65e commit e20c35c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 39 deletions.
4 changes: 2 additions & 2 deletions atlas-metrics/app/components/custom/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"use client";

import { DateRangePicker } from "@components/custom/DateRangePicker";
import {ServiceSelect} from "@components/custom/ServiceSelect";
import { ServiceSelect } from "@components/custom/ServiceSelect";

const services = ["Service A", "Service B"];

export function Menu() {
return (
<div className="grid auto-cols-max grid-flow-col justify-end gap-5 pb-5">
<ServiceSelect selectedService={services[0]} services={services}/>
<ServiceSelect selectedService={services[0]} services={services} />
<DateRangePicker />
</div>
);
Expand Down
69 changes: 34 additions & 35 deletions atlas-metrics/app/components/custom/ServiceSelect.tsx
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>
);
}
3 changes: 1 addition & 2 deletions atlas-metrics/app/lib/api-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { EnumLike } from "zod/lib/types";
import { z } from "zod";
import { EnumLike, z } from "zod";
import { NextResponse } from "next/server";

export const SearchParamStringOrUndefined = (searchParams: URLSearchParams, key: string) => {
Expand Down

0 comments on commit e20c35c

Please sign in to comment.