Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Update js files to ts

Joshen Lima976585b713b
diff --git a/studio/components/to-be-cleaned/AlphaPreview.js b/studio/components/to-be-cleaned/AlphaPreview.tsx
similarity index 90%
rename from studio/components/to-be-cleaned/AlphaPreview.js
rename to studio/components/to-be-cleaned/AlphaPreview.tsx
index 8da68a79ce1..e2f86b91076 100644
--- a/studio/components/to-be-cleaned/AlphaPreview.js
+++ b/studio/components/to-be-cleaned/AlphaPreview.tsx
@@ -1,8 +1,6 @@
-import * as React from 'react'
-
import { Typography, IconAlertCircle } from '@supabase/ui'
-export default function AlphaPreview() {
+const AlphaPreview = () => {
return (
<div className="block w-full bg-yellow-500 bg-opacity-5 p-3 border border-yellow-500 border-opacity-50 rounded">
<div className="flex space-x-3">
@@ -21,3 +19,5 @@ export default function AlphaPreview() {
</div>
)
}
+
+export default AlphaPreview
diff --git a/studio/components/to-be-cleaned/DateRangePicker.js b/studio/components/to-be-cleaned/DateRangePicker.tsx
similarity index 93%
rename from studio/components/to-be-cleaned/DateRangePicker.js
rename to studio/components/to-be-cleaned/DateRangePicker.tsx
index 180d4e77ce5..cb5afc396c4 100644
--- a/studio/components/to-be-cleaned/DateRangePicker.js
+++ b/studio/components/to-be-cleaned/DateRangePicker.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useState } from 'react'
+import { FC, useEffect, useState } from 'react'
import { Button, Dropdown, IconChevronDown } from '@supabase/ui'
import dayjs from 'dayjs'
import { DATE_FORMAT } from 'lib/constants'
@@ -11,7 +11,13 @@ import { DATE_FORMAT } from 'lib/constants'
* Otherwise there won't be any data shown on the graphs
*/
-function DateRangePicker({ onChange, value, options, loading, currentBillingPeriodStart }) {
+const DateRangePicker: FC<any> = ({
+ onChange,
+ value,
+ options,
+ loading,
+ currentBillingPeriodStart,
+}) => {
const [timePeriod, setTimePeriod] = useState(value)
useEffect(() => {
@@ -23,7 +29,7 @@ function DateRangePicker({ onChange, value, options, loading, currentBillingPeri
const today = dayjs().format(DATE_FORMAT)
- function handleChange(x) {
+ function handleChange(x: any) {
setTimePeriod(x)
switch (x) {
@@ -164,7 +170,7 @@ function DateRangePicker({ onChange, value, options, loading, currentBillingPeri
overlay={
<>
<Dropdown.RadioGroup value={timePeriod} onChange={(x) => handleChange(x)}>
- {options.map((option) => {
+ {options.map((option: any) => {
return (
<Dropdown.Radio value={option.key} key={option.key}>
{option.label}
@@ -176,7 +182,7 @@ function DateRangePicker({ onChange, value, options, loading, currentBillingPeri
}
>
<Button as="span" type="default" iconRight={<IconChevronDown />}>
- {timePeriod && options.find((x) => x.key == timePeriod).label}
+ {timePeriod && options.find((x: any) => x.key == timePeriod).label}
</Button>
</Dropdown>
</>
diff --git a/studio/components/to-be-cleaned/DisplayProjectSettings.js b/studio/components/to-be-cleaned/DisplayProjectSettings.tsx
similarity index 86%
rename from studio/components/to-be-cleaned/DisplayProjectSettings.js
rename to studio/components/to-be-cleaned/DisplayProjectSettings.tsx
index 2aaeb8b83f3..b502698e89d 100644
--- a/studio/components/to-be-cleaned/DisplayProjectSettings.js
+++ b/studio/components/to-be-cleaned/DisplayProjectSettings.tsx
@@ -1,4 +1,5 @@
import useSWR from 'swr'
+import { FC } from 'react'
import { useRouter } from 'next/router'
import { get } from 'lib/common/fetch'
import { IconAlertCircle, Input, Loading, Typography } from '@supabase/ui'
@@ -8,11 +9,11 @@ import Panel from './Panel'
const { Text, Title } = Typography
-export function DisplayApiSettings() {
+export const DisplayApiSettings = () => {
const router = useRouter()
const { ref } = router.query
- const { data, error } = useSWR(`${API_URL}/props/project/${ref}/settings`, get)
+ const { data, error }: any = useSWR(`${API_URL}/props/project/${ref}/settings`, get)
if (!data)
return (
@@ -27,6 +28,7 @@ export function DisplayApiSettings() {
</div>
) : (
<div className="py-4">
+ {/* @ts-ignore */}
<Loading active={true} />
</div>
)}
@@ -38,15 +40,16 @@ export function DisplayApiSettings() {
// Get the API service
const API_SERVICE_ID = 1
- let apiService = services.find((x) => x.app.id == API_SERVICE_ID)
+ let apiService = services.find((x: any) => x.app.id == API_SERVICE_ID)
let apiKeys = apiService.service_api_keys
return (
<ApiContentWrapper>
{!data ? (
+ // @ts-ignore
<Loading active={true} />
) : (
- apiKeys.map((x, i) => (
+ apiKeys.map((x: any, i: number) => (
<Panel.Content
key={x.api_key}
className={
@@ -56,9 +59,10 @@ export function DisplayApiSettings() {
>
<Input
layout="horizontal"
+ // @ts-ignore
label={
<>
- {x.tags?.split(',').map((x, i) => (
+ {x.tags?.split(',').map((x: any, i: number) => (
<code key={`${x}${i}`} className="text-xs bg-gray-500 text-white px-2">
{x}
</code>
@@ -91,11 +95,11 @@ export function DisplayApiSettings() {
)
}
-export function DisplayConfigSettings() {
+export const DisplayConfigSettings = () => {
const router = useRouter()
const { ref } = router.query
- const { data, error } = useSWR(`${API_URL}/props/project/${ref}/settings`, get)
+ const { data, error }: any = useSWR(`${API_URL}/props/project/${ref}/settings`, get)
if (!data)
return (
@@ -112,6 +116,7 @@ export function DisplayConfigSettings() {
</div>
) : (
<div className="py-4">
+ {/* @ts-ignore */}
<Loading active={true} />
</div>
)}
@@ -124,14 +129,14 @@ export function DisplayConfigSettings() {
// Get the API service
const API_SERVICE_ID = 1
let jwtSecret = project.jwt_secret ?? ''
- let apiService = services.find((x) => x.app.id == API_SERVICE_ID)
+ let apiService = services.find((x: any) => x.app.id == API_SERVICE_ID)
let apiConfig = apiService.app_config
return (
<section>
<Panel
title={
- <Typography.Title level={6} className="mb-0">
+ <Typography.Title level={5} className="mb-0">
Project Configuration
</Typography.Title>
}
@@ -141,9 +146,7 @@ export function DisplayConfigSettings() {
label="URL"
readOnly
copy
- readOnly
disabled
- copy
className="input-mono"
value={`https://${apiConfig.endpoint}`}
descriptionText="A RESTful endpoint for querying and managing your database."
@@ -168,7 +171,7 @@ export function DisplayConfigSettings() {
)
}
-const ApiContentWrapper = ({ children }) => {
+const ApiContentWrapper: FC<any> = ({ children }) => {
return (
<Panel
title={
@@ -187,7 +190,7 @@ const ApiContentWrapper = ({ children }) => {
)
}
-const ConfigContentWrapper = ({ children }) => {
+const ConfigContentWrapper: FC<any> = ({ children }) => {
return (
<Panel
title={
diff --git a/studio/components/to-be-cleaned/FiveOhFive.js b/studio/components/to-be-cleaned/FiveOhFive.js
deleted file mode 100644
index 2adf12e029d..00000000000
--- a/studio/components/to-be-cleaned/FiveOhFive.js
+++ /dev/null
@@ -1,7 +0,0 @@
-export default function FiveOhFive({ error }) {
- return (
- <div className="flex h-screen">
- <img className="m-auto max-w-lg" src="/img/eastwood-fatal-error.svg" alt="loading" />
- </div>
- )
-}
diff --git a/studio/components/to-be-cleaned/FormBoxEmpty.js b/studio/components/to-be-cleaned/FormBoxEmpty.tsx
similarity index 61%
rename from studio/components/to-be-cleaned/FormBoxEmpty.js
rename to studio/components/to-be-cleaned/FormBoxEmpty.tsx
index 08798d5934d..15a47f8a8d8 100644
--- a/studio/components/to-be-cleaned/FormBoxEmpty.js
+++ b/studio/components/to-be-cleaned/FormBoxEmpty.tsx
@@ -1,14 +1,13 @@
-import { IconGlobe, IconTool, Typography } from '@supabase/ui'
+import { FC } from 'react'
+import { Typography } from '@supabase/ui'
-const { Text } = Typography
-
-const EmptyPanel = ({ icon, text }) => {
+const EmptyPanel: FC<any> = ({ icon, text }) => {
return (
<div className="flex items-center justify-center flex-row py-4 space-x-2">
<div className="relative bg-bg-secondary-light w-12 h-12 rounded-full flex items-center justify-center text-gray-300">
{icon}
</div>
- <Text type="secondary">{text}</Text>
+ <Typography.Text type="secondary">{text}</Typography.Text>
</div>
)
}
diff --git a/studio/components/to-be-cleaned/KeyMap.js b/studio/components/to-be-cleaned/KeyMap.tsx
similarity index 76%
rename from studio/components/to-be-cleaned/KeyMap.js
rename to studio/components/to-be-cleaned/KeyMap.tsx
index e06c74e42f5..d70714b6741 100644
--- a/studio/components/to-be-cleaned/KeyMap.js
+++ b/studio/components/to-be-cleaned/KeyMap.tsx
@@ -1,4 +1,4 @@
-import React from 'react'
+import { FC } from 'react'
/**
* Render keyMap
@@ -6,18 +6,18 @@ import React from 'react'
* @param {String} keyMap ex: Command+Enter ; separate key using +
*/
-const customKeyChars = {
+const customKeyChars: any = {
command: '⌘',
control: '⌃',
option: '⌥',
enter: '↵',
}
-export default function KeyMap({ keyMap }) {
+const KeyMap: FC<any> = ({ keyMap }) => {
if (!keyMap) return null
const keys = keyMap.split('+')
- const keymapRender = keys.map((key) => {
+ const keymapRender = keys.map((key: any) => {
let keyChar = key
if (key.toLowerCase() in customKeyChars) keyChar = customKeyChars[key.toLowerCase()]
return (
@@ -28,3 +28,5 @@ export default function KeyMap({ keyMap }) {
})
return <p className="inline-flex space-x-1.5">{keymapRender}</p>
}
+
+export default KeyMap
diff --git a/studio/components/to-be-cleaned/LogPanel.js b/studio/components/to-be-cleaned/LogPanel.js
deleted file mode 100644
index ee110f56348..00000000000
--- a/studio/components/to-be-cleaned/LogPanel.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import { useState, useEffect } from 'react'
-import { Button, Typography } from '@supabase/ui'
-
-import { API_URL } from 'lib/constants'
-import { get } from 'lib/common/fetch'
-import Panel from './Panel'
-
-export default function LogPanel({ title, projectRef, app }) {
- const [logs, setLogs] = useState([])
- const [lines, setLines] = useState(10)
- const [isLoading, setIsLoading] = useState(false)
-
- const refreshLogs = async () => {
- setIsLoading(true)
- try {
- const data = await get(`${API_URL}/projects/${projectRef}/logs?app=${app}`)
- if (data.error) throw data.error
- const cleansed = data.logs
- .split('\n')
- .filter((x) => x.trim() != '')
- .reverse()
- setLogs(cleansed)
- } catch (error) {
- console.error('Refresh logs error:', error)
- } finally {
- setIsLoading(false)
- }
- }
-
- useEffect(() => {
- refreshLogs()
- }, [])
-
- return (
- <Panel
- title={
- <div className="flex items-center justify-between w-full">
- <Typography.Title level={5} className="flex-1 block">
- {title}
- </Typography.Title>
- <div className="flex-1 text-right">
- <Button
- type="outline"
- className="hover:border-gray-400"
- disabled={isLoading}
- loading={isLoading}
- onClick={() => refreshLogs()}
- >
- Refresh
- </Button>
- </div>
- </div>
- }
- >
- <div className="max-w-full w-full rounded overflow-hidden">
- <div className="relative max-w-full overflow-x-auto">
- {logs.map((x, i) => (
- <div
- key={x}
- className={`block whitespace-nowrap px-4 py-3 font-mono border-t dark:border-dark`}
- >
- <Typography.Text>{x}</Typography.Text>
- </div>
- ))}
- </div>
- </div>
- </Panel>
- )
-}
diff --git a/studio/components/to-be-cleaned/Panel.js b/studio/components/to-be-cleaned/Panel.tsx
similarity index 92%
rename from studio/components/to-be-cleaned/Panel.js
rename to studio/components/to-be-cleaned/Panel.tsx
index 24da5ccbaa4..b2e6f97253e 100644
--- a/studio/components/to-be-cleaned/Panel.js
+++ b/studio/components/to-be-cleaned/Panel.tsx
@@ -1,7 +1,7 @@
import { Loading } from '@supabase/ui'
import React from 'react'
-function Panel(props) {
+function Panel(props: any) {
let headerClasses = []
if (!props.hideHeaderStyling) {
@@ -25,7 +25,7 @@ function Panel(props) {
rounded mb-8 ${props.className}`}
>
{props.title && (
- <div className={headerClasses}>
+ <div className={headerClasses.join(' ')}>
<div className="px-6 py-4 flex items-center">{props.title}</div>
</div>
)}
@@ -44,7 +44,7 @@ function Panel(props) {
)
}
-function Content(props) {
+function Content(props: any) {
let classes = ['px-6 py-4']
if (props.className) classes.push(props.className)
return <div className={classes.join(' ')}>{props.children}</div>
diff --git a/studio/components/to-be-cleaned/Reports/EditReportModal.js b/studio/components/to-be-cleaned/Reports/EditReportModal.tsx
similarity index 81%
rename from studio/components/to-be-cleaned/Reports/EditReportModal.js
rename to studio/components/to-be-cleaned/Reports/EditReportModal.tsx
index 28b74d4ca09..6aeadc04f92 100644
--- a/studio/components/to-be-cleaned/Reports/EditReportModal.js
+++ b/studio/components/to-be-cleaned/Reports/EditReportModal.tsx
@@ -1,21 +1,22 @@
-import React, { useState, useEffect } from 'react'
+import React, { FC, useState, useEffect } from 'react'
import { useRouter } from 'next/router'
import { observer } from 'mobx-react-lite'
import { toJS } from 'mobx'
-
import { Input, Modal } from '@supabase/ui'
+import { useStore } from 'hooks'
import { useProjectContentStore } from 'stores/projectContentStore'
-import { toast } from 'react-hot-toast'
-const EditModal = () => {
+const EditModal: FC<any> = () => {
const router = useRouter()
const { id, ref } = router.query
- const [visible, setVisible] = useState(false)
- const [loading, setLoading] = useState(false)
- const [name, setName] = useState(null)
- const [description, setDescription] = useState(null)
+ const { ui } = useStore()
+
+ const [visible, setVisible] = useState<boolean>(false)
+ const [loading, setLoading] = useState<boolean>(false)
+ const [name, setName] = useState<string>()
+ const [description, setDescription] = useState<string>()
const contentStore = useProjectContentStore(ref)
@@ -55,9 +56,8 @@ const EditModal = () => {
await contentStore.load()
setVisible(!visible)
return data
- } catch (error) {
- console.error(error)
- toast.error(error.message)
+ } catch (error: any) {
+ ui.setNotification({ category: 'error', message: error.message })
setLoading(false)
}
}
diff --git a/studio/components/to-be-cleaned/SimpleCodeBlock.js b/studio/components/to-be-cleaned/SimpleCodeBlock.tsx
similarity index 86%
rename from studio/components/to-be-cleaned/SimpleCodeBlock.js
rename to studio/components/to-be-cleaned/SimpleCodeBlock.tsx
index 4411e0d6e7f..efeec0fcd86 100644
--- a/studio/components/to-be-cleaned/SimpleCodeBlock.js
+++ b/studio/components/to-be-cleaned/SimpleCodeBlock.tsx
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
-import React, { useEffect, useState, useRef } from 'react'
+import { FC, useEffect, useState, useRef } from 'react'
import Highlight, { defaultProps } from 'prism-react-renderer'
import defaultTheme from 'prism-react-renderer/themes/palenight'
import Clipboard from 'clipboard'
@@ -18,11 +18,11 @@ const prism = {
plugins: ['line-numbers', 'show-language'],
}
-const SimpleCodeBlock = ({ children, className: languageClassName, metastring }) => {
+const SimpleCodeBlock: FC<any> = ({ children, className: languageClassName, metastring }) => {
const [showCopied, setShowCopied] = useState(false)
const target = useRef(null)
const button = useRef(null)
- let highlightLines = []
+ let highlightLines: any = []
if (metastring && highlightLinesRangeRegex.test(metastring)) {
const highlightLinesRange = metastring.match(highlightLinesRangeRegex)[1]
@@ -36,10 +36,13 @@ const SimpleCodeBlock = ({ children, className: languageClassName, metastring })
}, [showCopied])
useEffect(() => {
- let clipboard
+ let clipboard: any
+ // @ts-ignore
if (button?.current?.button) {
+ // @ts-ignore
clipboard = new Clipboard(button.current.button, {
+ // @ts-ignore
target: () => target.current,
})
}
@@ -57,15 +60,14 @@ const SimpleCodeBlock = ({ children, className: languageClassName, metastring })
language = prism.defaultLanguage
}
- const handleCopyCode = (code) => {
- navigator.clipboard.writeText(code).then(() => setShowCopied(true))
+ const handleCopyCode = (code: any) => {
+ navigator?.clipboard?.writeText(code).then(() => setShowCopied(true))
}
return (
<Highlight
- className=""
{...defaultProps}
- theme={prism.theme || defaultTheme}
+ theme={(prism as any).theme || defaultTheme}
code={children.trim()}
language={language}
>
diff --git a/studio/components/to-be-cleaned/SqlEditor.js b/studio/components/to-be-cleaned/SqlEditor.tsx
similarity index 88%
rename from studio/components/to-be-cleaned/SqlEditor.js
rename to studio/components/to-be-cleaned/SqlEditor.tsx
index 836c4fd7413..e2136d7542a 100644
--- a/studio/components/to-be-cleaned/SqlEditor.js
+++ b/studio/components/to-be-cleaned/SqlEditor.tsx
@@ -1,9 +1,9 @@
import Editor, { useMonaco } from '@monaco-editor/react'
-import { useEffect, useRef } from 'react'
+import { FC, useEffect, useRef } from 'react'
import { Typography } from '@supabase/ui'
import { useStore } from 'hooks'
-const SqlEditor = ({
+const SqlEditor: FC<any> = ({
queryId,
language = 'pgsql',
defaultValue = '',
@@ -13,7 +13,7 @@ const SqlEditor = ({
}) => {
const monaco = useMonaco()
const { meta } = useStore()
- const editorRef = useRef()
+ const editorRef = useRef<any>()
useEffect(() => {
if (monaco) {
@@ -21,6 +21,7 @@ const SqlEditor = ({
monaco.editor.defineTheme('supabase', {
base: 'vs-dark',
inherit: true,
+ colors: {},
rules: [
{ token: '', background: '4a5568' },
{ token: 'string.sql', foreground: '24b47e' },
@@ -52,7 +53,7 @@ const SqlEditor = ({
useEffect(() => {
if (editorRef.current) {
// add margin above first line
- editorRef.current?.changeViewZones((accessor) => {
+ editorRef.current?.changeViewZones((accessor: any) => {
accessor.addZone({
afterLineNumber: 0,
heightInPx: 4,
@@ -62,7 +63,7 @@ const SqlEditor = ({
}
}, [queryId])
- async function formatPgsql(value) {
+ async function formatPgsql(value: any) {
try {
const formatted = await meta.formatQuery(value)
if (formatted.error) throw formatted.error
@@ -73,11 +74,11 @@ const SqlEditor = ({
}
}
- const onMount = (editor, monaco) => {
+ const onMount = (editor: any, monaco: any) => {
editorRef.current = editor
// Add margin above first line
- editor.changeViewZones((accessor) => {
+ editor.changeViewZones((accessor: any) => {
accessor.addZone({
afterLineNumber: 0,
heightInPx: 4,
diff --git a/studio/components/to-be-cleaned/TooltipListener.js b/studio/components/to-be-cleaned/TooltipListener.tsx
similarity index 97%
rename from studio/components/to-be-cleaned/TooltipListener.js
rename to studio/components/to-be-cleaned/TooltipListener.tsx
index aba6107a5c7..313344b74ee 100644
--- a/studio/components/to-be-cleaned/TooltipListener.js
+++ b/studio/components/to-be-cleaned/TooltipListener.tsx
@@ -1,7 +1,8 @@
import { useRef, useEffect } from 'react'
-import KeyMap from './KeyMap'
import { renderToString } from 'react-dom/server'
+
import { makeRandomString } from 'lib/helpers'
+import KeyMap from './KeyMap'
/**
* Hook for listening to hover action on the target element and show tooltip.
@@ -17,13 +18,13 @@ import { makeRandomString } from 'lib/helpers'
*/
export default function TooltipListener({
- title,
+ title = '',
position = 'bottom',
keyMap = null,
className = '',
- nowrap,
+ nowrap = false,
}) {
- const ref = useRef(null)
+ const ref = useRef<any>(null)
const tooltipId = `tooltip-${makeRandomString(5)}`
const tooltip = document.createElement('div')
tooltip.id = tooltipId
diff --git a/studio/components/to-be-cleaned/Usage.js b/studio/components/to-be-cleaned/Usage.tsx
similarity index 83%
rename from studio/components/to-be-cleaned/Usage.js
rename to studio/components/to-be-cleaned/Usage.tsx
index 7f7241d16e5..b26dc651a59 100644
--- a/studio/components/to-be-cleaned/Usage.js
+++ b/studio/components/to-be-cleaned/Usage.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react'
+import React, { FC, useEffect, useState } from 'react'
import useSWR from 'swr'
import { Loading, Typography } from '@supabase/ui'
import { toast } from 'react-hot-toast'
@@ -32,10 +32,11 @@ const usageLimits = {
title: 'Database space',
tiers: {
free: {
- description: (stats) => `${(((stats?.dbSize || 0) / (500 * MB)) * 100).toFixed(2)} %`,
- render: (stats) => {
- let bytes = stats?.dbSize ? new Number(stats?.dbSize) : 0
- let usage = {
+ description: (stats: any) =>
+ `${(((stats?.dbSize || 0) / (500 * MB)) * 100).toFixed(2)} %`,
+ render: (stats: any) => {
+ const bytes: any = stats?.dbSize ? new Number(stats?.dbSize) : 0
+ const usage = {
gb: bytes / GB || 0,
mb: bytes / MB || 0,
}
@@ -52,10 +53,11 @@ const usageLimits = {
},
},
pro: {
- description: (stats) => `${(((stats?.dbSize || 0) / (8000 * MB)) * 100).toFixed(2)} %`,
- render: (stats) => {
- let bytes = stats?.dbSize ? new Number(stats?.dbSize) : 0
- let usage = {
+ description: (stats: any) =>
+ `${(((stats?.dbSize || 0) / (8000 * MB)) * 100).toFixed(2)} %`,
+ render: (stats: any) => {
+ const bytes: any = stats?.dbSize ? new Number(stats?.dbSize) : 0
+ const usage = {
gb: bytes / GB || 0,
mb: bytes / MB || 0,
}
@@ -83,27 +85,28 @@ const usageLimits = {
title: 'Users',
tiers: {
free: {
- description: (stats) => `${(((stats?.authUsers || 0) / 10000) * 100).toFixed(2)}%`,
- render: (stats) => (
+ description: (stats: any) => `${(((stats?.authUsers || 0) / 10000) * 100).toFixed(2)}%`,
+ render: (stats: any) => (
<SparkBar
value={stats?.authUsers || 0}
max={10000}
type={'horizontal'}
barClass={'bg-green-500'}
- labelBottom={stats?.authUsers ? new Number(stats?.authUsers).toLocaleString() : 0}
+ labelBottom={stats?.authUsers ? new Number(stats?.authUsers).toLocaleString() : '0'}
labelTop={`${new Number(10000).toLocaleString()}`}
/>
),
},
pro: {
- description: (stats) => `${(((stats?.authUsers || 0) / 100000) * 100).toFixed(2)}%`,
- render: (stats) => (
+ description: (stats: any) =>
+ `${(((stats?.authUsers || 0) / 100000) * 100).toFixed(2)}%`,
+ render: (stats: any) => (
<SparkBar
value={stats?.authUsers || 0}
max={100000}
type={'horizontal'}
barClass={'bg-green-500'}
- labelBottom={stats?.authUsers ? new Number(stats?.authUsers).toLocaleString() : 0}
+ labelBottom={stats?.authUsers ? new Number(stats?.authUsers).toLocaleString() : '0'}
labelTop={`${new Number(100000).toLocaleString()}`}
/>
),
@@ -133,8 +136,9 @@ const usageLimits = {
title: 'Storage space',
tiers: {
free: {
- description: (stats) => `${(((stats?.bucketSize || 0) / (1 * GB)) * 100).toFixed(2)}%`,
- render: (stats) => (
+ description: (stats: any) =>
+ `${(((stats?.bucketSize || 0) / (1 * GB)) * 100).toFixed(2)}%`,
+ render: (stats: any) => (
<SparkBar
value={stats?.bucketSize / (1024 * 1024) || 0}
max={1 * 1024}
@@ -143,16 +147,16 @@ const usageLimits = {
labelBottom={
stats?.bucketSize
? `${new Number(stats?.bucketSize / (1024 * 1024)).toLocaleString()} MB`
- : 0
+ : '0'
}
labelTop={`${new Number(1 * 1024).toLocaleString()} MB`}
/>
),
},
pro: {
- description: (stats) =>
+ description: (stats: any) =>
`${(((stats?.bucketSize || 0) / (100 * GB)) * 100).toFixed(2)}%`,
- render: (stats) => (
+ render: (stats: any) => (
<SparkBar
value={stats?.bucketSize / (1024 * 1024) || 0}
max={100 * 1024}
@@ -161,7 +165,7 @@ const usageLimits = {
labelBottom={
stats?.bucketSize
? `${new Number(stats?.bucketSize / (1024 * 1024)).toLocaleString()} MB`
- : 0
+ : '0'
}
labelTop={`${new Number(100).toLocaleString()} GB`}
/>
@@ -186,12 +190,12 @@ const usageLimits = {
},
}
-export default function ProjectUsage({ projectRef, subscription_id }) {
+const ProjectUsage: FC<any> = ({ projectRef, subscription_id }) => {
const { data: stats, error: usageError } = useSWR(`${API_URL}/projects/${projectRef}/usage`, get)
- const [loading, setLoading] = useState(false)
- const [error, setError] = useState(null)
- const [subscription, setSubscription] = useState(null)
+ const [loading, setLoading] = useState<boolean>(false)
+ const [error, setError] = useState<any>(null)
+ const [subscription, setSubscription] = useState<any>(null)
useEffect(() => {
let cancel = false
@@ -208,7 +212,7 @@ export default function ProjectUsage({ projectRef, subscription_id }) {
})
if (!cancel) setSubscription(data)
if (error) throw error
- } catch (error) {
+ } catch (error: any) {
toast.error(error.message)
if (!cancel) setError(error)
} finally {
@@ -269,6 +273,7 @@ export default function ProjectUsage({ projectRef, subscription_id }) {
{feature.tiers[tier]?.description(stats)}
</td>
<td className="px-6 py-3 text-sm text-typography-body-light dark:text-typography-body-dark ">
+ {/* @ts-ignore */}
{feature.tiers[tier]?.render ? feature.tiers[tier].render(stats) : null}
</td>
</tr>
@@ -283,12 +288,14 @@ export default function ProjectUsage({ projectRef, subscription_id }) {
)
}
-export function ProjectUsageMinimal({ projectRef, subscription_id, filter }) {
+export default ProjectUsage
+
+export const ProjectUsageMinimal: FC<any> = ({ projectRef, subscription_id, filter }) => {
const { data: stats, error: usageError } = useSWR(`${API_URL}/projects/${projectRef}/usage`, get)
- const [loading, setLoading] = useState(false)
- const [error, setError] = useState(null)
- const [subscription, setSubscription] = useState(null)
+ const [loading, setLoading] = useState<boolean>(false)
+ const [error, setError] = useState<any>(null)
+ const [subscription, setSubscription] = useState<any>(null)
useEffect(() => {
let cancel = false
@@ -305,7 +312,7 @@ export function ProjectUsageMinimal({ projectRef, subscription_id, filter }) {
})
if (!cancel) setSubscription(data)
if (error) throw error
- } catch (error) {
+ } catch (error: any) {
if (!cancel) setError(error)
} finally {
if (!cancel) setLoading(false)
@@ -338,6 +345,7 @@ export function ProjectUsageMinimal({ projectRef, subscription_id, filter }) {
</Typography.Text>
) : null}
<div className="text-sm text-typography-body-light dark:text-typography-body-dark">
+ {/* @ts-ignore */}
{feature.tiers[tier]?.render ? feature.tiers[tier].render(stats) : null}
</div>
</div>