-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Api connection #26
base: main
Are you sure you want to change the base?
Api connection #26
Changes from all commits
5c774d2
cf29ee7
e91b52f
fa8c47f
5225ca9
932c689
4163eb1
9c7bb36
1edac71
793dfb8
7ac27e7
4029ac8
4fbda0f
5b4ea10
1227111
712ee19
8337e60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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() { | ||
const footer_elements = [ | ||
'About', | ||
'Terms & conditions', | ||
'Privacy Policy', | ||
'Contact', | ||
] | ||
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> | ||
Comment on lines
+36
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add proper social media links and aria-labels The social media links currently point to "/" which is not ideal for production. Also, add aria-labels for better accessibility. -<Link href="/">
+<Link
+ href="https://facebook.com/wecooked"
+ target="_blank"
+ rel="noopener noreferrer"
+ aria-label="Visit WeCooked Facebook page">
<Image
src="/svg/fb-ic.svg"
alt="Facebook icon"
width={25}
height={25}
className="cursor-pointer"
/>
</Link> (Apply similar changes to other social media links)
|
||
</div> | ||
</div> | ||
<div className="flex justify-center pb-16"> | ||
Copyright ©{new Date().getFullYear()} Wecooked | ||
</div> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,46 @@ export default function CourseUpload() { | |
setIsSubmitting(true) | ||
setSubmitError(null) | ||
|
||
const courseUploadData = [ | ||
{ | ||
courseTitle: 'Masterbate British Cuisine', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typographical error in There's a typo in |
||
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', | ||
}, | ||
] | ||
Comment on lines
+100
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace hardcoded Currently, Apply this diff to construct const courseUploadData = [
{
- courseTitle: 'Masterbate British Cuisine',
+ courseTitle: courseName,
- courseDetail: 'Learn the secrets of British cuisine from Gordon Ramsay.',
+ courseDetail: courseDetail,
- coursePrice: 100,
+ coursePrice: coursePrice,
- courseCategory: 'Cooking',
+ courseCategory: courseCategory,
- courseVideoId: 1,
+ courseVideoId: /* assign appropriate video ID */,
- courseChefId: 1,
+ courseChefId: /* assign appropriate chef ID */,
- coursePackId: 'pack1',
+ coursePackId: /* assign appropriate pack ID */,
- courseVideoPath: 'test12345678.com',
+ courseVideoPath: videoUrl,
- courseIngredientPrice: 123456,
+ courseIngredientPrice: /* calculate ingredient price if applicable */,
- courseIngredientDetail: 'Pork,Pork,Pork,Pork',
+ courseIngredientDetail: courseIngredients,
- courseImage: 'placeholderImage.com',
+ courseImage: coverImageUrl,
},
] Please replace the placeholders with the appropriate variables or calculations.
|
||
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) | ||
} | ||
|
||
|
||
try { | ||
const courseData: CourseSubmission = { | ||
courseName, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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({ | ||
|
@@ -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 { | ||
|
||
Comment on lines
+60
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enhance cookie security settings The cookie settings need security improvements:
Update cookie settings: -Cookies.set('Authorization', 'true', { expires: 7 })
+Cookies.set('Authorization', 'true', {
+ expires: 7,
+ secure: true,
+ sameSite: 'strict',
+ httpOnly: true
+})
|
||
} | ||
} | ||
|
||
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, | ||
}] | ||
|
||
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) | ||
} | ||
Comment on lines
+72
to
+102
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve error handling and user feedback The login error handling needs improvement:
Example implementation: try {
+ setIsLoading(true)
const response = await fetch(...)
if (!response.ok) {
- throw new Error('Login failed')
+ const errorData = await response.json()
+ throw new Error(errorData.message || 'Login failed')
}
// ... rest of the code
} catch (error) {
- console.error('Login failed:', error)
+ setError(error.message)
+ // Show error message to user
} finally {
+ setIsLoading(false)
}
|
||
} | ||
|
||
return ( | ||
|
@@ -184,7 +215,7 @@ export default function Login() { | |
<div className="flex justify-center mt-6 gap-x-1 text-sm"> | ||
<p>Don'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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace
ul
withli
elements for proper semantic HTMLThe mapping of footer elements should use
li
elements within a parentul
, not individualul
elements for each item.📝 Committable suggestion