npm package: @larussoft/admin
Description: Modular Next.js 15 admin panel package for Larussoft projects
Author: Larussoft
Latest version: 0.3.5

# @larussoft/admin

Next.js 15 tabanlı modüler admin panel paketi. Larussoft projelerine kurulur, ihtiyaç duyulan modüller aktif edilir, proje özel sayfalar eklenir.

## Kurulum

```bash
npm install @larussoft/admin
```

### Peer Bağımlılıklar

```bash
npm install next react react-dom @larussoft/core
```

## Hızlı Başlangıç

```tsx
// proje/app/admin/layout.tsx
import { AdminProvider } from '@larussoft/admin/providers'
import { AdminLayout } from '@larussoft/admin/core'

export default function Layout({ children }) {
  return (
    <AdminProvider config={{
      appName: 'Randevio Admin',
      modules: ['core', 'cms'],
      api: { baseURL: process.env.NEXT_PUBLIC_API_URL! },
      extraMenuItems: [
        { label: 'Salonlar', href: '/admin/salons', icon: 'store' },
      ],
    }}>
      <AdminLayout>
        {children}
      </AdminLayout>
    </AdminProvider>
  )
}
```

## Modüller

| Import Yolu | Açıklama |
|---|---|
| `@larussoft/admin/core` | Layout, sidebar, header, auth guard |
| `@larussoft/admin/components` | DataTable, FormBuilder, RichEditor |
| `@larussoft/admin/hooks` | usePermission, useAdminApi, useAdminList, useTranslations |
| `@larussoft/admin/providers` | AdminProvider context |
| `@larussoft/admin/setup` | İlk kurulum seed yardımcısı |

## Paylaşımlı Componentler

```tsx
import { DataTable, FormBuilder, RichEditor } from '@larussoft/admin/components'
```

## API Hook'ları

```tsx
import { useAdminApi, useAdminList, useAdminMutation } from '@larussoft/admin/hooks'
import { USERS } from '@larussoft/admin/lib/endpoints'

// Sayfalanmış liste
const { data, loading, execute } = useAdminList<User>(USERS.LIST)

// Tekil kayıt
const { data: user } = useAdminApi<User>(USERS.DETAIL(id))

// Mutation
const { execute: createUser } = useAdminMutation<User, CreateUserDto>('post', USERS.CREATE)
```

## RBAC

```tsx
import { usePermission } from '@larussoft/admin/hooks'

const canEdit = usePermission('salons.edit')
// false ise component render edilmez
```

## İlk Kurulum (Seed)

Proje tarafında seed script'i oluşturulur:

```ts
// proje/scripts/seed.ts
import { seedAdmin } from '@larussoft/admin/setup'

await seedAdmin({
  apiUrl: 'http://localhost:4000',
  admin: { name: 'Admin', email: 'admin@proje.com', password: 'Secret123!' },
  siteName: 'Proje Admin',
  locale: 'tr',
})
```

## Backend Entegrasyonu

Admin panel `@larussoft/backend` API endpoint'lerine bağlanır. Backend ayrı projede çalışır:

```typescript
// proje/backend/src/app.module.ts
import { BackendModule } from '@larussoft/backend'
import { AdminModule } from '@larussoft/backend/admin'

@Module({
  imports: [
    BackendModule.forRoot({
      database: { host: 'localhost', port: 5432, database: 'mydb', username: 'postgres', password: '' },
      auth: { jwt: { secret: process.env.JWT_SECRET! }, loginWith: 'email' },
    }),
    AdminModule.forRoot({ userEntity: User }),
  ],
})
export class AppModule {}
```

## Teknoloji

- Next.js 15 App Router
- TypeScript (strict)
- Tailwind CSS v4
- TipTap (zengin metin editörü)
- Zustand (state yönetimi)
- React Hook Form + Zod (form)
- TanStack Table (tablo)
- Lucide React (ikon)

## Lisans

MIT