feat(cms): wire DyvoLis gallery to CMS, fix eslint config
Add galleryImages array field to DyvoLisPage global so the photo gallery is editable from Payload admin. Component falls back to 24 static images when no CMS images are uploaded. Fix eslint flat-config error caused by referencing @typescript-eslint plugin without an explicit import. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
03c7640874
commit
7c5b5979bd
4 changed files with 23 additions and 7 deletions
|
|
@ -5,8 +5,6 @@ const eslintConfig = [
|
|||
...nextConfig,
|
||||
{
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export const revalidate = 60
|
|||
async function getDyvoLisData() {
|
||||
try {
|
||||
const payload = await getPayload({ config: configPromise })
|
||||
return await payload.findGlobal({ slug: 'dyvolis-page', depth: 0 })
|
||||
return await payload.findGlobal({ slug: 'dyvolis-page', depth: 1 })
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
|
|
@ -38,7 +38,15 @@ export default async function DyvoLisPage() {
|
|||
statLabel={data?.heroStatLabel ?? undefined}
|
||||
tips={data?.heroTips?.map((t: { text: string }) => t.text)}
|
||||
/>
|
||||
<DyvoLisGallery quote={data?.galleryQuote ?? undefined} />
|
||||
<DyvoLisGallery
|
||||
quote={data?.galleryQuote ?? undefined}
|
||||
images={data?.galleryImages
|
||||
?.map((item: { image?: { url?: string | null } | string | null }) => {
|
||||
if (!item.image || typeof item.image === 'string') return null
|
||||
return item.image.url ?? null
|
||||
})
|
||||
.filter((u: string | null): u is string => u !== null)}
|
||||
/>
|
||||
<DyvoLisWhyVisit
|
||||
title={data?.whyVisitTitle ?? undefined}
|
||||
items={
|
||||
|
|
|
|||
|
|
@ -32,13 +32,16 @@ const GALLERY = [
|
|||
|
||||
interface DyvoLisGalleryProps {
|
||||
quote?: string
|
||||
images?: string[]
|
||||
}
|
||||
|
||||
export function DyvoLisGallery({
|
||||
quote = 'Це місце – де малеча зустрічає героїв улюблених казок. Простір справжнього дитинства.',
|
||||
images,
|
||||
}: DyvoLisGalleryProps) {
|
||||
const photos = images && images.length > 0 ? images : GALLERY
|
||||
const [active, setActive] = useState(0)
|
||||
const n = GALLERY.length
|
||||
const n = photos.length
|
||||
|
||||
useEffect(() => {
|
||||
const t = setInterval(() => setActive((p) => (p + 1) % n), 3500)
|
||||
|
|
@ -71,7 +74,7 @@ export function DyvoLisGallery({
|
|||
className="relative mx-auto h-[260px] max-w-[1204px] lg:h-[400px]"
|
||||
style={{ perspective: '1100px' }}
|
||||
>
|
||||
{GALLERY.map((src, i) => {
|
||||
{photos.map((src, i) => {
|
||||
const d = getOffset(i)
|
||||
const absD = Math.abs(d)
|
||||
const sign = d >= 0 ? 1 : -1
|
||||
|
|
@ -139,7 +142,7 @@ export function DyvoLisGallery({
|
|||
</button>
|
||||
|
||||
<div className="flex gap-2.5">
|
||||
{GALLERY.map((_, i) => (
|
||||
{photos.map((_, i) => (
|
||||
<button
|
||||
key={i}
|
||||
onClick={() => setActive(i)}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,13 @@ export const DyvoLisPage: GlobalConfig = {
|
|||
defaultValue:
|
||||
'Це місце – де малеча зустрічає героїв улюблених казок. Простір справжнього дитинства.',
|
||||
},
|
||||
{
|
||||
name: 'galleryImages',
|
||||
type: 'array',
|
||||
label: 'Фото галерея',
|
||||
admin: { description: 'Якщо порожньо — відображаються 24 стандартні фото' },
|
||||
fields: [{ name: 'image', type: 'upload', relationTo: 'media', required: true }],
|
||||
},
|
||||
// Why visit section
|
||||
{
|
||||
name: 'whyVisitTitle',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue