Skip to content

Commit

Permalink
ran fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshayBandi027 committed Oct 5, 2024
1 parent 916139c commit 31165df
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 132 deletions.
4 changes: 2 additions & 2 deletions apps/dashboard/app/(app)/apis/create-api-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const CreateApiButton = ({ ...rest }: React.ButtonHTMLAttributes<HTMLButt
async onSuccess(res) {
toast.success("Your API has been created");

await revalidate("/apis")
await revalidate("/apis");

router.push(`/apis/${res.id}`);
},
onError(err) {
Expand Down
117 changes: 53 additions & 64 deletions apps/dashboard/app/(app)/desktop-sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,60 +1,53 @@
"use client"
import { Feedback } from "@/components/dashboard/feedback-component"
import { Badge } from "@/components/ui/badge"
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip"
import {
createWorkspaceNavigation,
resourcesNavigation,
} from "@/app/(app)/workspace-navigations"
import type { Workspace } from "@/lib/db"
import { useDelayLoader } from "@/lib/hooks/useDelayLoader"
import { cn } from "@/lib/utils"
import { Loader2, type LucideIcon } from "lucide-react"
import Link from "next/link"
import { useSelectedLayoutSegments } from "next/navigation"
import { useRouter } from "next/navigation"
import type React from "react"
import { useTransition } from "react"
import { WorkspaceSwitcher } from "./team-switcher"
import { UserButton } from "./user-button"
"use client";
import { createWorkspaceNavigation, resourcesNavigation } from "@/app/(app)/workspace-navigations";
import { Feedback } from "@/components/dashboard/feedback-component";
import { Badge } from "@/components/ui/badge";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import type { Workspace } from "@/lib/db";
import { useDelayLoader } from "@/lib/hooks/useDelayLoader";
import { cn } from "@/lib/utils";
import { Loader2, type LucideIcon } from "lucide-react";
import Link from "next/link";
import { useSelectedLayoutSegments } from "next/navigation";
import { useRouter } from "next/navigation";
import type React from "react";
import { useTransition } from "react";
import { WorkspaceSwitcher } from "./team-switcher";
import { UserButton } from "./user-button";
type Props = {
workspace: Workspace & {
apis: {
id: string
name: string
}[]
}
className?: string
}
id: string;
name: string;
}[];
};
className?: string;
};

type NavItem = {
disabled?: boolean
tooltip?: string
icon: LucideIcon | React.ElementType
href: string
external?: boolean
label: string
active?: boolean
tag?: React.ReactNode
hidden?: boolean
}
disabled?: boolean;
tooltip?: string;
icon: LucideIcon | React.ElementType;
href: string;
external?: boolean;
label: string;
active?: boolean;
tag?: React.ReactNode;
hidden?: boolean;
};

export const DesktopSidebar: React.FC<Props> = ({ workspace, className }) => {
const segments = useSelectedLayoutSegments() ?? []
const workspaceNavigation = createWorkspaceNavigation(workspace, segments)
const segments = useSelectedLayoutSegments() ?? [];
const workspaceNavigation = createWorkspaceNavigation(workspace, segments);

const firstOfNextMonth = new Date()
firstOfNextMonth.setUTCMonth(firstOfNextMonth.getUTCMonth() + 1)
firstOfNextMonth.setDate(1)
const firstOfNextMonth = new Date();
firstOfNextMonth.setUTCMonth(firstOfNextMonth.getUTCMonth() + 1);
firstOfNextMonth.setDate(1);
return (
<aside
className={cn(
"bg-background text-content/65 inset-y-0 w-64 px-5 z-10 h-full shrink-0 flex flex-col overflow-y-auto",
className
className,
)}
>
<div className="flex min-w-full mt-2 -mx-2">
Expand All @@ -67,9 +60,8 @@ export const DesktopSidebar: React.FC<Props> = ({ workspace, className }) => {
<Badge size="sm">Subscription ending</Badge>
</TooltipTrigger>
<TooltipContent>
Your plan is schedueld to be downgraded to the{" "}
{workspace.planDowngradeRequest} tier on{" "}
{firstOfNextMonth.toDateString()}
Your plan is schedueld to be downgraded to the {workspace.planDowngradeRequest} tier
on {firstOfNextMonth.toDateString()}
</TooltipContent>
</Tooltip>
</div>
Expand Down Expand Up @@ -109,22 +101,22 @@ export const DesktopSidebar: React.FC<Props> = ({ workspace, className }) => {
<div className="pointer-events-none absolute bottom-full inset-x-0 h-10 bg-[inherit] [mask-image:linear-gradient(to_top,white,transparent)]" />
</div>
</aside>
)
}
);
};

