mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
29 lines
863 B
TypeScript
29 lines
863 B
TypeScript
"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 as string)
|
|
}
|
|
|
|
const defaultCurrency = formData.get("default_currency")
|
|
if (defaultCurrency) {
|
|
await updateSettings(user.id, "default_currency", defaultCurrency as string)
|
|
}
|
|
|
|
revalidatePath("/dashboard")
|
|
redirect("/dashboard")
|
|
}
|