Skip to content

Commit

Permalink
feat(general): no unused vars
Browse files Browse the repository at this point in the history
  • Loading branch information
matedocebo committed Feb 27, 2024
1 parent d2efd35 commit f672016
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 84 deletions.
9 changes: 0 additions & 9 deletions app/(dashboard)/dashboard/billing/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,8 @@ import { authOptions } from "@/lib/auth"
import { getCurrentUser } from "@/lib/session"
import { stripe } from "@/lib/stripe"
import { getUserSubscriptionPlan } from "@/lib/subscription"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import { BillingForm } from "@/components/billing-form"
import { DashboardHeader } from "@/components/header"
import { Icons } from "@/components/icons"
import { DashboardShell } from "@/components/shell"

export const metadata = {
Expand Down
1 change: 0 additions & 1 deletion app/(dashboard)/dashboard/settings/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Card } from "@/components/ui/card"
import { CardSkeleton } from "@/components/card-skeleton"
import { DashboardHeader } from "@/components/header"
import { DashboardShell } from "@/components/shell"
Expand Down
5 changes: 1 addition & 4 deletions app/api/translations/[translationId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ const routeContextSchema = z.object({
}),
})

export async function DELETE(
req: Request,
context: z.infer<typeof routeContextSchema>
) {
export async function DELETE(context: z.infer<typeof routeContextSchema>) {
try {
// Validate the route params.
const { params } = routeContextSchema.parse(context)
Expand Down
2 changes: 1 addition & 1 deletion app/api/users/stripe/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { absoluteUrl } from "@/lib/utils"

const billingUrl = absoluteUrl("/dashboard/billing")

export async function GET(req: Request) {
export async function GET() {
try {
const session = await getServerSession(authOptions)

Expand Down
1 change: 0 additions & 1 deletion components/site-footer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from "react"

import { cn } from "@/lib/utils"
import { Icons } from "@/components/icons"

export function SiteFooter({ className }: React.HTMLAttributes<HTMLElement>) {
return (
Expand Down
15 changes: 1 addition & 14 deletions components/translation/table/row.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
import Image from "next/image"
import { Language } from "@/store/useI18nState"
import {
Accordion,
AccordionButton,
AccordionIcon,
AccordionItem,
AccordionPanel,
Box,
Menu,
MenuButton,
MenuItem,
MenuList,
} from "@chakra-ui/react"
import { Menu, MenuButton, MenuItem, MenuList } from "@chakra-ui/react"

import { Keyword } from "../useTranslation"

Expand Down
103 changes: 52 additions & 51 deletions components/translation/useTranslation.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { useCallback, useEffect, useMemo, useState } from "react"
import { useCallback, useMemo, useState } from "react"
import { useRouter } from "next/navigation"
import { autocompleteI18nObject } from "@/external_api/autocompleteI18nObject"
// import { autocompleteI18nObject } from "@/external_api/autocompleteI18nObject"
import {
I18n,
// I18n,
I18nInfo,
I18nLang,
Language,
useI18nState,
} from "@/store/useI18nState"
import { Spinner } from "@chakra-ui/react"
import { useMutation } from "react-query"

// import { useMutation } from "react-query"

import { EditorProps } from "."
import { toast } from "../ui/use-toast"
Expand All @@ -33,7 +33,8 @@ export type Keyword = {
}

const useTranslation = (props: EditorProps) => {
const { i18n, addTranslation, addKey, deleteKey, setI18n } = useI18nState()
const { i18n, addTranslation, addKey, deleteKey /* setI18n */ } =
useI18nState()

const keywords = useMemo((): Keyword[] => {
if (!i18n.info || !i18n.info.length) {
Expand Down Expand Up @@ -67,7 +68,7 @@ const useTranslation = (props: EditorProps) => {

const router = useRouter()

const [pauseAutocomplete, setPauseAutocomplete] = useState(false)
// const [pauseAutocomplete, setPauseAutocomplete] = useState(false)
const [isSaving, setIsSaving] = useState<boolean>(false)

const addNewKey = useCallback(
Expand All @@ -77,50 +78,50 @@ const useTranslation = (props: EditorProps) => {
[addKey]
)

const setChatGPTPause = () => {
setPauseAutocomplete(true)
setTimeout(() => {
setPauseAutocomplete(false)
}, 10000)
}

const { mutate, isLoading } = useMutation({
mutationFn: async () => await autocompleteI18nObject(i18n),
onSuccess: (data: I18n) => {
setI18n(data)
setChatGPTPause()
},
onError: (error) => {
setChatGPTPause()
},
})

const autocomplete = useCallback(() => {
mutate()
}, [mutate])

const autocompleteButtonText = useMemo(() => {
if (isLoading) {
return <Spinner />
}
return pauseAutocomplete ? "need to recharge ChatGPT..." : "Autogenerate"
}, [isLoading, pauseAutocomplete])

const downloadFile = useCallback(() => {
const fileName = "i18n"
const json = JSON.stringify(i18n, null, 2)
const blob = new Blob([json], { type: "application/json" })
const href = URL.createObjectURL(blob)

const link = document.createElement("a")
link.href = href
link.download = fileName + ".json"
document.body.appendChild(link)
link.click()

document.body.removeChild(link)
URL.revokeObjectURL(href)
}, [i18n])
// const setChatGPTPause = () => {
// setPauseAutocomplete(true)
// setTimeout(() => {
// setPauseAutocomplete(false)
// }, 10000)
// }

// const { mutate, isLoading } = useMutation({
// mutationFn: async () => await autocompleteI18nObject(i18n),
// onSuccess: (data: I18n) => {
// setI18n(data)
// setChatGPTPause()
// },
// onError: () => {
// setChatGPTPause()
// },
// })

// const autocomplete = useCallback(() => {
// mutate()
// }, [mutate])

// const autocompleteButtonText = useMemo(() => {
// if (isLoading) {
// return <Spinner />
// }
// return pauseAutocomplete ? "need to recharge ChatGPT..." : "Autogenerate"
// }, [isLoading, pauseAutocomplete])

// const downloadFile = useCallback(() => {
// const fileName = "i18n"
// const json = JSON.stringify(i18n, null, 2)
// const blob = new Blob([json], { type: "application/json" })
// const href = URL.createObjectURL(blob)

// const link = document.createElement("a")
// link.href = href
// link.download = fileName + ".json"
// document.body.appendChild(link)
// link.click()

// document.body.removeChild(link)
// URL.revokeObjectURL(href)
// }, [i18n])

const editTranslation = useCallback(
(language: string, key: string, value: string) => {
Expand Down
4 changes: 2 additions & 2 deletions components/ui/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ function Calendar({
...classNames,
}}
components={{
IconLeft: ({ ...props }) => <ChevronLeft className="h-4 w-4" />,
IconRight: ({ ...props }) => <ChevronRight className="h-4 w-4" />,
IconLeft: () => <ChevronLeft className="h-4 w-4" />,
IconRight: () => <ChevronRight className="h-4 w-4" />,
}}
{...props}
/>
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"name": "next"
}
],
"strictNullChecks": true
"strictNullChecks": true,
"noUnusedParameters": true,
"noUnusedLocals": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
Expand Down

0 comments on commit f672016

Please sign in to comment.