feat: auth & admin

This commit is contained in:
2026-06-03 10:41:53 +03:00
parent 612d0f0125
commit 7dc59fb3c4
120 changed files with 4683 additions and 2159 deletions
@@ -13,43 +13,43 @@ SWR enables request deduplication, caching, and revalidation across component in
```tsx
function UserList() {
const [users, setUsers] = useState([])
const [users, setUsers] = useState([]);
useEffect(() => {
fetch('/api/users')
.then(r => r.json())
.then(setUsers)
}, [])
.then((r) => r.json())
.then(setUsers);
}, []);
}
```
**Correct (multiple instances share one request):**
```tsx
import useSWR from 'swr'
import useSWR from 'swr';
function UserList() {
const { data: users } = useSWR('/api/users', fetcher)
const { data: users } = useSWR('/api/users', fetcher);
}
```
**For immutable data:**
```tsx
import { useImmutableSWR } from '@/lib/swr'
import { useImmutableSWR } from '@/lib/swr';
function StaticContent() {
const { data } = useImmutableSWR('/api/config', fetcher)
const { data } = useImmutableSWR('/api/config', fetcher);
}
```
**For mutations:**
```tsx
import { useSWRMutation } from 'swr/mutation'
import { useSWRMutation } from 'swr/mutation';
function UpdateButton() {
const { trigger } = useSWRMutation('/api/user', updateUser)
return <button onClick={() => trigger()}>Update</button>
const { trigger } = useSWRMutation('/api/user', updateUser);
return <button onClick={() => trigger()}>Update</button>;
}
```