Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #122 from floriaaan/feature/add-swagger-routes
Browse files Browse the repository at this point in the history
[FEATURE] Add swagger page
  • Loading branch information
floriaaan authored Jul 8, 2024
2 parents 99151d3 + 8c20543 commit ac499a3
Show file tree
Hide file tree
Showing 10 changed files with 4,898 additions and 5,190 deletions.
31 changes: 31 additions & 0 deletions apps/web/app/admin/docs/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use client";
import { RedocStandalone } from "redoc";
import { useQuery } from "@tanstack/react-query";
import { fetchAPI } from "@/lib/fetchAPI";
import { useAuth } from "@/hooks";

export default function Docs() {
const { user, session } = useAuth();

const { data: doc, isLoading } = useQuery({
queryKey: ["docs"],
queryFn: async () => {
const res = await fetchAPI(`/docs`, session?.token);
return await res.json();
},
});

if (isLoading) return "";

return (
<div>
<RedocStandalone
spec={doc}
options={{
nativeScrollbars: true,
theme: { colors: { primary: { main: "#F99436" } } },
}}
/>
</div>
);
}
13 changes: 13 additions & 0 deletions apps/web/components/admin/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
MdManageAccounts,
MdTableView,
MdUnfoldMore,
MdDocumentScanner,
} from "react-icons/md";

export const Sidebar = () => {
Expand Down Expand Up @@ -111,6 +112,18 @@ export const Sidebar = () => {
<MdDoneAll className="h-5 w-5 shrink-0" />
État de l’application
</Link>
{isAdmin && (
<Link
href="/admin/docs"
className={cn(
"inline-flex items-center gap-x-2 px-4 py-2 text-sm font-semibold hover:bg-black hover:bg-opacity-5",
path === "/admin/docs" && "bg-black bg-opacity-10",
)}
>
<MdDocumentScanner className="h-5 w-5 shrink-0" />
Documentation technique
</Link>
)}
</div>
</>
) : (
Expand Down
4 changes: 1 addition & 3 deletions apps/web/components/ui/sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ const SheetClose = () => (
</SheetPrimitive.Close>
);

const SheetPortal = ({ ...props }: SheetPrimitive.DialogPortalProps) => (
<SheetPrimitive.Portal {...props} />
);
const SheetPortal = ({ ...props }: SheetPrimitive.DialogPortalProps) => <SheetPrimitive.Portal {...props} />;
SheetPortal.displayName = SheetPrimitive.Portal.displayName;

const SheetOverlay = React.forwardRef<
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"react-hook-form": "^7.47.0",
"react-icons": "^5.0.1",
"react-map-gl": "^7.1.6",
"redoc": "^2.1.5",
"tailwind-merge": "^1.14.0",
"tailwindcss": "3.3.3",
"tailwindcss-animate": "^1.0.7",
Expand Down
Loading

0 comments on commit ac499a3

Please sign in to comment.