create-nextjs-cms 0.9.15 → 0.9.16
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
|
@@ -51,7 +51,7 @@ export default function ItemEditPage({
|
|
|
51
51
|
const handleDirtyChange = useCallback((isDirty: boolean) => setFormDirty(isDirty), [])
|
|
52
52
|
const dropzoneRef: RefObject<DropzoneHandles | null> = useRef(null)
|
|
53
53
|
const variantRef: RefObject<VariantHandles[]> = useRef([])
|
|
54
|
-
const [data, {refetch}] = trpc.hasItemsSections.editItem.useSuspenseQuery({
|
|
54
|
+
const [data, { refetch }] = trpc.hasItemsSections.editItem.useSuspenseQuery({
|
|
55
55
|
sectionName: section,
|
|
56
56
|
sectionItemId: itemId,
|
|
57
57
|
locale,
|
|
@@ -222,21 +222,21 @@ export default function ItemEditPage({
|
|
|
222
222
|
}, [])
|
|
223
223
|
|
|
224
224
|
if (data.error) {
|
|
225
|
-
|
|
225
|
+
return <ErrorComponent message={data.error.message} />
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
return (
|
|
229
229
|
<div className='flex w-full flex-col overflow-hidden'>
|
|
230
230
|
<div className='flex w-full flex-col'>
|
|
231
|
-
<div className='relative z-1 border-b-2 p-8 pt-12 font-extrabold
|
|
232
|
-
<div className='absolute
|
|
231
|
+
<div className='text-foreground relative z-1 border-b-2 p-8 pt-12 font-extrabold'>
|
|
232
|
+
<div className='absolute top-0 left-0 z-2 h-4 w-full bg-linear-to-r from-emerald-800 via-emerald-400 to-sky-600'></div>
|
|
233
233
|
<h1 className='pb-4 text-4xl'>{data.section?.title.section}</h1>
|
|
234
234
|
<span>
|
|
235
235
|
/{t('edit')} {data.section?.title.singular}
|
|
236
236
|
</span>
|
|
237
237
|
</div>
|
|
238
238
|
{data.localization?.localeSwitcherEnabled ? (
|
|
239
|
-
<div className=
|
|
239
|
+
<div className='px-4 pt-4'>
|
|
240
240
|
<LocaleSwitcher
|
|
241
241
|
section={section}
|
|
242
242
|
itemId={itemId}
|
|
@@ -245,29 +245,29 @@ export default function ItemEditPage({
|
|
|
245
245
|
existingTranslations={data.localization.existingTranslations}
|
|
246
246
|
locales={data.localization.locales}
|
|
247
247
|
hasUnsavedChanges={formDirty}
|
|
248
|
+
developerOnly={data.localization.developerNoteEnabled}
|
|
248
249
|
/>
|
|
249
250
|
{locale && (
|
|
250
251
|
<Alert variant='info' className='mt-2 w-full'>
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
</
|
|
270
|
-
</Alert>
|
|
252
|
+
<AlertDescription className='text-md font-bold'>
|
|
253
|
+
<div className='flex items-center justify-between'>
|
|
254
|
+
<span>{t('editingContentTranslation', { locale })}</span>
|
|
255
|
+
{data.localization.existingTranslations.includes(locale) && (
|
|
256
|
+
<button
|
|
257
|
+
type='button'
|
|
258
|
+
onClick={handleDeleteLocale}
|
|
259
|
+
disabled={deleteLocaleMutation.isPending}
|
|
260
|
+
className='inline-flex items-center gap-1.5 rounded-md bg-red-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-red-700 disabled:opacity-50'
|
|
261
|
+
>
|
|
262
|
+
<Trash2 className='h-3.5 w-3.5' />
|
|
263
|
+
{deleteLocaleMutation.isPending
|
|
264
|
+
? t('loading')
|
|
265
|
+
: t('deleteLocaleTranslation')}
|
|
266
|
+
</button>
|
|
267
|
+
)}
|
|
268
|
+
</div>
|
|
269
|
+
</AlertDescription>
|
|
270
|
+
</Alert>
|
|
271
271
|
)}
|
|
272
272
|
</div>
|
|
273
273
|
) : null}
|
|
@@ -6,6 +6,7 @@ import { Check } from 'lucide-react'
|
|
|
6
6
|
import { useI18n } from 'nextjs-cms/translations/client'
|
|
7
7
|
import { useSession } from 'nextjs-cms/auth/react'
|
|
8
8
|
import ContainerBox from './ContainerBox'
|
|
9
|
+
import { Alert, AlertDescription } from './ui/alert'
|
|
9
10
|
|
|
10
11
|
type LocaleConfig = {
|
|
11
12
|
code: string
|
|
@@ -21,6 +22,7 @@ type Props = {
|
|
|
21
22
|
existingTranslations: string[]
|
|
22
23
|
locales: LocaleConfig[]
|
|
23
24
|
hasUnsavedChanges?: boolean
|
|
25
|
+
developerOnly?: boolean
|
|
24
26
|
/** Base path for locale links. Defaults to `/edit/${section}/${itemId}` for hasItems sections. */
|
|
25
27
|
basePath?: string
|
|
26
28
|
}
|
|
@@ -33,6 +35,7 @@ export default function LocaleSwitcher({
|
|
|
33
35
|
existingTranslations,
|
|
34
36
|
locales,
|
|
35
37
|
hasUnsavedChanges,
|
|
38
|
+
developerOnly,
|
|
36
39
|
basePath,
|
|
37
40
|
}: Props) {
|
|
38
41
|
const t = useI18n()
|
|
@@ -59,31 +62,37 @@ export default function LocaleSwitcher({
|
|
|
59
62
|
|
|
60
63
|
return (
|
|
61
64
|
<ContainerBox title={t('localesHeading')}>
|
|
62
|
-
<div className=
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
<div className='flex flex-wrap items-center gap-2'>
|
|
66
|
+
{locales.map((locale) => {
|
|
67
|
+
const isActive = locale.code === currentLocale.code
|
|
68
|
+
const hasTranslation =
|
|
69
|
+
locale.code === defaultLocale.code || existingTranslations.includes(locale.code)
|
|
70
|
+
const isDefault = locale.code === defaultLocale.code
|
|
67
71
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
72
|
+
return (
|
|
73
|
+
<Link
|
|
74
|
+
key={locale.code}
|
|
75
|
+
href={getHref(locale.code)}
|
|
76
|
+
onClick={(e) => handleClick(e, locale.code)}
|
|
77
|
+
className={cn(
|
|
78
|
+
'border-primary/20 inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-sm font-medium transition-colors',
|
|
79
|
+
isActive
|
|
80
|
+
? 'bg-success text-success-foreground'
|
|
81
|
+
: 'bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground',
|
|
82
|
+
)}
|
|
83
|
+
>
|
|
84
|
+
{locale.label}
|
|
85
|
+
{isDefault && <span className='text-[10px] opacity-70'>{t('baseLocaleBadge')}</span>}
|
|
86
|
+
{hasTranslation && !isDefault && <Check className='h-3 w-3' />}
|
|
87
|
+
</Link>
|
|
88
|
+
)
|
|
89
|
+
})}
|
|
86
90
|
</div>
|
|
91
|
+
{developerOnly && (
|
|
92
|
+
<Alert variant='info' className='mt-2 w-full'>
|
|
93
|
+
<AlertDescription className='text-md font-bold'>{t('localeSwitcherDevOnly')}</AlertDescription>
|
|
94
|
+
</Alert>
|
|
95
|
+
)}
|
|
87
96
|
</ContainerBox>
|
|
88
97
|
)
|
|
89
98
|
}
|
|
@@ -155,6 +155,7 @@ export default function SectionPage({ section }: { section: string }) {
|
|
|
155
155
|
locales={data.localization.locales}
|
|
156
156
|
hasUnsavedChanges={formDirty}
|
|
157
157
|
basePath={`/section/${section}`}
|
|
158
|
+
developerOnly={data.localization.developerNoteEnabled}
|
|
158
159
|
/>
|
|
159
160
|
{locale && (
|
|
160
161
|
<Alert variant='info' className='mt-2 w-full'>
|