-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
657540f
commit 5b79606
Showing
10 changed files
with
222 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
DATABASE_URL="your mongodb url" | ||
# Database URL for MongoDB connection | ||
# Format: "mongodb+srv://<username>:<password>@<cluster-url>/<database-name>" | ||
DATABASE_URL="your_mongodb_connection_string_here" | ||
|
||
# SMTP Configuration for Email Services | ||
# Replace with your SMTP provider's details if not using Gmail. | ||
SMTP_HOST="smtp.gmail.com" # SMTP server host | ||
SMTP_PORT=587 # SMTP server port (587 for TLS) | ||
SMTP_SECURE=false # Use false for TLS/STARTTLS, true for SSL | ||
SMTP_USER="[email protected]" # Email address to send from | ||
SMTP_PASS="your_smtp_password_here" # SMTP password or app-specific password for Gmail | ||
|
||
# NextAuth Configuration | ||
# NEXTAUTH_URL: Set to your app's URL for production; use http://localhost:3000 for local development. | ||
NEXTAUTH_URL="http://localhost:3000" # Base URL for NextAuth authentication | ||
NEXTAUTH_SECRET="your_nextauth_secret_here" # Secret used to sign NextAuth tokens | ||
|
||
# Cloudinary Configuration for Image Uploads | ||
# Replace these with your Cloudinary account details for image uploads. | ||
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME="your_cloud_name_here" # Cloudinary cloud name | ||
NEXT_PUBLIC_CLOUDINARY_CLOUD_PRESET="your_upload_preset" # Cloudinary upload preset | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
alimento-nextjs/components/multistepForm/pages/formPage4.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import ImageUpload from '@/components/ui/imageUpload'; | ||
import { useGlobalDish } from '@/context/dishFormContext'; | ||
|
||
const FormPage4 = () => { | ||
const { imageUrl, handleImageChange, handleImageRemove } = useGlobalDish(); | ||
|
||
return ( | ||
<div className="h-3/4 flex mb-5 flex-col items-start gap-8 justify-start"> | ||
<h1 className="text-primary-marineBlue font-bold text-[1.6rem] md:text-4xl leading-9"> | ||
Add Images | ||
</h1> | ||
<h3 className="text-gray-400 mt-2 "> | ||
Please add some images for your listing | ||
<br /> | ||
</h3> | ||
<ImageUpload | ||
value={imageUrl.map(imageUrl => imageUrl)} | ||
onChange={handleImageChange} | ||
onRemove={handleImageRemove} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FormPage4; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
'use client'; | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { ImagePlus, Trash } from 'lucide-react'; | ||
import Image from 'next/image'; | ||
import { | ||
CldUploadWidget, | ||
CloudinaryUploadWidgetResults, | ||
} from 'next-cloudinary'; | ||
|
||
import { Button } from '@/components/ui/button'; | ||
|
||
interface ImageUploadProps { | ||
disabled?: boolean; | ||
onChange: (value: string) => void; | ||
onRemove: (value: string) => void; | ||
value: string[]; | ||
} | ||
|
||
const ImageUpload: React.FC<ImageUploadProps> = ({ | ||
disabled, | ||
onChange, | ||
onRemove, | ||
value, | ||
}) => { | ||
const [isMounted, setIsMounted] = useState(false); | ||
|
||
useEffect(() => { | ||
setIsMounted(true); | ||
}, []); | ||
|
||
const onUpload = (result: CloudinaryUploadWidgetResults) => { | ||
if (typeof result.info !== 'string' && result.info?.secure_url) { | ||
onChange(result.info.secure_url); | ||
console.log(value); | ||
} | ||
}; | ||
|
||
if (!isMounted) return null; | ||
|
||
return ( | ||
<div> | ||
<div className="mb-4 flex items-center gap-4"> | ||
{/* iterate to display existing images */} | ||
{value.map(url => ( | ||
<div | ||
key={url} | ||
className="relative w-[200px] h-[200px] rounded-md overflow-hidden" | ||
> | ||
<div className="z-10 absolute top-2 right-2"> | ||
<Button | ||
type="button" | ||
variant={'destructive'} | ||
onClick={() => onRemove(url)} | ||
size={'icon'} | ||
> | ||
<Trash className="h-4 w-4" /> | ||
</Button> | ||
</div> | ||
<Image fill className="object-cover" alt="Image" src={url} /> | ||
</div> | ||
))} | ||
</div> | ||
|
||
{/* upload image button */} | ||
<CldUploadWidget onSuccess={onUpload} uploadPreset={process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_PRESET}> | ||
{({ open }) => { | ||
const onClick = () => { | ||
open(); | ||
}; | ||
|
||
return ( | ||
<Button | ||
type="button" | ||
disabled={disabled} | ||
variant={'secondary'} | ||
onClick={onClick} | ||
> | ||
<ImagePlus className="w-4 h-4 mr-2" /> | ||
Upload an Image | ||
</Button> | ||
); | ||
}} | ||
</CldUploadWidget> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ImageUpload; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
import type { NextConfig } from "next"; | ||
import type { NextConfig } from 'next'; | ||
|
||
const nextConfig: NextConfig = { | ||
/* config options here */ | ||
images: { | ||
remotePatterns: [ | ||
{ | ||
protocol: 'https', | ||
hostname: 'res.cloudinary.com', | ||
port: '', | ||
pathname: '/**', | ||
}, | ||
] | ||
}, | ||
}; | ||
|
||
export default nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters