Image gallery
This commit is contained in:
@@ -2,6 +2,7 @@ import PropertyHeaderImage from '@/components/PropertyHeaderImage';
|
|||||||
import PropertyDetails from '@/components/PropertyDetails';
|
import PropertyDetails from '@/components/PropertyDetails';
|
||||||
import connectDB from '@/config/database';
|
import connectDB from '@/config/database';
|
||||||
import Property from '@/models/Property';
|
import Property from '@/models/Property';
|
||||||
|
import PropertyImages from '@/components/PropertyImages';
|
||||||
|
|
||||||
const PropertyPage = async ({ params }) => {
|
const PropertyPage = async ({ params }) => {
|
||||||
await connectDB();
|
await connectDB();
|
||||||
@@ -101,6 +102,7 @@ const PropertyPage = async ({ params }) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<PropertyImages images={property.images} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import Image from 'next/image';
|
||||||
|
|
||||||
|
const PropertyImages = ({ images }) => {
|
||||||
|
return (
|
||||||
|
<section className='bg-blue-50 p-4'>
|
||||||
|
<div className='container mx-auto'>
|
||||||
|
{images.length === 1 ? (
|
||||||
|
<Image
|
||||||
|
src={images[0]}
|
||||||
|
alt=''
|
||||||
|
className='object-cover h-[400px] mx-auto rounded-xl'
|
||||||
|
width={1800}
|
||||||
|
height={400}
|
||||||
|
priority={true}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className={`grid grid-cols-2 gap-4`}>
|
||||||
|
{images.map((image, index) => (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
className={`${
|
||||||
|
images.length === 3 && index === 2
|
||||||
|
? 'col-span-2'
|
||||||
|
: 'col-span-1'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
src={image}
|
||||||
|
alt=''
|
||||||
|
className='object-cover h-[400px] w-full rounded-xl'
|
||||||
|
width={1800}
|
||||||
|
height={400}
|
||||||
|
priority={true}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PropertyImages;
|
||||||
Reference in New Issue
Block a user