Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 37 additions & 36 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
.env
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Environment variables need documentation and a template file

The codebase uses several environment variables but lacks documentation and a template:

  • NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET for file uploads
  • NEXT_PUBLIC_BACKEND_URL for API endpoints

Action items:

  • Create an .env.example file listing all required variables
  • Add environment setup instructions in README.md
  • Document the purpose and format of each variable
🔗 Analysis chain

LGTM! Verify environment variable documentation exists.

Good practice to ignore .env files to prevent accidental commit of sensitive data.

Let's verify if proper documentation exists for the required environment variables:


Let me try searching for any .env.example or similar template files that might document the environment variables.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for environment variable documentation
# Expected: Find documentation about required env vars in README or similar files

# Look for env var documentation in common locations
echo "Checking for environment documentation..."
rg -i "environment|env var|\.env" README.md || true
fd -g "*.md" -x rg -i "environment|env var|\.env" {} || true

Length of output: 209


Script:

#!/bin/bash
# Check for environment variable template files
fd -g ".env*" --type f

# Look for environment variable usage in the codebase
rg -i "process\.env\." -A 2

# Check for environment setup in package.json scripts
rg "env" package.json

Length of output: 4078

79 changes: 79 additions & 0 deletions app/chef/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import Image from 'next/image'
import Link from 'next/link'

