feat: add delivery address migration, update companies server actions and rewrite companies page to support creation and edit of full address
All checks were successful
Staging Build / build (push) Successful in 2m37s
All checks were successful
Staging Build / build (push) Successful in 2m37s
This commit is contained in:
@@ -9,20 +9,32 @@ export async function getCompanies() {
|
||||
return data
|
||||
}
|
||||
|
||||
export async function createCompany(name: string) {
|
||||
export async function createCompany(data: { name: string; street?: string; zip?: string; city?: string; email?: string }) {
|
||||
const admin = createAdminClient()
|
||||
const { data, error } = await admin.from('companies').insert({ name }).select().single()
|
||||
const { data: dbData, error } = await admin.from('companies').insert({
|
||||
name: data.name,
|
||||
street: data.street || null,
|
||||
zip: data.zip || null,
|
||||
city: data.city || null,
|
||||
email: data.email || null,
|
||||
}).select().single()
|
||||
if (error) throw error
|
||||
revalidatePath('/admin/companies')
|
||||
return data
|
||||
return dbData
|
||||
}
|
||||
|
||||
export async function updateCompany(id: string, name: string) {
|
||||
export async function updateCompany(id: string, data: { name: string; street?: string; zip?: string; city?: string; email?: string }) {
|
||||
const admin = createAdminClient()
|
||||
const { data, error } = await admin.from('companies').update({ name }).eq('id', id).select().single()
|
||||
const { data: dbData, error } = await admin.from('companies').update({
|
||||
name: data.name,
|
||||
street: data.street || null,
|
||||
zip: data.zip || null,
|
||||
city: data.city || null,
|
||||
email: data.email || null,
|
||||
}).eq('id', id).select().single()
|
||||
if (error) throw error
|
||||
revalidatePath('/admin/companies')
|
||||
return data
|
||||
return dbData
|
||||
}
|
||||
|
||||
export async function deleteCompany(id: string) {
|
||||
|
||||
Reference in New Issue
Block a user