create-nextjs-cms 0.5.93 → 0.5.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-nextjs-cms",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.95",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"tsx": "^4.20.6",
|
|
30
30
|
"typescript": "^5.9.2",
|
|
31
31
|
"@lzcms/eslint-config": "0.3.0",
|
|
32
|
-
"@lzcms/
|
|
33
|
-
"@lzcms/
|
|
32
|
+
"@lzcms/prettier-config": "0.1.0",
|
|
33
|
+
"@lzcms/tsconfig": "0.1.0"
|
|
34
34
|
},
|
|
35
35
|
"prettier": "@lzcms/prettier-config",
|
|
36
36
|
"scripts": {
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useI18n } from 'nextjs-cms/translations/client'
|
|
4
|
-
import { trpc } from '@/app/_trpc/client'
|
|
5
|
-
import { Badge } from '@/components/ui/badge'
|
|
6
|
-
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
|
|
7
|
-
import ErrorComponent from '@/components/ErrorComponent'
|
|
8
|
-
import { Spinner } from '@/components/ui/spinner'
|
|
9
|
-
|
|
10
|
-
type LogMetadata = {
|
|
11
|
-
fields?: string[]
|
|
12
|
-
previousUsername?: string
|
|
13
|
-
newUsername?: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const formatTimestamp = (value: Date | string | null) => {
|
|
17
|
-
if (!value) return ''
|
|
18
|
-
const date = value instanceof Date ? value : new Date(value)
|
|
19
|
-
if (Number.isNaN(date.getTime())) return ''
|
|
20
|
-
return date.toLocaleString()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const parseMetadata = (metadata?: string | null): LogMetadata | null => {
|
|
24
|
-
if (!metadata) return null
|
|
25
|
-
try {
|
|
26
|
-
return JSON.parse(metadata) as LogMetadata
|
|
27
|
-
} catch (error) {
|
|
28
|
-
return null
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export default function LogPage() {
|
|
33
|
-
const t = useI18n()
|
|
34
|
-
const { data, isLoading, isError, error } = trpc.logs.list.useQuery({
|
|
35
|
-
limit: 50,
|
|
36
|
-
offset: 0,
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
if (isLoading) {
|
|
40
|
-
return (
|
|
41
|
-
<div className='flex w-full items-center justify-center p-8'>
|
|
42
|
-
<Spinner className='size-8' />
|
|
43
|
-
</div>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (isError) {
|
|
48
|
-
return <ErrorComponent message={error?.message || t('noAccessToSection')} />
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const logs = data?.items ?? []
|
|
52
|
-
return (
|
|
53
|
-
<div className='w-full'>
|
|
54
|
-
<div className='text-foreground bg-linear-to-r from-sky-200 via-emerald-300 to-blue-600 p-8 font-extrabold dark:from-blue-800 dark:via-amber-700 dark:to-rose-900'>
|
|
55
|
-
<h1 className='text-3xl'>{t('logs')}</h1>
|
|
56
|
-
</div>
|
|
57
|
-
|
|
58
|
-
<div className='flex flex-col gap-4 p-4'>
|
|
59
|
-
<Table>
|
|
60
|
-
<TableHeader>
|
|
61
|
-
<TableRow>
|
|
62
|
-
<TableHead>{t('date')}</TableHead>
|
|
63
|
-
<TableHead>{t('action')}</TableHead>
|
|
64
|
-
<TableHead>{t('admin')}</TableHead>
|
|
65
|
-
<TableHead>{t('section')}</TableHead>
|
|
66
|
-
<TableHead>{t('details')}</TableHead>
|
|
67
|
-
</TableRow>
|
|
68
|
-
</TableHeader>
|
|
69
|
-
<TableBody>
|
|
70
|
-
{logs.length === 0 ? (
|
|
71
|
-
<TableRow>
|
|
72
|
-
<TableCell colSpan={5} className='text-muted-foreground text-center'>
|
|
73
|
-
{t('noData')}
|
|
74
|
-
</TableCell>
|
|
75
|
-
</TableRow>
|
|
76
|
-
) : (
|
|
77
|
-
logs.map((log) => {
|
|
78
|
-
const metadata = parseMetadata(log.metadata)
|
|
79
|
-
const fields = metadata?.fields?.length ? metadata.fields.join(', ') : null
|
|
80
|
-
const usernameChange =
|
|
81
|
-
metadata?.previousUsername && metadata?.newUsername
|
|
82
|
-
? `${metadata.previousUsername} -> ${metadata.newUsername}`
|
|
83
|
-
: null
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<TableRow key={log.id}>
|
|
87
|
-
<TableCell>{formatTimestamp(log.createdAt)}</TableCell>
|
|
88
|
-
<TableCell>
|
|
89
|
-
<Badge variant='outline'>{log.eventType}</Badge>
|
|
90
|
-
</TableCell>
|
|
91
|
-
<TableCell>{log.actorUsername || log.actorId || '-'}</TableCell>
|
|
92
|
-
<TableCell>{log.sectionName || '-'}</TableCell>
|
|
93
|
-
<TableCell className='text-muted-foreground'>
|
|
94
|
-
{log.entityLabel || log.entityId || '-'}
|
|
95
|
-
{fields ? ` | ${fields}` : ''}
|
|
96
|
-
{usernameChange ? ` | ${usernameChange}` : ''}
|
|
97
|
-
</TableCell>
|
|
98
|
-
</TableRow>
|
|
99
|
-
)
|
|
100
|
-
})
|
|
101
|
-
)}
|
|
102
|
-
</TableBody>
|
|
103
|
-
</Table>
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
)
|
|
107
|
-
}
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useI18n } from 'nextjs-cms/translations/client'
|
|
4
|
+
import { trpc } from '@/app/_trpc/client'
|
|
5
|
+
import { Badge } from '@/components/ui/badge'
|
|
6
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
|
|
7
|
+
import ErrorComponent from '@/components/ErrorComponent'
|
|
8
|
+
import { Spinner } from '@/components/ui/spinner'
|
|
9
|
+
|
|
10
|
+
type LogMetadata = {
|
|
11
|
+
fields?: string[]
|
|
12
|
+
previousUsername?: string
|
|
13
|
+
newUsername?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const formatTimestamp = (value: Date | string | null) => {
|
|
17
|
+
if (!value) return ''
|
|
18
|
+
const date = value instanceof Date ? value : new Date(value)
|
|
19
|
+
if (Number.isNaN(date.getTime())) return ''
|
|
20
|
+
return date.toLocaleString()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const parseMetadata = (metadata?: string | null): LogMetadata | null => {
|
|
24
|
+
if (!metadata) return null
|
|
25
|
+
try {
|
|
26
|
+
return JSON.parse(metadata) as LogMetadata
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return null
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default function LogPage() {
|
|
33
|
+
const t = useI18n()
|
|
34
|
+
const { data, isLoading, isError, error } = trpc.logs.list.useQuery({
|
|
35
|
+
limit: 50,
|
|
36
|
+
offset: 0,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
if (isLoading) {
|
|
40
|
+
return (
|
|
41
|
+
<div className='flex w-full items-center justify-center p-8'>
|
|
42
|
+
<Spinner className='size-8' />
|
|
43
|
+
</div>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (isError) {
|
|
48
|
+
return <ErrorComponent message={error?.message || t('noAccessToSection')} />
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const logs = data?.items ?? []
|
|
52
|
+
return (
|
|
53
|
+
<div className='w-full'>
|
|
54
|
+
<div className='text-foreground bg-linear-to-r from-sky-200 via-emerald-300 to-blue-600 p-8 font-extrabold dark:from-blue-800 dark:via-amber-700 dark:to-rose-900'>
|
|
55
|
+
<h1 className='text-3xl'>{t('logs')}</h1>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div className='flex flex-col gap-4 p-4'>
|
|
59
|
+
<Table>
|
|
60
|
+
<TableHeader>
|
|
61
|
+
<TableRow>
|
|
62
|
+
<TableHead>{t('date')}</TableHead>
|
|
63
|
+
<TableHead>{t('action')}</TableHead>
|
|
64
|
+
<TableHead>{t('admin')}</TableHead>
|
|
65
|
+
<TableHead>{t('section')}</TableHead>
|
|
66
|
+
<TableHead>{t('details')}</TableHead>
|
|
67
|
+
</TableRow>
|
|
68
|
+
</TableHeader>
|
|
69
|
+
<TableBody>
|
|
70
|
+
{logs.length === 0 ? (
|
|
71
|
+
<TableRow>
|
|
72
|
+
<TableCell colSpan={5} className='text-muted-foreground text-center'>
|
|
73
|
+
{t('noData')}
|
|
74
|
+
</TableCell>
|
|
75
|
+
</TableRow>
|
|
76
|
+
) : (
|
|
77
|
+
logs.map((log) => {
|
|
78
|
+
const metadata = parseMetadata(log.metadata)
|
|
79
|
+
const fields = metadata?.fields?.length ? metadata.fields.join(', ') : null
|
|
80
|
+
const usernameChange =
|
|
81
|
+
metadata?.previousUsername && metadata?.newUsername
|
|
82
|
+
? `${metadata.previousUsername} -> ${metadata.newUsername}`
|
|
83
|
+
: null
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<TableRow key={log.id}>
|
|
87
|
+
<TableCell>{formatTimestamp(log.createdAt)}</TableCell>
|
|
88
|
+
<TableCell>
|
|
89
|
+
<Badge variant='outline'>{log.eventType}</Badge>
|
|
90
|
+
</TableCell>
|
|
91
|
+
<TableCell>{log.actorUsername || log.actorId || '-'}</TableCell>
|
|
92
|
+
<TableCell>{log.sectionName || '-'}</TableCell>
|
|
93
|
+
<TableCell className='text-muted-foreground'>
|
|
94
|
+
{log.entityLabel || log.entityId || '-'}
|
|
95
|
+
{fields ? ` | ${fields}` : ''}
|
|
96
|
+
{usernameChange ? ` | ${usernameChange}` : ''}
|
|
97
|
+
</TableCell>
|
|
98
|
+
</TableRow>
|
|
99
|
+
)
|
|
100
|
+
})
|
|
101
|
+
)}
|
|
102
|
+
</TableBody>
|
|
103
|
+
</Table>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"nanoid": "^5.1.2",
|
|
65
65
|
"next": "16.1.1",
|
|
66
66
|
"next-themes": "^0.4.6",
|
|
67
|
-
"nextjs-cms": "0.5.
|
|
67
|
+
"nextjs-cms": "0.5.95",
|
|
68
68
|
"plaiceholder": "^3.0.0",
|
|
69
69
|
"prettier-plugin-tailwindcss": "^0.7.2",
|
|
70
70
|
"qrcode": "^1.5.4",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"eslint-config-prettier": "^10.0.1",
|
|
98
98
|
"eslint-plugin-prettier": "^5.2.3",
|
|
99
99
|
"fs-extra": "^11.3.3",
|
|
100
|
-
"nextjs-cms-kit": "0.5.
|
|
100
|
+
"nextjs-cms-kit": "0.5.95",
|
|
101
101
|
"postcss": "^8.5.1",
|
|
102
102
|
"prettier": "3.5.0",
|
|
103
103
|
"raw-loader": "^4.0.2",
|