export default function Footer() {
Comment on lines +1 to +4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider relocating the Footer component and adding TypeScript types

This appears to be a shared component but is located in the chef-specific directory. Consider moving it to a shared/common components directory.

Apply these changes:

  1. Move the file to app/components/Footer.tsx
  2. Add TypeScript interface:
+interface FooterProps {
+  className?: string;
+}
+
-export default function Footer() {
+export default function Footer({ className }: FooterProps) {

Committable suggestion skipped: line range outside the PR's diff.

const footer_elements = [
'About',
'Terms & conditions',
'Privacy Policy',
'Contact',
]
Comment on lines +5 to +10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance footer navigation items with proper structure and links

The footer elements should include proper links and be properly typed.

Replace the simple array with a properly structured constant:

-  const footer_elements = [
-    'About',
-    'Terms & conditions',
-    'Privacy Policy',
-    'Contact',
-  ]
+  const FOOTER_LINKS = [
+    { label: 'About', href: '/about' },
+    { label: 'Terms & conditions', href: '/terms' },
+    { label: 'Privacy Policy', href: '/privacy' },
+    { label: 'Contact', href: '/contact' },
+  ] as const;

Then update the mapping:

-  {footer_elements.map((item, index) => (
-    <ul
+  {FOOTER_LINKS.map(({ label, href }) => (
+    <Link
+      href={href}
       key={index}
       className="cursor-pointer hover:text-transparent bg-clip-text bg-gradient-to-t from-[#FE3511] to-[#F0725C]"
     >
-      {item}
-    </ul>
+      {label}
+    </Link>
   ))}

Committable suggestion skipped: line range outside the PR's diff.

return (
<div className="relative bg-white">
<div className="flex justify-between w-full p-8 px-28">
<div>
<Link href="/chef/video">
<Image
src="/svg/WecookedLogo.svg"
alt="WeCooked Logo"
width={120}
height={120}
className="cursor-pointer"
/>
</Link>
</div>
<div className="flex gap-x-6">
{footer_elements.map((item, index) => (
<ul
key={index}
className="cursor-pointer hover:text-transparent bg-clip-text bg-gradient-to-t from-[#FE3511] to-[#F0725C]"
>
{item}
</ul>
))}
</div>
<div className="flex items-center gap-x-3">
<Link href="/">
<Image
src="/svg/fb-ic.svg"
alt="Facebook icon"
width={25}
height={25}
className="cursor-pointer"
/>
</Link>
<Link href="/">
<Image
src="/svg/tweet-ic.svg"
alt="twitter icon"
width={25}
height={25}
className="cursor-pointer"
/>
</Link>
<Link href="/">
<Image
src="/svg/insta-ic.svg"
alt="instagram icon"
width={25}
height={25}
className="cursor-pointer"
/>
</Link>
<Link href="/">
<Image
src="/svg/google-ic.svg"
alt="Google icon"
width={25}
height={25}
className="cursor-pointer"
/>
</Link>
</div>
Comment on lines +35 to +72
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refactor social media section to reduce duplication and add proper links

The social media section contains duplicated code and placeholder links.

  1. Create a structured array for social media links:
const SOCIAL_MEDIA = [
  { platform: 'Facebook', icon: '/svg/fb-ic.svg', href: process.env.NEXT_PUBLIC_FACEBOOK_URL },
  { platform: 'Twitter', icon: '/svg/tweet-ic.svg', href: process.env.NEXT_PUBLIC_TWITTER_URL },
  { platform: 'Instagram', icon: '/svg/insta-ic.svg', href: process.env.NEXT_PUBLIC_INSTAGRAM_URL },
  { platform: 'Google', icon: '/svg/google-ic.svg', href: process.env.NEXT_PUBLIC_GOOGLE_URL },
] as const;
  1. Replace the repetitive code:
- <div className="flex items-center gap-x-3">
-   <Link href="/">
-     <Image
-       src="/svg/fb-ic.svg"
-       alt="Facebook icon"
-       width={25}
-       height={25}
-       className="cursor-pointer"
-     />
-   </Link>
-   // ... repeated code for other platforms
- </div>
+ <div className="flex items-center gap-x-3">
+   {SOCIAL_MEDIA.map(({ platform, icon, href }) => (
+     <Link key={platform} href={href ?? '/'} target="_blank" rel="noopener noreferrer">
+       <Image
+         src={icon}
+         alt={`${platform} icon`}
+         width={25}
+         height={25}
+         className="cursor-pointer"
+       />
+     </Link>
+   ))}
+ </div>

</div>
<div className="flex justify-center pb-16">
Copyright ©{new Date().getFullYear()} Wecooked
</div>
</div>
)
}
Comment on lines +4 to +79
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve accessibility and semantic HTML structure

The component needs improvements for better accessibility support.

  1. Add proper ARIA labels and roles:
- <div className="relative bg-white">
+ <footer role="contentinfo" aria-label="Site footer" className="relative bg-white">

// Update navigation
- <div className="flex gap-x-6">
+ <nav aria-label="Footer navigation" className="flex gap-x-6">

// Update social media section
- <div className="flex items-center gap-x-3">
+ <div className="flex items-center gap-x-3" aria-label="Social media links">
  1. Add keyboard focus styles:
// Add to social media links
className="cursor-pointer focus:ring-2 focus:ring-offset-2 focus:ring-[#FE3511] focus:outline-none"

Committable suggestion skipped: line range outside the PR's diff.

3 changes: 1 addition & 2 deletions app/chef/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import NavLink from './NavLink'
import { useRouter } from 'next/navigation'
import { useAuthContext } from '@/app/contexts/authcontext'


/**
* Custom hook to manage authentication state in localStorage.
* Wrapped in useEffect to prevent SSR issues with Netlify.
Expand Down Expand Up @@ -90,7 +89,7 @@ export default function Navbar() {
aria-orientation="vertical"
>
<Link
href="/client/profile"
href="/chef/profile"
className="block px-4 py-2 hover:bg-gray-100"
role="menuitem"
>
Expand Down
40 changes: 40 additions & 0 deletions app/chef/components/course/CourseUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,46 @@ export default function CourseUpload() {
setIsSubmitting(true)
setSubmitError(null)

const courseUploadData = [
{
courseTitle: 'Masterbate British Cuisine',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct the typo in courseTitle

The courseTitle contains a typo: 'Masterbate British Cuisine' should be corrected to 'Master British Cuisine'.

Apply this diff to fix the typo:

-        courseTitle: 'Masterbate British Cuisine',
+        courseTitle: 'Master British Cuisine',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
courseTitle: 'Masterbate British Cuisine',
courseTitle: 'Master British Cuisine',

courseDetail:
'Learn the secrets of British cuisine from Gordon Ramsay.',
coursePrice: 100,
courseCategory: 'Cooking',
courseVideoId: 1,
courseChefId: 1,
coursePackId: 'pack1',
courseVideoPath: 'test12345678.com',
courseIngredientPrice: 123456,
courseIngredientDetail: 'Pork,Pork,Pork,Pork',
courseImage: 'placeholderImage.com',
},
]
try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_BACKEND_URL}/chef/upload`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(courseUploadData),
}
)

if (response.ok) {
const responseData = await response.json()
console.log('Upload successful:', responseData)
} else {
const errorDetails = await response.json() // Optional: read error response
console.error('Failed to upload:', response.status, errorDetails)
}
} catch (error) {
console.error('Error submitting the form:', error)
}

Comment on lines +100 to +138
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refactor duplicate submission logic

There is duplicate submission logic in the handleSubmit function. Currently, you are sending courseUploadData to the backend and then calling mockSubmitToAPI with courseData. This can lead to inconsistent data submissions and unnecessary complexity.

Consider refactoring the code to use the form data (courseData) for the backend submission and remove the redundant courseUploadData. Here's how you can modify your code:

-    const courseUploadData = [
-      {
-        courseTitle: 'Master British Cuisine',
-        courseDetail:
-          'Learn the secrets of British cuisine from Gordon Ramsay.',
-        coursePrice: 100,
-        courseCategory: 'Cooking',
-        courseVideoId: 1,
-        courseChefId: 1,
-        coursePackId: 'pack1',
-        courseVideoPath: 'test12345678.com',
-        courseIngredientPrice: 123456,
-        courseIngredientDetail: 'Pork,Pork,Pork,Pork',
-        courseImage: 'placeholderImage.com',
-      },
-    ]
     try {
+      const courseData: CourseSubmission = {
+        courseName,
+        courseDetail,
+        courseCategory,
+        courseDietary,
+        coursePrice,
+        coursePackPrice,
+        courseIngredients,
+        videoUrl,
+        coverImageUrl,
+        bookmarks: bookmarks.map((b) => ({
+          title: b.title,
+          time: b.time,
+          timeStop: b.timeStop,
+          timeCountdown: b.timeCountdown,
+        })),
+      }
+
       const response = await fetch(
         `${process.env.NEXT_PUBLIC_BACKEND_URL}/chef/upload`,
         {
           method: 'POST',
           headers: {
             'Content-Type': 'application/json',
           },
-          body: JSON.stringify(courseUploadData),
+          body: JSON.stringify(courseData),
         }
       )

       if (response.ok) {
         const responseData = await response.json()
         console.log('Upload successful:', responseData)
+        setSubmitSuccess(true)
+        resetForm()
       } else {
         const errorDetails = await response.json() // Optional: read error response
         console.error('Failed to upload:', response.status, errorDetails)
       }
     } catch (error) {
       console.error('Error submitting the form:', error)
+      setSubmitError(error instanceof Error ? error.message : 'Unknown error')
     } finally {
       setIsSubmitting(false)
     }

-    try {
-      const response = await mockSubmitToAPI(courseData)
-      if (response.success) {
-        setSubmitSuccess(true)
-        // Reset form or navigate away
-        resetForm()
-      } else {
-        throw new Error(response.message || 'Course submission failed')
-      }
-    } catch (error) {
-      setSubmitError(error instanceof Error ? error.message : 'Unknown error')
-    } finally {
-      setIsSubmitting(false)
-    }

Committable suggestion skipped: line range outside the PR's diff.


try {
const courseData: CourseSubmission = {
courseName,
Expand Down
45 changes: 38 additions & 7 deletions app/chef/components/login&forget-password/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AuthContext, useAuthContext } from '@/app/contexts/authcontext'
import { useForm } from 'react-hook-form'
import { z } from 'zod'
import { zodResolver } from '@hookform/resolvers/zod'
import Cookies from 'js-cookie'

// Define the validation schema
const loginSchema = z.object({
Expand Down Expand Up @@ -56,19 +57,49 @@ export default function Login() {
const login = () => {
setIsAuthenticated(true)
router.push('/chef/course')
if (remember == true && typeof window !== 'undefined') {
// Access localStorage here (to prevent netlify approvement fail)
localStorage.setItem('isAuthenticated', 'true')
if (remember) {
// Store authentication state in cookies
Cookies.set('Authorization', 'true', { expires: 7 }) // expires in 7 days if "Remember me" is checked
} else {

}
}

const togglePasswordVisibility = () => setShowPassword((prev) => !prev)
const toggleRemember = () => setRemember((prev) => !prev)

// Update handleFormSubmit to handle form data
const handleFormSubmit = (data: LoginFormData) => {
console.log(JSON.stringify(data)) // Placeholder for auth logic
login() //set login state to true
const handleFormSubmit = async (data: LoginFormData) => {

const chefLoginData = [{
chefEmail: data.email,
chefPassword: data.password,
}]
Comment on lines +74 to +77
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix incorrect API request payload structure

The chefLoginData is incorrectly structured as an array with a single object, which may not match the API's expectations.

Modify the data structure:

- const chefLoginData = [{
+ const chefLoginData = {
    chefEmail: data.email,
    chefPassword: data.password,
- }]
+ }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const chefLoginData = [{
chefEmail: data.email,
chefPassword: data.password,
}]
const chefLoginData = {
chefEmail: data.email,
chefPassword: data.password,
}


try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_BACKEND_URL}/chef/login`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(chefLoginData),
}
)

if (!response.ok) {
throw new Error('Login failed')
}

const responseData = await response.json()
console.log('token received:', responseData.token)
Cookies.set('Authorization', responseData.token)

login() // Redirect to the home page
} catch (error) {
console.error('Login failed:', error)
}
}

return (
Expand Down Expand Up @@ -184,7 +215,7 @@ export default function Login() {
<div className="flex justify-center mt-6 gap-x-1 text-sm">
<p>Don&apos;t have an account?</p>
<Link
href="/client/sign-up"
href="/chef/sign-up-chef"
className="cursor-pointer text-transparent bg-clip-text bg-gradient-to-t from-[#FE3511] to-[#F0725C] hover:underline font-medium"
>
Sign up now
Expand Down
Loading