Skip to content

Commit

Permalink
feat(spu-ui): migrate API imports to use @sophys-web/api-client
Browse files Browse the repository at this point in the history
  • Loading branch information
brnovasco committed Jan 6, 2025
1 parent 0bf4a21 commit b5adac9
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 130 deletions.
7 changes: 6 additions & 1 deletion apps/spu-ui/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ const config = {
/** enable standalone output for docker self-hosting */
// output: "standalone",
/** Enables hot reloading for local packages without a build step */
transpilePackages: ["@sophys-web/ui", "@sophys-web/api", "@sophys-web/auth"],
transpilePackages: [
"@sophys-web/ui",
"@sophys-web/api",
"@sophys-web/auth",
"@sophys-web/api-client",
],
/** We already do linting and typechecking as separate tasks in CI */
eslint: { ignoreDuringBuilds: true },
typescript: { ignoreBuildErrors: true },
Expand Down
1 change: 1 addition & 0 deletions apps/spu-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@sophys-web/api": "workspace:*",
"@sophys-web/auth": "workspace:*",
"@sophys-web/ui": "workspace:*",
"@sophys-web/api-client": "workspace:*",
"@t3-oss/env-nextjs": "^0.10.1",
"@trpc/next": "11.0.0-rc.645",
"@tanstack/react-query-devtools": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/_components/console.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { useEffect, useRef } from "react";
import { DownloadIcon, RotateCcwIcon, Trash2Icon } from "lucide-react";
import { api } from "@sophys-web/api-client/react";
import { cn } from "@sophys-web/ui";
import { Button } from "@sophys-web/ui/button";
import { ScrollArea } from "@sophys-web/ui/scroll-area";
Expand All @@ -11,7 +12,6 @@ import {
TooltipProvider,
TooltipTrigger,
} from "@sophys-web/ui/tooltip";
import { api } from "../../trpc/react";

export function Console({ className }: { className?: string }) {
const { data: messages, refetch } = api.consoleOutput.stream.useQuery();
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 { api } from "@sophys-web/api-client/react";
import { cn } from "@sophys-web/ui";
import { Badge } from "@sophys-web/ui/badge";
import { Button } from "@sophys-web/ui/button";
Expand All @@ -16,7 +17,6 @@ import { ScrollArea } from "@sophys-web/ui/scroll-area";
import type { HistoryItemProps } from "../../lib/types";
import { useQueue } from "../_hooks/use-queue";
import { schema } from "../../lib/schemas/plans/complete-acquisition";
import { api } from "../../trpc/react";

function RedoButton(props: HistoryItemProps) {
const { add } = useQueue();
Expand Down
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/_components/queue/queue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { useCallback } from "react";
import { PlayIcon, SquareIcon, Trash2Icon } from "lucide-react";
import { api } from "@sophys-web/api-client/react";
import { Button } from "@sophys-web/ui/button";
import {
DropdownMenu,
Expand All @@ -13,7 +14,6 @@ import { ScrollArea } from "@sophys-web/ui/scroll-area";
import { toast } from "@sophys-web/ui/sonner";
import { useQueue } from "../../_hooks/use-queue";
import { useStatus } from "../../_hooks/use-status";
import { api } from "../../../trpc/react";
import { EnvMenu } from "../env-menu";
import { History } from "../history";
import { getEngineStatus } from "../run-engine-controls";
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 @@ -5,6 +5,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { MoveRightIcon, UploadIcon } from "lucide-react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { api } from "@sophys-web/api-client/react";
import { Button } from "@sophys-web/ui/button";
import { Checkbox } from "@sophys-web/ui/checkbox";
import {
Expand Down Expand Up @@ -33,7 +34,6 @@ import type {
cleaningSchema as cleaningKwargsSchema,
} from "../../../lib/schemas/plans/complete-acquisition";
import type { Sample } from "../sample";
import { api } from "~/trpc/react";
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";
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 { api } from "@sophys-web/api-client/react";
import { Button } from "@sophys-web/ui/button";
import {
DropdownMenu,
Expand All @@ -16,7 +17,6 @@ import {
} from "@sophys-web/ui/dropdown-menu";
import { toast } from "@sophys-web/ui/sonner";
import { useStatus } from "../_hooks/use-status";
import { api } from "../../trpc/react";

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/select-plan.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"use client";

import { useState } from "react";
import { api } from "@sophys-web/api-client/react";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@sophys-web/ui/select";
import { api } from "../../trpc/react";

export function SelectPlan() {
const { data } = api.plans.allowed.useQuery(undefined);
Expand Down
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/_hooks/use-capillary-state.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useState } from "react";
import { api } from "@sophys-web/api-client/react";
import type {
sampleTypeOptions,
trayColumns,
Expand All @@ -11,7 +12,6 @@ import {
schema as loadSampleKwargs,
name as loadSamplePlan,
} from "../../lib/schemas/plans/load";
import { api } from "../../trpc/react";

const STALE_TIME_IN_SECONDS = 15 * 60; // 15 minutes

Expand Down
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/_hooks/use-queue.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";

import { nanoid } from "nanoid";
import { api } from "@sophys-web/api-client/react";
import type { QueueItemProps } from "../../lib/types";
import { api } from "../../trpc/react";

export const useQueue = () => {
const utils = api.useUtils();
Expand Down
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/_hooks/use-status.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { api } from "../../trpc/react";
import { api } from "@sophys-web/api-client/react";

export const useStatus = () => {
const utils = api.useUtils();
Expand Down
2 changes: 1 addition & 1 deletion apps/spu-ui/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import "./globals.css";
import type { Metadata } from "next";
import Image from "next/image";
import { GeistMono } from "geist/font/mono";
import { TRPCReactProvider } from "@sophys-web/api-client/react";
import { Toaster } from "@sophys-web/ui/sonner";
import { env } from "../env";
import { TRPCReactProvider } from "../trpc/react";
import UserAvatar from "./_components/user-avatar";

export const metadata: Metadata = {
Expand Down
25 changes: 0 additions & 25 deletions apps/spu-ui/src/trpc/query-client.ts

This file was deleted.

66 changes: 0 additions & 66 deletions apps/spu-ui/src/trpc/react.tsx

This file was deleted.

28 changes: 0 additions & 28 deletions apps/spu-ui/src/trpc/server.ts

This file was deleted.

3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b5adac9

Please sign in to comment.