mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Preparing the repository
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
"use server"
|
||||
import {baseAuth} from "@/auth/auth";
|
||||
import {User} from "@prisma/client";
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {ServerActionResult} from "@/types/action-type";
|
||||
import {Organization} from "@prisma/client";
|
||||
import {z} from "zod";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import {db} from "@/db";
|
||||
import {getDb} from "@/db";
|
||||
import {
|
||||
OrganizationFormSchema
|
||||
} from "@/components/wrappers/dashboard/organization/OrganizationForm/organization-form.schema";
|
||||
@@ -172,6 +172,7 @@ export const deleteOrganizationAction = userAction
|
||||
console.log(parsedInput);
|
||||
try {
|
||||
|
||||
const db = await getDb()
|
||||
const uuid = uuidv4()
|
||||
const organization = await db.organization.findFirst({
|
||||
where: {
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
import {currentUser} from "@/auth/current-user";
|
||||
import {enhance} from "@zenstackhq/runtime";
|
||||
import {prisma} from "@/prisma";
|
||||
// import {currentUser} from "@/auth/current-user";
|
||||
// import {enhance} from "@zenstackhq/runtime";
|
||||
// import {prisma} from "@/prisma";
|
||||
//
|
||||
// const user = await currentUser();
|
||||
//
|
||||
// export const db = enhance(prisma, {user: user});
|
||||
|
||||
const user = await currentUser();
|
||||
import { enhance } from "@zenstackhq/runtime";
|
||||
import { prisma } from "@/prisma";
|
||||
|
||||
export const db = enhance(prisma, {user: user});
|
||||
export const getDb = async () => {
|
||||
const { currentUser } = await import("@/auth/current-user");
|
||||
const user = await currentUser();
|
||||
return enhance(prisma, { user });
|
||||
};
|
||||
@@ -2,57 +2,19 @@
|
||||
|
||||
import {redirect} from "next/navigation";
|
||||
import {signIn, signOut} from "@/auth/auth";
|
||||
import {getServerUrl} from "@/utils/get-server-url";
|
||||
import {deleteOrganizationCookie, setCurrentOrganizationSlug} from "@/features/dashboard/organization-cookie";
|
||||
//
|
||||
// const baseUrl = getServerUrl();
|
||||
// async function fetchCsrfToken() {
|
||||
// const response = await fetch(`${baseUrl}/api/auth/csrf`);
|
||||
// const data = await response.json();
|
||||
// return data.csrfToken;
|
||||
// }
|
||||
//
|
||||
// async function manualSignOut() {
|
||||
// const csrfToken = await fetchCsrfToken();
|
||||
//
|
||||
// const formData = new URLSearchParams();
|
||||
// formData.append('csrfToken', csrfToken);
|
||||
// formData.append('json', 'true');
|
||||
//
|
||||
// const response = await fetch(`${baseUrl}/api/auth/signout`, {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||
// },
|
||||
// body: formData.toString(),
|
||||
// });
|
||||
//
|
||||
// if (response.ok) {
|
||||
// console.log('Signed out successfully');
|
||||
// window.location.reload();
|
||||
//
|
||||
// } else {
|
||||
// console.error('Failed to sign out');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
import {setCurrentOrganizationSlug} from "@/features/dashboard/organization-cookie";
|
||||
|
||||
export const signOutAction = async () => {
|
||||
const deleteCookieResponse = await setCurrentOrganizationSlug("");
|
||||
await signOut({ redirectTo: '/', redirect: true });
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.location.reload();
|
||||
}
|
||||
// if (typeof window !== 'undefined') {
|
||||
// window.location.reload();
|
||||
// }
|
||||
|
||||
return deleteCookieResponse;
|
||||
};
|
||||
//
|
||||
// export const signOutAction = async () => {
|
||||
// // await manualSignOut()
|
||||
// await signOut({redirectTo: '/', redirect: true})
|
||||
// await deleteOrganizationCookie()
|
||||
// window.location.reload();
|
||||
// }
|
||||
|
||||
export const signInAction = async (type: string, formData?: any) => {
|
||||
if (type === "google") {
|
||||
await setCurrentOrganizationSlug("default");
|
||||
|
||||
+44
-44
@@ -14143,42 +14143,42 @@ components:
|
||||
- type: string
|
||||
- $ref: "#/components/schemas/NullableStringFieldUpdateOperationsInput"
|
||||
- type: "null"
|
||||
UserArgs:
|
||||
UserDefaultArgs:
|
||||
type: object
|
||||
properties:
|
||||
select:
|
||||
$ref: "#/components/schemas/UserSelect"
|
||||
include:
|
||||
$ref: "#/components/schemas/UserInclude"
|
||||
OrganizationArgs:
|
||||
OrganizationDefaultArgs:
|
||||
type: object
|
||||
properties:
|
||||
select:
|
||||
$ref: "#/components/schemas/OrganizationSelect"
|
||||
include:
|
||||
$ref: "#/components/schemas/OrganizationInclude"
|
||||
ProjectArgs:
|
||||
ProjectDefaultArgs:
|
||||
type: object
|
||||
properties:
|
||||
select:
|
||||
$ref: "#/components/schemas/ProjectSelect"
|
||||
include:
|
||||
$ref: "#/components/schemas/ProjectInclude"
|
||||
AgentArgs:
|
||||
AgentDefaultArgs:
|
||||
type: object
|
||||
properties:
|
||||
select:
|
||||
$ref: "#/components/schemas/AgentSelect"
|
||||
include:
|
||||
$ref: "#/components/schemas/AgentInclude"
|
||||
DatabaseArgs:
|
||||
DatabaseDefaultArgs:
|
||||
type: object
|
||||
properties:
|
||||
select:
|
||||
$ref: "#/components/schemas/DatabaseSelect"
|
||||
include:
|
||||
$ref: "#/components/schemas/DatabaseInclude"
|
||||
BackupArgs:
|
||||
BackupDefaultArgs:
|
||||
type: object
|
||||
properties:
|
||||
select:
|
||||
@@ -14191,14 +14191,14 @@ components:
|
||||
user:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/UserArgs"
|
||||
- $ref: "#/components/schemas/UserDefaultArgs"
|
||||
SessionInclude:
|
||||
type: object
|
||||
properties:
|
||||
user:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/UserArgs"
|
||||
- $ref: "#/components/schemas/UserDefaultArgs"
|
||||
UserInclude:
|
||||
type: object
|
||||
properties:
|
||||
@@ -14217,7 +14217,7 @@ components:
|
||||
_count:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/UserCountOutputTypeArgs"
|
||||
- $ref: "#/components/schemas/UserCountOutputTypeDefaultArgs"
|
||||
OrganizationInclude:
|
||||
type: object
|
||||
properties:
|
||||
@@ -14232,25 +14232,25 @@ components:
|
||||
_count:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/OrganizationCountOutputTypeArgs"
|
||||
- $ref: "#/components/schemas/OrganizationCountOutputTypeDefaultArgs"
|
||||
UserOrganizationInclude:
|
||||
type: object
|
||||
properties:
|
||||
user:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/UserArgs"
|
||||
- $ref: "#/components/schemas/UserDefaultArgs"
|
||||
organization:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/OrganizationArgs"
|
||||
- $ref: "#/components/schemas/OrganizationDefaultArgs"
|
||||
ProjectInclude:
|
||||
type: object
|
||||
properties:
|
||||
organization:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/OrganizationArgs"
|
||||
- $ref: "#/components/schemas/OrganizationDefaultArgs"
|
||||
databases:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
@@ -14258,7 +14258,7 @@ components:
|
||||
_count:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/ProjectCountOutputTypeArgs"
|
||||
- $ref: "#/components/schemas/ProjectCountOutputTypeDefaultArgs"
|
||||
AgentInclude:
|
||||
type: object
|
||||
properties:
|
||||
@@ -14269,14 +14269,14 @@ components:
|
||||
_count:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/AgentCountOutputTypeArgs"
|
||||
- $ref: "#/components/schemas/AgentCountOutputTypeDefaultArgs"
|
||||
DatabaseInclude:
|
||||
type: object
|
||||
properties:
|
||||
agent:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/AgentArgs"
|
||||
- $ref: "#/components/schemas/AgentDefaultArgs"
|
||||
backups:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
@@ -14288,18 +14288,18 @@ components:
|
||||
project:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/ProjectArgs"
|
||||
- $ref: "#/components/schemas/ProjectDefaultArgs"
|
||||
_count:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/DatabaseCountOutputTypeArgs"
|
||||
- $ref: "#/components/schemas/DatabaseCountOutputTypeDefaultArgs"
|
||||
BackupInclude:
|
||||
type: object
|
||||
properties:
|
||||
database:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/DatabaseArgs"
|
||||
- $ref: "#/components/schemas/DatabaseDefaultArgs"
|
||||
restorations:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
@@ -14307,18 +14307,18 @@ components:
|
||||
_count:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/BackupCountOutputTypeArgs"
|
||||
- $ref: "#/components/schemas/BackupCountOutputTypeDefaultArgs"
|
||||
RestorationInclude:
|
||||
type: object
|
||||
properties:
|
||||
backup:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/BackupArgs"
|
||||
- $ref: "#/components/schemas/BackupDefaultArgs"
|
||||
database:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/DatabaseArgs"
|
||||
- $ref: "#/components/schemas/DatabaseDefaultArgs"
|
||||
UserCountOutputTypeSelect:
|
||||
type: object
|
||||
properties:
|
||||
@@ -14357,32 +14357,32 @@ components:
|
||||
properties:
|
||||
restorations:
|
||||
type: boolean
|
||||
UserCountOutputTypeArgs:
|
||||
UserCountOutputTypeDefaultArgs:
|
||||
type: object
|
||||
properties:
|
||||
select:
|
||||
$ref: "#/components/schemas/UserCountOutputTypeSelect"
|
||||
OrganizationCountOutputTypeArgs:
|
||||
OrganizationCountOutputTypeDefaultArgs:
|
||||
type: object
|
||||
properties:
|
||||
select:
|
||||
$ref: "#/components/schemas/OrganizationCountOutputTypeSelect"
|
||||
ProjectCountOutputTypeArgs:
|
||||
ProjectCountOutputTypeDefaultArgs:
|
||||
type: object
|
||||
properties:
|
||||
select:
|
||||
$ref: "#/components/schemas/ProjectCountOutputTypeSelect"
|
||||
AgentCountOutputTypeArgs:
|
||||
AgentCountOutputTypeDefaultArgs:
|
||||
type: object
|
||||
properties:
|
||||
select:
|
||||
$ref: "#/components/schemas/AgentCountOutputTypeSelect"
|
||||
DatabaseCountOutputTypeArgs:
|
||||
DatabaseCountOutputTypeDefaultArgs:
|
||||
type: object
|
||||
properties:
|
||||
select:
|
||||
$ref: "#/components/schemas/DatabaseCountOutputTypeSelect"
|
||||
BackupCountOutputTypeArgs:
|
||||
BackupCountOutputTypeDefaultArgs:
|
||||
type: object
|
||||
properties:
|
||||
select:
|
||||
@@ -14421,7 +14421,7 @@ components:
|
||||
user:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/UserArgs"
|
||||
- $ref: "#/components/schemas/UserDefaultArgs"
|
||||
SessionSelect:
|
||||
type: object
|
||||
properties:
|
||||
@@ -14440,7 +14440,7 @@ components:
|
||||
user:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/UserArgs"
|
||||
- $ref: "#/components/schemas/UserDefaultArgs"
|
||||
VerificationTokenSelect:
|
||||
type: object
|
||||
properties:
|
||||
@@ -14496,7 +14496,7 @@ components:
|
||||
_count:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/UserCountOutputTypeArgs"
|
||||
- $ref: "#/components/schemas/UserCountOutputTypeDefaultArgs"
|
||||
OrganizationSelect:
|
||||
type: object
|
||||
properties:
|
||||
@@ -14523,7 +14523,7 @@ components:
|
||||
_count:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/OrganizationCountOutputTypeArgs"
|
||||
- $ref: "#/components/schemas/OrganizationCountOutputTypeDefaultArgs"
|
||||
UserOrganizationSelect:
|
||||
type: object
|
||||
properties:
|
||||
@@ -14540,11 +14540,11 @@ components:
|
||||
user:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/UserArgs"
|
||||
- $ref: "#/components/schemas/UserDefaultArgs"
|
||||
organization:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/OrganizationArgs"
|
||||
- $ref: "#/components/schemas/OrganizationDefaultArgs"
|
||||
role:
|
||||
type: boolean
|
||||
ProjectSelect:
|
||||
@@ -14567,7 +14567,7 @@ components:
|
||||
organization:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/OrganizationArgs"
|
||||
- $ref: "#/components/schemas/OrganizationDefaultArgs"
|
||||
databases:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
@@ -14575,7 +14575,7 @@ components:
|
||||
_count:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/ProjectCountOutputTypeArgs"
|
||||
- $ref: "#/components/schemas/ProjectCountOutputTypeDefaultArgs"
|
||||
AgentSelect:
|
||||
type: object
|
||||
properties:
|
||||
@@ -14600,7 +14600,7 @@ components:
|
||||
_count:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/AgentCountOutputTypeArgs"
|
||||
- $ref: "#/components/schemas/AgentCountOutputTypeDefaultArgs"
|
||||
DatabaseSelect:
|
||||
type: object
|
||||
properties:
|
||||
@@ -14629,7 +14629,7 @@ components:
|
||||
agent:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/AgentArgs"
|
||||
- $ref: "#/components/schemas/AgentDefaultArgs"
|
||||
lastContact:
|
||||
type: boolean
|
||||
backups:
|
||||
@@ -14645,11 +14645,11 @@ components:
|
||||
project:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/ProjectArgs"
|
||||
- $ref: "#/components/schemas/ProjectDefaultArgs"
|
||||
_count:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/DatabaseCountOutputTypeArgs"
|
||||
- $ref: "#/components/schemas/DatabaseCountOutputTypeDefaultArgs"
|
||||
BackupSelect:
|
||||
type: object
|
||||
properties:
|
||||
@@ -14668,7 +14668,7 @@ components:
|
||||
database:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/DatabaseArgs"
|
||||
- $ref: "#/components/schemas/DatabaseDefaultArgs"
|
||||
restorations:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
@@ -14676,7 +14676,7 @@ components:
|
||||
_count:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/BackupCountOutputTypeArgs"
|
||||
- $ref: "#/components/schemas/BackupCountOutputTypeDefaultArgs"
|
||||
RestorationSelect:
|
||||
type: object
|
||||
properties:
|
||||
@@ -14693,13 +14693,13 @@ components:
|
||||
backup:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/BackupArgs"
|
||||
- $ref: "#/components/schemas/BackupDefaultArgs"
|
||||
databaseId:
|
||||
type: boolean
|
||||
database:
|
||||
oneOf:
|
||||
- type: boolean
|
||||
- $ref: "#/components/schemas/DatabaseArgs"
|
||||
- $ref: "#/components/schemas/DatabaseDefaultArgs"
|
||||
SettingsSelect:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
+1
-3
@@ -1,9 +1,7 @@
|
||||
|
||||
import {createSafeActionClient} from "next-safe-action";
|
||||
import {currentUser} from "@/auth/current-user";
|
||||
import {baseAuth} from "@/auth/auth";
|
||||
import {Organization} from "@prisma/client";
|
||||
import {currentOrganization} from "@/auth/current-organization";
|
||||
|
||||
|
||||
export class ActionError extends Error {
|
||||
constructor(message: string) {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import {useEffect, useState} from "react"
|
||||
|
||||
const HydrationZustand = ({children}) => {
|
||||
const [isHydrated, setIsHydrated] = useState(false)
|
||||
|
||||
// Wait till Next.js rehydration completes
|
||||
useEffect(() => {
|
||||
setIsHydrated(true)
|
||||
}, [])
|
||||
|
||||
return <>{isHydrated ? <div>{children}</div> : null}</>
|
||||
}
|
||||
|
||||
export default HydrationZustand
|
||||
@@ -1,31 +0,0 @@
|
||||
'use client'
|
||||
|
||||
import {type ReactNode, createContext, useRef} from 'react'
|
||||
|
||||
import {useStore} from '@/state-management/store'
|
||||
|
||||
export type GlobalStoreApi = ReturnType<typeof useStore>
|
||||
|
||||
export const GlobalStoreContext = createContext<GlobalStoreApi | undefined>(
|
||||
undefined,
|
||||
)
|
||||
|
||||
export interface CounterStoreProviderProps {
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
export const GlobalStoreProvider = ({
|
||||
children,
|
||||
}: CounterStoreProviderProps) => {
|
||||
const storeRef = useRef<GlobalStoreApi>()
|
||||
if (!storeRef.current) {
|
||||
storeRef.current = useStore()
|
||||
}
|
||||
|
||||
return (
|
||||
<GlobalStoreContext.Provider value={storeRef.current}>
|
||||
{children}
|
||||
</GlobalStoreContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
import {persist} from "zustand/middleware";
|
||||
|
||||
import {create} from "zustand";
|
||||
|
||||
export type GlobalState = {
|
||||
organizationId: string
|
||||
}
|
||||
|
||||
export type GlobalActions = {
|
||||
moveToAnotherOrganization: (id: string) => void
|
||||
}
|
||||
|
||||
export type GlobalStore = GlobalState & GlobalActions
|
||||
|
||||
export const defaultInitState: GlobalState = {
|
||||
organizationId: "",
|
||||
}
|
||||
|
||||
export const useStore = create<GlobalStore>()(
|
||||
persist(
|
||||
(set) => ({
|
||||
...defaultInitState,
|
||||
moveToAnotherOrganization: (id: string) => set((state) => ({organizationId: id})),
|
||||
}),
|
||||
{
|
||||
name: "global-storage",
|
||||
|
||||
}
|
||||
)
|
||||
);
|
||||
Reference in New Issue
Block a user