diff --git a/src/components/ui/tooltip-shortcut.tsx b/src/components/ui/tooltip-shortcut.tsx
index aa64261..6712c36 100644
--- a/src/components/ui/tooltip-shortcut.tsx
+++ b/src/components/ui/tooltip-shortcut.tsx
@@ -1,28 +1,19 @@
-import React, { ReactNode } from 'react';
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "../shadcn/tooltip";
-import Shortcut from './shortcut';
+import React, { ReactNode } from "react"
+import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../shadcn/tooltip"
+import Shortcut from "./shortcut"
interface TooltipShortcutProps {
- children: ReactNode;
- tooltip: string;
- shortcuts: string[];
+ children: ReactNode
+ tooltip: string
+ shortcuts: string[]
}
interface TooltipShortcutTriggerProps {
- children: ReactNode;
+ children: ReactNode
}
export function TooltipShortcutTrigger({ children }: TooltipShortcutTriggerProps) {
- return (
-
- {children}
-
- );
+ return
{children}
}
export default function TooltipShortcut({ children, tooltip, shortcuts }: TooltipShortcutProps) {
@@ -43,5 +34,5 @@ export default function TooltipShortcut({ children, tooltip, shortcuts }: Toolti
- );
-}
\ No newline at end of file
+ )
+}
diff --git a/src/lib/hook/use-is-mobile.ts b/src/lib/hook/use-is-mobile.ts
index 38e9224..c79994e 100644
--- a/src/lib/hook/use-is-mobile.ts
+++ b/src/lib/hook/use-is-mobile.ts
@@ -1,8 +1,8 @@
-import * as React from 'react'
+import * as React from "react"
export const useIsMobile = (mobileScreenSize = 768) => {
- if (typeof window.matchMedia !== 'function') {
- throw Error('matchMedia not supported by browser!')
+ if (typeof window.matchMedia !== "function") {
+ throw Error("matchMedia not supported by browser!")
}
const [isMobile, setIsMobile] = React.useState(window.matchMedia(`(max-width: ${mobileScreenSize}px)`).matches)
@@ -14,14 +14,14 @@ export const useIsMobile = (mobileScreenSize = 768) => {
const mediaListener = window.matchMedia(`(max-width: ${mobileScreenSize}px)`)
// try catch used to fallback for browser compatibility
try {
- mediaListener.addEventListener('change', checkIsMobile)
+ mediaListener.addEventListener("change", checkIsMobile)
} catch {
mediaListener.addListener(checkIsMobile)
}
return () => {
try {
- mediaListener.removeEventListener('change', checkIsMobile)
+ mediaListener.removeEventListener("change", checkIsMobile)
} catch {
mediaListener.removeListener(checkIsMobile)
}
diff --git a/src/lib/hook/use-key-press.ts b/src/lib/hook/use-key-press.ts
index b3386b7..02fe8e2 100644
--- a/src/lib/hook/use-key-press.ts
+++ b/src/lib/hook/use-key-press.ts
@@ -1,8 +1,13 @@
-import { useCallback, useEffect, useLayoutEffect, useRef } from 'react'
+import { useCallback, useEffect, useLayoutEffect, useRef } from "react"
type KeyHandler = (event: KeyboardEvent) => void
-export const useKeyPress = (targetKey: string, callback: KeyHandler, modifiers: Array<'ctrlKey' | 'shiftKey' | 'altKey' | 'metaKey'> = [], node: HTMLElement | Document | null = null) => {
+export const useKeyPress = (
+ targetKey: string,
+ callback: KeyHandler,
+ modifiers: Array<"ctrlKey" | "shiftKey" | "altKey" | "metaKey"> = [],
+ node: HTMLElement | Document | null = null
+) => {
const callbackRef = useRef(callback)
useLayoutEffect(() => {
@@ -23,7 +28,7 @@ export const useKeyPress = (targetKey: string, callback: KeyHandler, modifiers:
useEffect(() => {
const targetNode = node ?? document
- targetNode.addEventListener('keydown', handleKeyPress as EventListener)
- return () => targetNode.removeEventListener('keydown', handleKeyPress as EventListener)
+ targetNode.addEventListener("keydown", handleKeyPress as EventListener)
+ return () => targetNode.removeEventListener("keydown", handleKeyPress as EventListener)
}, [handleKeyPress, node])
}
diff --git a/src/lib/language.ts b/src/lib/language.ts
index 5dfbe5d..798c85d 100644
--- a/src/lib/language.ts
+++ b/src/lib/language.ts
@@ -1,6 +1,6 @@
interface Language {
- name: string;
- extension: string;
+ name: string
+ extension: string
}
const languages: Language[] = [
@@ -97,22 +97,20 @@ const languages: Language[] = [
{ name: "verilog", extension: "v" },
{ name: "vue", extension: "vue" },
{ name: "xml", extension: "xml" },
-];
+]
function isDocker(file_name: string) {
- return file_name === "Dockerfile";
+ return file_name === "Dockerfile"
}
function defaultStrategy(file_name: string) {
- const extension = file_name.split(".").pop();
- return (
- languages.find((lang) => lang.extension === extension)?.name || "plaintext"
- );
+ const extension = file_name.split(".").pop()
+ return languages.find((lang) => lang.extension === extension)?.name || "plaintext"
}
export function getLanguage(file_name: string) {
if (isDocker(file_name)) {
- return "dockerfile";
+ return "dockerfile"
}
- return defaultStrategy(file_name);
+ return defaultStrategy(file_name)
}
diff --git a/src/lib/queries/auth.queries.tsx b/src/lib/queries/auth.queries.tsx
index 371d68b..5b4177e 100644
--- a/src/lib/queries/auth.queries.tsx
+++ b/src/lib/queries/auth.queries.tsx
@@ -1,52 +1,46 @@
-"use client";
-import ky from "ky";
-import { getBackendURL } from "../utils";
-import { useMutation, useQueryClient } from "@tanstack/react-query";
-import getQueryClient from "./queries";
+"use client"
+import ky from "ky"
+import { getBackendURL } from "../utils"
+import { useMutation, useQueryClient } from "@tanstack/react-query"
+import getQueryClient from "./queries"
const fetchLocalAuth = async ({ email }: { email: string }) => {
const json = await ky
.post(`${getBackendURL()}/auth/local/begin`, {
json: { email },
})
- .json();
+ .json()
- return json; //no need to assert type since the most important is the status code
-};
+ return json //no need to assert type since the most important is the status code
+}
-const fetchLocalAuthVerify = async ({
- email,
- token,
-}: {
- email: string;
- token: string;
-}) => {
+const fetchLocalAuthVerify = async ({ email, token }: { email: string; token: string }) => {
const json = await ky
.post(`${getBackendURL()}/auth/local/verify`, {
json: { email, token },
credentials: "include",
})
- .json();
- return json;
-};
+ .json()
+ return json
+}
const fetchLogout = async () => {
const json = await ky
.post(`${getBackendURL()}/auth/logout`, {
credentials: "include",
})
- .json();
- return json;
-};
+ .json()
+ return json
+}
export const renewToken = async () => {
const json = await ky
.post(`${getBackendURL()}/auth/identity/renew`, {
credentials: "include",
})
- .json();
- return json;
-};
+ .json()
+ return json
+}
/**
* Start the local authentication process by sending an email to the user
@@ -56,31 +50,31 @@ export const renewToken = async () => {
export const useLocalAuth = () => {
const { mutate, error, isPending } = useMutation({
mutationFn: (email: string) => {
- return fetchLocalAuth({ email });
+ return fetchLocalAuth({ email })
},
- });
- return { mutate, error, isPending };
-};
+ })
+ return { mutate, error, isPending }
+}
export const useLocalAuthVerify = () => {
const { mutate, error, isPending, data } = useMutation({
mutationFn: ({ email, token }: { email: string; token: string }) => {
- return fetchLocalAuthVerify({ email, token });
+ return fetchLocalAuthVerify({ email, token })
},
- });
- return { mutate, error, isPending, data };
-};
+ })
+ return { mutate, error, isPending, data }
+}
export const useLogout = ({ onSuccess }: { onSuccess?: () => void } = {}) => {
- const queryClient = useQueryClient();
+ const queryClient = useQueryClient()
const { mutate, error, isPending } = useMutation({
mutationFn: () => {
- return fetchLogout();
+ return fetchLogout()
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: ["me"] });
- onSuccess && onSuccess();
+ queryClient.invalidateQueries({ queryKey: ["me"] })
+ onSuccess && onSuccess()
},
- });
- return { mutate, error, isPending };
-};
+ })
+ return { mutate, error, isPending }
+}
diff --git a/src/lib/queries/gists.queries.tsx b/src/lib/queries/gists.queries.tsx
index 0c2d225..9350069 100644
--- a/src/lib/queries/gists.queries.tsx
+++ b/src/lib/queries/gists.queries.tsx
@@ -1,22 +1,22 @@
-"use client";
-import ky from "ky";
-import { getBackendURL } from "../utils";
-import { Gist } from "@/types";
-import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
+"use client"
+import ky from "ky"
+import { getBackendURL } from "../utils"
+import { Gist } from "@/types"
+import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
//types
export interface ApiGist {
- id: string;
- name: string;
- content: string;
- owner_id: string;
- org_id: string | null;
+ id: string
+ name: string
+ content: string
+ owner_id: string
+ org_id: string | null
}
export interface GistsWithPaginate {
- gists: ApiGist[];
- nb_pages: number;
+ gists: ApiGist[]
+ nb_pages: number
}
//fetches
@@ -24,46 +24,46 @@ const fetchGists = async ({
offset,
limit,
}: {
- offset: number;
- limit: number;
+ offset: number
+ limit: number
}): Promise<{
- gists: Gist[];
- nb_pages: number;
+ gists: Gist[]
+ nb_pages: number
}> => {
const json = await ky
.get(`${getBackendURL()}/gists?offset=${offset}&limit=${limit}`, {
credentials: "include",
})
- .json
();
+ .json()
return {
gists: json.gists.map((gist) => {
return {
id: gist.id,
name: gist.name,
code: gist.content,
- } as Gist;
+ } as Gist
}),
nb_pages: json.nb_pages,
- };
-};
+ }
+}
const fetchGist = async (gistId: string): Promise => {
const json = await ky
.get(`${getBackendURL()}/gists/${gistId}`, {
credentials: "include",
})
- .json();
+ .json()
return {
id: json.id,
name: json.name,
code: json.content,
- };
-};
+ }
+}
export interface CreateGistPayload {
- name: string;
- content: string;
- org_id?: string;
+ name: string
+ content: string
+ org_id?: string
}
const fetchCreateGist = async (gist: CreateGistPayload): Promise => {
@@ -72,75 +72,65 @@ const fetchCreateGist = async (gist: CreateGistPayload): Promise => {
credentials: "include",
json: gist,
})
- .json