const NavLink: React.FC<{ item: NavItem }> = ({ item }) => {
const [isPending, startTransition] = useTransition()
const showLoader = useDelayLoader(isPending)
const router = useRouter()
const [isPending, startTransition] = useTransition();
const showLoader = useDelayLoader(isPending);
const router = useRouter();
const link = (
<Link
prefetch
href={item.href}
onClick={() => {
if (!item.external) {
startTransition(() => {
router.push(item.href)
})
router.push(item.href);
});
}
}}
target={item.external ? "_blank" : undefined}
Expand All @@ -134,25 +126,22 @@ const NavLink: React.FC<{ item: NavItem }> = ({ item }) => {
"bg-background border-border text-content [box-shadow:0px_1px_3px_0px_rgba(0,0,0,0.03)]":
item.active,
"text-content-subtle pointer-events-none": item.disabled,
}
},
)}
>
<div className="flex items-center group gap-x-2">
<span className="flex h-5 w-5 shrink-0 items-center justify-center text-[0.625rem]">
{showLoader ? (
<Loader2 className="w-5 h-5 shrink-0 animate-spin" />
) : (
<item.icon
className="w-5 h-5 shrink-0 [stroke-width:1.25px]"
aria-hidden="true"
/>
<item.icon className="w-5 h-5 shrink-0 [stroke-width:1.25px]" aria-hidden="true" />
)}
</span>
<p className="truncate whitespace-nowrap">{item.label}</p>
</div>
{item.tag}
</Link>
)
);

if (item.tooltip) {
return (
Expand All @@ -162,7 +151,7 @@ const NavLink: React.FC<{ item: NavItem }> = ({ item }) => {
<TooltipContent>{item.tooltip}</TooltipContent>
</TooltipTrigger>
</Tooltip>
)
);
}
return link
}
return link;
};
66 changes: 25 additions & 41 deletions apps/dashboard/app/(app)/mobile-sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@
"use client"
import { Feedback } from "@/components/dashboard/feedback-component"
import { Button } from "@/components/ui/button"
import { Separator } from "@/components/ui/separator"
import {
Sheet,
SheetClose,
SheetContent,
SheetHeader,
SheetTrigger,
} from "@/components/ui/sheet"
import {
createWorkspaceNavigation,
resourcesNavigation,
} from "@/app/(app)/workspace-navigations"
import type { Workspace } from "@/lib/db"
import { cn } from "@/lib/utils"
import { Menu } from "lucide-react"
import Link from "next/link"
import { useSelectedLayoutSegments } from "next/navigation"
import { WorkspaceSwitcher } from "./team-switcher"
"use client";
import { createWorkspaceNavigation, resourcesNavigation } from "@/app/(app)/workspace-navigations";
import { Feedback } from "@/components/dashboard/feedback-component";
import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import { Sheet, SheetClose, SheetContent, SheetHeader, SheetTrigger } from "@/components/ui/sheet";
import type { Workspace } from "@/lib/db";
import { cn } from "@/lib/utils";
import { Menu } from "lucide-react";
import Link from "next/link";
import { useSelectedLayoutSegments } from "next/navigation";
import { WorkspaceSwitcher } from "./team-switcher";

type Props = {
className?: string
className?: string;
workspace: Workspace & {
apis: {
id: string
name: string
}[]
}
}
id: string;
name: string;
}[];
};
};

