Skip to content

Commit

Permalink
refactor(spu-ui): migrate hooks to api-client and remove unused hooks
Browse files Browse the repository at this point in the history
also updated the api-client hooks export for better path resolving
i did the ugly, breno
  • Loading branch information
matyson committed Jan 21, 2025
1 parent 6e6f269 commit cc3e178
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 151 deletions.
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/_components/env-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { useStatus } from "@sophys-web/api-client/hooks/use-status";
import { cn } from "@sophys-web/ui";
import { buttonVariants } from "@sophys-web/ui/button";
import {
Expand All @@ -10,7 +11,6 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@sophys-web/ui/dropdown-menu";
import { useStatus } from "../_hooks/use-status";

export function EnvMenu() {
const { status, envUpdate, envOpen, envClose } = useStatus();
Expand Down
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/_components/history.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import { RotateCcwIcon } from "lucide-react";
import { useQueue } from "@sophys-web/api-client/hooks/use-queue";
import { api } from "@sophys-web/api-client/react";
import { cn } from "@sophys-web/ui";
import { Button } from "@sophys-web/ui/button";
Expand All @@ -13,7 +14,6 @@ import {
} from "@sophys-web/ui/card";
import { ScrollArea } from "@sophys-web/ui/scroll-area";
import type { HistoryItemProps } from "../../lib/types";
import { useQueue } from "../_hooks/use-queue";
import {
formatPlanNames,
PlanContent,
Expand Down
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/_components/on-demand/cleaning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useState } from "react";
import { zodResolver } from "@hookform/resolvers/zod";
import { DropletIcon } from "lucide-react";
import { useForm } from "react-hook-form";
import { useQueue } from "@sophys-web/api-client/hooks/use-queue";
import { Button } from "@sophys-web/ui/button";
import {
Dialog,
Expand Down Expand Up @@ -30,7 +31,6 @@ import {
SelectValue,
} from "@sophys-web/ui/select";
import { toast } from "@sophys-web/ui/sonner";
import { useQueue } from "~/app/_hooks/use-queue";
import { cleaningAgents, cleaningDefaults } from "../../../lib/constants";
import {
schema as cleaningKwargsSchema,
Expand Down
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/_components/on-demand/queue-stop.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SquareIcon } from "lucide-react";
import { useQueue } from "@sophys-web/api-client/hooks/use-queue";
import { Button } from "@sophys-web/ui/button";
import { useQueue } from "~/app/_hooks/use-queue";

export function QueueStop({ className }: { className?: string }) {
const { add } = useQueue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useState } from "react";
import { zodResolver } from "@hookform/resolvers/zod";
import { CameraIcon } from "lucide-react";
import { useForm } from "react-hook-form";
import { useQueue } from "@sophys-web/api-client/hooks/use-queue";
import { cn } from "@sophys-web/ui";
import { Button } from "@sophys-web/ui/button";
import { Checkbox } from "@sophys-web/ui/checkbox";
Expand Down Expand Up @@ -34,7 +35,6 @@ import {
} from "@sophys-web/ui/select";
import { toast } from "@sophys-web/ui/sonner";
import type { LastSampleParams } from "~/app/_hooks/use-capillary-state";
import { useQueue } from "~/app/_hooks/use-queue";
import { acquireTimeOptions, sampleTypeOptions } from "~/lib/constants";
import { name, schema } from "~/lib/schemas/plans/single-acquisition";

Expand Down
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/_components/queue/queue-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import { GripVerticalIcon, XIcon } from "lucide-react";
import { z } from "zod";
import { useQueue } from "@sophys-web/api-client/hooks/use-queue";
import { cn } from "@sophys-web/ui";
import { Badge } from "@sophys-web/ui/badge";
import { Button } from "@sophys-web/ui/button";
Expand All @@ -14,7 +15,6 @@ import {
CardTitle,
} from "@sophys-web/ui/card";
import type { QueueItemProps } from "../../../lib/types";
import { useQueue } from "../../_hooks/use-queue";
import { ItemEditDialog } from "./item-edit-dialog";

export function formatPlanNames(name: string) {
Expand Down
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/_components/queue/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CheckIcon, MoveRightIcon, UploadIcon } from "lucide-react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import type { Session } from "@sophys-web/auth";
import { useQueue } from "@sophys-web/api-client/hooks/use-queue";
import { api } from "@sophys-web/api-client/react";
import { cn } from "@sophys-web/ui";
import { Button } from "@sophys-web/ui/button";
Expand Down Expand Up @@ -36,7 +37,6 @@ import type {
cleaningSchema as cleaningKwargsSchema,
} from "../../../lib/schemas/plans/complete-acquisition";
import type { Sample } from "../sample";
import { useQueue } from "../../_hooks/use-queue";
import { name as cleanCapillaryPlanName } from "../../../lib/schemas/plans/clean-and-acquire";
import { name as acquisitionPlanName } from "../../../lib/schemas/plans/complete-acquisition";
import {
Expand Down
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/_components/run-engine-controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Play,
Square,
} from "lucide-react";
import { useStatus } from "@sophys-web/api-client/hooks/use-status";
import { api } from "@sophys-web/api-client/react";
import { Button } from "@sophys-web/ui/button";
import {
Expand All @@ -16,7 +17,6 @@ import {
DropdownMenuTrigger,
} from "@sophys-web/ui/dropdown-menu";
import { toast } from "@sophys-web/ui/sonner";
import { useStatus } from "../_hooks/use-status";

type EngineStatus = "idle" | "running" | "paused" | "unknown";
type EngineAction = "pause" | "resume" | "stop" | "halt" | "abort";
Expand Down
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/_components/sample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useState } from "react";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { useQueue } from "@sophys-web/api-client/hooks/use-queue";
import { cn } from "@sophys-web/ui";
import { Button } from "@sophys-web/ui/button";
import {
Expand Down Expand Up @@ -45,7 +46,6 @@ import type {
trayRows,
} from "~/lib/constants";
import { name, schema } from "~/lib/schemas/plans/load";
import { useQueue } from "../_hooks/use-queue";
import { getSamples, setSamples } from "../actions/samples";

export interface Sample {
Expand Down
104 changes: 0 additions & 104 deletions apps/spu-ui/src/app/_hooks/use-queue.tsx

This file was deleted.

31 changes: 0 additions & 31 deletions apps/spu-ui/src/app/_hooks/use-status.tsx

This file was deleted.

10 changes: 3 additions & 7 deletions packages/api-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@
"types": "./dist/src/env.d.ts",
"default": "./src/env.ts"
},
"./hooks/use-queue": {
"types": "./dist/src/hooks/use-queue.d.ts",
"default": "./src/hooks/use-queue.tsx"
},
"./hooks/use-status": {
"types": "./dist/src/hooks/use-status.d.ts",
"default": "./src/hooks/use-status.tsx"
"./hooks/*": {
"types": "./dist/src/hooks/*.d.ts",
"default": "./src/hooks/*.ts"
}
},
"license": "MIT",
Expand Down

0 comments on commit cc3e178

Please sign in to comment.