Add restore project function

This commit is contained in:
Terry Sutton committed 2022-06-28 19:55:58 -02:30
1 parent abb69c087e
commit 3dbcf55f91
2 files changed
+12 -4

No files matched your search

@@ -19,7 +19,6 @@ const ProjectCard: FC<Props> = ({
onSelectDelete,
rewriteHref,
}) => {
console.log({ rewriteHref })
const { name, ref: projectRef } = project
const desc = `${project.cloud_provider} | ${project.region}`
@@ -3,9 +3,11 @@ import { Button, IconAlertCircle, IconPauseCircle } from '@supabase/ui'
import { Project } from 'types'
import Link from '@supabase/ui/dist/cjs/components/Typography/Link'
import router from 'next/router'
import { useStore, useSubscriptionStats } from 'hooks'
import { DEFAULT_FREE_PROJECTS_LIMIT } from 'lib/constants'
import { post } from 'lib/common/fetch'
import { API_URL, PROJECT_STATUS } from 'lib/constants'
import { useRouter } from 'next/router'
interface Props {
project: Project
@@ -13,8 +15,9 @@ interface Props {
const ProjectPausedState: FC<Props> = ({ project }) => {
const [isSubmitting, setIsSubmitting] = useState(false)
const router = useRouter()
const { ref } = router.query
const { ui } = useStore()
const { ui, app } = useStore()
const subscriptionStats = useSubscriptionStats()
const {
total_free_projects: totalFreeProjects,
@@ -23,6 +26,12 @@ const ProjectPausedState: FC<Props> = ({ project }) => {
} = subscriptionStats
const freeProjectsLimit = ui.profile?.free_project_limit ?? DEFAULT_FREE_PROJECTS_LIMIT
const restoreProject = async (project: Project) => {
app.onProjectUpdated({ ...project, status: PROJECT_STATUS.RESTORING })
await post(`${API_URL}/projects/${project.ref}/restore`, {})
//router.reload()
}
return (
<>
<div className="mx-auto mt-8 mb-16 w-full max-w-7xl">
@@ -37,7 +46,7 @@ const ProjectPausedState: FC<Props> = ({ project }) => {
<div className="flex items-center justify-center gap-4">
<Button
// onClick={}
onClick={() => restoreProject(project)}
size="small"
loading={isSubmitting}
type="primary"