This commit is contained in:
@@ -12,6 +12,11 @@ export const POST: APIRoute = async ({ request, locals, redirect }) => {
|
||||
const formData = await request.formData();
|
||||
const organizationId = formData.get("organizationId") as string;
|
||||
const name = formData.get("name") as string;
|
||||
const street = formData.get("street") as string | null;
|
||||
const city = formData.get("city") as string | null;
|
||||
const state = formData.get("state") as string | null;
|
||||
const zip = formData.get("zip") as string | null;
|
||||
const country = formData.get("country") as string | null;
|
||||
|
||||
if (!organizationId || !name || name.trim().length === 0) {
|
||||
return new Response("Organization ID and name are required", {
|
||||
@@ -44,16 +49,23 @@ export const POST: APIRoute = async ({ request, locals, redirect }) => {
|
||||
);
|
||||
}
|
||||
|
||||
// Update organization name
|
||||
// Update organization information
|
||||
await db
|
||||
.update(organizations)
|
||||
.set({ name: name.trim() })
|
||||
.set({
|
||||
name: name.trim(),
|
||||
street: street?.trim() || null,
|
||||
city: city?.trim() || null,
|
||||
state: state?.trim() || null,
|
||||
zip: zip?.trim() || null,
|
||||
country: country?.trim() || null,
|
||||
})
|
||||
.where(eq(organizations.id, organizationId))
|
||||
.run();
|
||||
|
||||
return redirect("/dashboard/team/settings?success=org-name");
|
||||
} catch (error) {
|
||||
console.error("Error updating organization name:", error);
|
||||
return new Response("Failed to update organization name", { status: 500 });
|
||||
console.error("Error updating organization:", error);
|
||||
return new Response("Failed to update organization", { status: 500 });
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user