export const MobileSideBar = ({ className, workspace }: Props) => {
const segments = useSelectedLayoutSegments() ?? []
const segments = useSelectedLayoutSegments() ?? [];

const workspaceNavigation = createWorkspaceNavigation(workspace, segments)
const workspaceNavigation = createWorkspaceNavigation(workspace, segments);

return (
<div className={cn(className, "w-96")}>
Expand All @@ -47,14 +38,9 @@ export const MobileSideBar = ({ className, workspace }: Props) => {
<SheetHeader>
<SheetClose />
</SheetHeader>
<SheetContent
side="bottom"
className="bg-white shadow dark:bg-gray-950 rounded-xl"
>
<SheetContent side="bottom" className="bg-white shadow dark:bg-gray-950 rounded-xl">
<div className="flex flex-col w-full p-4 ">
<h2 className="px-2 mb-2 text-lg font-semibold tracking-tight">
Workspace
</h2>
<h2 className="px-2 mb-2 text-lg font-semibold tracking-tight">Workspace</h2>
<div className="space-y-1">
{workspaceNavigation.map((item) => (
<Link href={`${item.href}`} key={item.label}>
Expand All @@ -69,9 +55,7 @@ export const MobileSideBar = ({ className, workspace }: Props) => {
</div>

<Separator className="my-2" />
<h2 className="px-2 mb-2 text-lg font-semibold tracking-tight">
Resources
</h2>
<h2 className="px-2 mb-2 text-lg font-semibold tracking-tight">Resources</h2>
<div className="space-y-1">
{resourcesNavigation.map((item) => (
<Link href={`${item.href}`} target="_blank" key={item.label}>
Expand All @@ -89,5 +73,5 @@ export const MobileSideBar = ({ className, workspace }: Props) => {
</SheetContent>
</Sheet>
</div>
)
}
);
};
47 changes: 22 additions & 25 deletions apps/dashboard/app/(app)/workspace-navigations.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Workspace } from "@/lib/db";
import {
BookOpen,
Cable,
Expand All @@ -10,21 +11,20 @@ import {
MonitorDot,
Settings2,
ShieldCheck,
} from "lucide-react"
import { cn } from "../../lib/utils"
import type { Workspace } from "@/lib/db"
} from "lucide-react";
import { cn } from "../../lib/utils";

type NavItem = {
disabled?: boolean
tooltip?: string
icon: LucideIcon | React.ElementType
href: string
external?: boolean
label: string
active?: boolean
tag?: React.ReactNode
hidden?: boolean
}
disabled?: boolean;
tooltip?: string;
icon: LucideIcon | React.ElementType;
href: string;
external?: boolean;
label: string;
active?: boolean;
tag?: React.ReactNode;
hidden?: boolean;
};

const DiscordIcon = () => (
<svg
Expand All @@ -41,25 +41,22 @@ const DiscordIcon = () => (
/>
</g>
</svg>
)
);

const Tag: React.FC<{ label: string; className?: string }> = ({
label,
className,
}) => (
const Tag: React.FC<{ label: string; className?: string }> = ({ label, className }) => (
<div
className={cn(
"bg-background border text-content-subtle rounded text-xs px-1 py-0.5 font-mono ",
className
className,
)}
>
{label}
</div>
)
);

export const createWorkspaceNavigation = (
workspace: Pick<Workspace,"features"> & Pick<Workspace,"betaFeatures">,
segments: string[]
workspace: Pick<Workspace, "features"> & Pick<Workspace, "betaFeatures">,
segments: string[],
) => {
return [
{
Expand Down Expand Up @@ -121,8 +118,8 @@ export const createWorkspaceNavigation = (
label: "Settings",
active: segments.at(0) === "settings",
},
].filter((n) => !n.hidden)
}
].filter((n) => !n.hidden);
};

export const resourcesNavigation: NavItem[] = [
{
Expand All @@ -137,4 +134,4 @@ export const resourcesNavigation: NavItem[] = [
external: true,
label: "Discord",
},
]
];

0 comments on commit 31165df

Please sign in to comment.