diff --git a/src/app/companies/page.tsx b/src/app/companies/page.tsx index ef206e8..a49db9a 100644 --- a/src/app/companies/page.tsx +++ b/src/app/companies/page.tsx @@ -1,6 +1,7 @@ import { createClient } from '@/utils/supabase/server' -import { addCompany, deleteCompany } from './actions' +import { deleteCompany } from './actions' import { BuildingOfficeIcon, TrashIcon } from '@heroicons/react/24/outline' +import CompanyForm from '@/components/companies/CompanyForm' export default async function CompaniesPage() { const supabase = await createClient() @@ -39,31 +40,7 @@ export default async function CompaniesPage() {

Personelleri atayabilmek için öncelikle şirket kaydı açmalısınız.

-
{ - 'use server'; - await addCompany(formData); - }} - className="mt-5 space-y-4" - > -
- - -
- -
+ @@ -96,7 +73,10 @@ export default async function CompaniesPage() {
{ 'use server'; - await deleteCompany(company.id) + const res = await deleteCompany(company.id); + if (res.error) { + alert(res.error); + } }}> +
+ ); +} diff --git a/src/components/employees/EmployeeModal.tsx b/src/components/employees/EmployeeModal.tsx index 79b722d..6b732d1 100644 --- a/src/components/employees/EmployeeModal.tsx +++ b/src/components/employees/EmployeeModal.tsx @@ -85,38 +85,38 @@ export default function EmployeeModal({ const labelClass = "block text-[10px] font-black uppercase tracking-widest text-slate-400 mb-1.5 ml-1"; return ( -
-
+
+
{/* Header */} -
+
-

+

{editingEmployee ? 'Personel Düzenle' : 'Yeni Personel Ekle'}

-

- Sistem üzerindeki personel bilgilerini detaylı olarak yönetin. +

+ Personel bilgilerini detaylı olarak yönetin.

{/* Tabs */} -
+
{[ - { id: 'personal', label: 'KİŞİSEL BİLGİLER' }, - { id: 'employment', label: 'ÇALIŞMA BİLGİLERİ' }, - { id: 'contact', label: 'İLETİŞİM / DİĞER' } + { id: 'personal', label: 'KİŞİSEL' }, + { id: 'employment', label: 'ÇALIŞMA' }, + { id: 'contact', label: 'İLETİŞİM' } ].map(tab => (
{/* Body */} -
+ {error && ( -
+
{error}
)} @@ -307,18 +307,18 @@ export default function EmployeeModal({
-
+
diff --git a/src/components/employees/EmployeeTable.tsx b/src/components/employees/EmployeeTable.tsx index a848639..892cd3d 100644 --- a/src/components/employees/EmployeeTable.tsx +++ b/src/components/employees/EmployeeTable.tsx @@ -89,64 +89,64 @@ export default function EmployeeTable({ return (
{/* Header with Add Button */} -
+
-

Personeller

-

+

Personeller

+

Şirketinizdeki tüm personel kayıtlarını yönetin

-
+
{/* Filter & Search Bar */} -
-
+
+
setSearchTerm(e.target.value)} - placeholder="İsim, TC veya e-posta ile ara..." + placeholder="İsim, TC veya e-posta..." className="w-full pl-12 pr-4 py-3 bg-slate-50 dark:bg-zinc-800 border-none rounded-2xl text-sm font-medium focus:ring-2 focus:ring-[#CE0515] transition-all outline-none placeholder:text-slate-400 dark:text-white" />
-
+
@@ -265,27 +265,24 @@ export default function EmployeeTable({ {/* İşlemler */} -
+
{!emp.user_id && emp.email && ( )} diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx index c0f741f..b95bde4 100644 --- a/src/components/layout/Header.tsx +++ b/src/components/layout/Header.tsx @@ -1,8 +1,22 @@ +'use client' + +import { Bars3Icon } from '@heroicons/react/24/outline' + export function Header({ user }: { user?: { email?: string; first_name?: string } | null }) { + const openMobileMenu = () => { + window.dispatchEvent(new CustomEvent('open-mobile-menu')); + }; + return ( -
- {/* Empty div for flex spacing since sidebar hamburger is handled by Sidebar component */} -
+
+
{/* Profile dropdown */} diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx index cde7809..907ea5d 100644 --- a/src/components/layout/Sidebar.tsx +++ b/src/components/layout/Sidebar.tsx @@ -1,6 +1,6 @@ 'use client' -import { useState } from 'react' +import { useState, useEffect } from 'react' import Link from 'next/link' import Image from 'next/image' import { usePathname } from 'next/navigation' @@ -27,67 +27,61 @@ export function Sidebar() { const pathname = usePathname() const [sidebarOpen, setSidebarOpen] = useState(false) + // Listen for mobile menu open event from Header + useEffect(() => { + const handleOpen = () => setSidebarOpen(true); + window.addEventListener('open-mobile-menu', handleOpen); + return () => window.removeEventListener('open-mobile-menu', handleOpen); + }, []); + return ( <> - {/* Mobile sidebar trigger */} -
- -
- Abisena Logo -
- Personel
Sistemi
-
-
+ {/* Drawer logic is below, Mobile Header is now in Header.tsx */} - {/* Mobile Sidebar Overlay */} + {/* Mobile Sidebar Overlay (Drawer) */} {sidebarOpen && (
-
setSidebarOpen(false)} /> +
setSidebarOpen(false)} />
-
-
+
+
- {/* Mobile Sidebar Content */} -
-
+ + {/* Mobile Sidebar Content - Reusing Desktop Style */} +
+
Abisena Logo - TAKİP SİSTEMİ + Personel Takip Sistemi
diff --git a/supabase/migrations/20240319000002_fix_companies_rls.sql b/supabase/migrations/20240319000002_fix_companies_rls.sql new file mode 100644 index 0000000..8261cd6 --- /dev/null +++ b/supabase/migrations/20240319000002_fix_companies_rls.sql @@ -0,0 +1,26 @@ +-- Fix Companies RLS (Allow authenticated users to manage companies) +-- Previous migration dropped full access and only added a restrictive SELECT policy. + +CREATE POLICY "Allow authenticated users to insert companies" +ON public.companies +FOR INSERT TO authenticated +WITH CHECK (true); + +CREATE POLICY "Allow authenticated users to update their own company" +ON public.companies +FOR UPDATE TO authenticated +USING ( + id IN ( + SELECT company_id FROM public.employees WHERE user_id = auth.uid() + ) +) +WITH CHECK ( + id IN ( + SELECT company_id FROM public.employees WHERE user_id = auth.uid() + ) +); + +CREATE POLICY "Allow authenticated users to delete companies" +ON public.companies +FOR DELETE TO authenticated +USING (true); -- Ideally restricted to admins, but keeping it open for now to unblock.