mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
BREAKING: postgres + saas
This commit is contained in:
28
app/(auth)/actions.ts
Normal file
28
app/(auth)/actions.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
"use server"
|
||||
|
||||
import { createUserDefaults, isDatabaseEmpty } from "@/models/defaults"
|
||||
import { updateSettings } from "@/models/settings"
|
||||
import { createSelfHostedUser } from "@/models/users"
|
||||
import { revalidatePath } from "next/cache"
|
||||
import { redirect } from "next/navigation"
|
||||
|
||||
export async function selfHostedGetStartedAction(formData: FormData) {
|
||||
const user = await createSelfHostedUser()
|
||||
|
||||
if (await isDatabaseEmpty(user.id)) {
|
||||
await createUserDefaults(user.id)
|
||||
}
|
||||
|
||||
const openaiApiKey = formData.get("openai_api_key")
|
||||
if (openaiApiKey) {
|
||||
await updateSettings(user.id, "openai_api_key", openaiApiKey)
|
||||
}
|
||||
|
||||
const defaultCurrency = formData.get("default_currency")
|
||||
if (defaultCurrency) {
|
||||
await updateSettings(user.id, "default_currency", defaultCurrency)
|
||||
}
|
||||
|
||||
revalidatePath("/dashboard")
|
||||
redirect("/dashboard")
|
||||
}
|
||||
Reference in New Issue
Block a user