Skip to content

Commit

Permalink
fix(ui): Dynamic link to workflow/cases
Browse files Browse the repository at this point in the history
  • Loading branch information
topher-lo committed Mar 7, 2024
1 parent a42b915 commit 6a78976
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions frontend/src/components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useEffect, useState } from "react"
import Link from "next/link"
import { usePathname, useSearchParams } from "next/navigation"
import { useParams, usePathname } from "next/navigation"
import axios from "axios"
import { BellRingIcon, WorkflowIcon } from "lucide-react"

Expand All @@ -14,8 +14,8 @@ import WorkflowSwitcher from "@/components/workflow-switcher"

export function Navbar() {
const [enableWorkflow, setEnableWorkflow] = useState(false)
const searchParams = useSearchParams()
const workflowId = searchParams.get("id")
const params = useParams()
const workflowId = params["id"]
const pathname = usePathname()

useEffect(() => {
Expand Down Expand Up @@ -44,6 +44,10 @@ export function Navbar() {
updateWorkflowStatus()
}, [enableWorkflow, workflowId])

if (!workflowId) {
return <h1>FUCK</h1>
}

return (
<div className="border-b">
<div className="flex h-16 items-center px-4">
Expand All @@ -52,15 +56,19 @@ export function Navbar() {
workflows when page is switched between workflow view and cases view
*/}
<WorkflowSwitcher />
<Tabs value={pathname === "/" ? "workflow" : "cases"}>
<Tabs value={pathname.endsWith("/cases") ? "cases" : "workflow"}>
<TabsList className="grid w-full grid-cols-2">
<Link href="/" className="w-full" passHref>
<TabsTrigger className="w-full" value="workflow">
<WorkflowIcon className="mr-2 h-4 w-4" />
Workflow
</TabsTrigger>
</Link>
<Link href="/cases" className="w-full" passHref>
<Link
href={`/workflows/${workflowId}/cases`}
className="w-full"
passHref
>
<TabsTrigger className="w-full" value="cases">
<BellRingIcon className="mr-2 h-4 w-4" />
Cases
Expand Down

0 comments on commit 6a78976

Please sign in to comment.