Personel Sayfası ve Uygulama renk değişiklikleri
This commit is contained in:
@@ -11,9 +11,10 @@ export async function addEmployee(formData: FormData) {
|
||||
const lastName = formData.get('last_name') as string
|
||||
const email = formData.get('email') as string
|
||||
const companyId = formData.get('company_id') as string
|
||||
const roleId = formData.get('role_id') as string
|
||||
|
||||
if (!email || !companyId) {
|
||||
return { error: 'E-posta ve Şirket seçimi zorunludur.' }
|
||||
if (!email || !companyId || !roleId) {
|
||||
return { error: 'E-posta, Şirket ve Rol seçimi zorunludur.' }
|
||||
}
|
||||
|
||||
// Admin creating users manually currently requires an admin API setup or the user registering themselves
|
||||
@@ -39,9 +40,10 @@ export async function addEmployee(formData: FormData) {
|
||||
.insert([{
|
||||
user_id: existingUser.id,
|
||||
company_id: companyId,
|
||||
role_id: roleId,
|
||||
department: formData.get('department'),
|
||||
title: formData.get('title'),
|
||||
status: 'active'
|
||||
status: formData.get('status') || 'active'
|
||||
}])
|
||||
|
||||
if (employeeError) {
|
||||
@@ -49,7 +51,7 @@ export async function addEmployee(formData: FormData) {
|
||||
if (employeeError.code === '23505') {
|
||||
return { error: 'Bu kullanıcı zaten bu şirkete eklenmiş.' }
|
||||
}
|
||||
return { error: 'Çalışan eklenirken hata: ' + employeeError.message }
|
||||
return { error: 'Personel eklenirken hata: ' + employeeError.message }
|
||||
}
|
||||
|
||||
revalidatePath('/employees')
|
||||
@@ -65,7 +67,29 @@ export async function deleteEmployee(id: string) {
|
||||
.eq('id', id)
|
||||
|
||||
if (error) {
|
||||
return { error: 'Çalışan silinirken hata oluştu: ' + error.message }
|
||||
return { error: 'Personel silinirken hata oluştu: ' + error.message }
|
||||
}
|
||||
|
||||
revalidatePath('/employees')
|
||||
return { success: true }
|
||||
}
|
||||
|
||||
export async function updateEmployee(id: string, formData: FormData) {
|
||||
const supabase = await createClient()
|
||||
|
||||
const { error } = await supabase
|
||||
.from('employees')
|
||||
.update({
|
||||
company_id: formData.get('company_id'),
|
||||
role_id: formData.get('role_id'),
|
||||
department: formData.get('department'),
|
||||
title: formData.get('title'),
|
||||
status: formData.get('status')
|
||||
})
|
||||
.eq('id', id)
|
||||
|
||||
if (error) {
|
||||
return { error: 'Personel güncellenirken hata oluştu: ' + error.message }
|
||||
}
|
||||
|
||||
revalidatePath('/employees')
|
||||
|
||||
Reference in New Issue
Block a user