-
Notifications
You must be signed in to change notification settings - Fork 2
Demo beetle #17
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
base: main
Are you sure you want to change the base?
Demo beetle #17
Changes from all commits
ee60dfc
92a981e
3fd0fae
ec9a2ad
7723b53
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 | ||
|---|---|---|---|---|
|
|
@@ -6,7 +6,6 @@ interface JobsResponse { | |||
| } | ||||
|
|
||||
| export const fetchJobs = async (chatdata: any) => { | ||||
| console.log("Sending API request with data:", chatdata); | ||||
| const token = await getCookie("token"); | ||||
|
|
||||
| try { | ||||
|
|
@@ -35,4 +34,93 @@ export const fetchJobs = async (chatdata: any) => { | |||
| console.error("Error fetching jobs:", error) | ||||
| throw error; // Re-throw to handle in the component | ||||
| } | ||||
| } | ||||
|
|
||||
| export const deleteById = async (path: string) => { | ||||
| const token = await getCookie("token"); | ||||
|
|
||||
| try { | ||||
| const response = await fetch( | ||||
| `${process.env.NEXT_PUBLIC_API_BASE_URL}${path}`, | ||||
| { | ||||
| method: "DELETE", | ||||
| headers: { | ||||
| "Content-Type": "application/json", | ||||
| Cookie: `token=${token}`, | ||||
| }, | ||||
| credentials: "include", | ||||
| } | ||||
| ); | ||||
|
|
||||
| if (!response.ok) { | ||||
| throw new Error(`API request failed with status ${response.status}`); | ||||
| } | ||||
|
|
||||
| const data = await response.json(); | ||||
| return data; | ||||
| } catch (error) { | ||||
| console.error("Error deleting resource:", error); | ||||
| throw error; | ||||
| } | ||||
| } | ||||
|
|
||||
| export const renameChatById = async (chatId: string, newName: string) => { | ||||
| const token = await getCookie("token"); | ||||
|
|
||||
| try { | ||||
| const response = await fetch( | ||||
| `${process.env.NEXT_PUBLIC_API_BASE_URL}/api/chat/rename?id=${chatId}`, | ||||
| { | ||||
| method: "PUT", | ||||
| headers: { | ||||
| "Content-Type": "application/json", | ||||
| }, | ||||
|
|
||||
| credentials: "include", | ||||
| body: JSON.stringify({ | ||||
| name: newName, | ||||
| }), | ||||
| } | ||||
| ); | ||||
|
|
||||
| if (!response.ok) { | ||||
| throw new Error(`API request failed with status ${response.status}`); | ||||
| } | ||||
|
|
||||
| const data = await response.json(); | ||||
| console.log("Chat renamed successfully:", data); | ||||
|
||||
| console.log("Chat renamed successfully:", data); |
Copilot
AI
Jan 2, 2026
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.
Debug console.log statement should be removed before merging to production. This log provides minimal value and clutters the console output.
| console.log("Chats fetched successfully:", data); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,8 +3,7 @@ import Image from 'next/image'; | |||||||||||||||||||||
| import { FaPaperclip, FaUpload, FaGlobe, FaTwitter, FaLinkedin, FaGithub } from 'react-icons/fa'; | ||||||||||||||||||||||
| import { useGoogleLogin } from '@react-oauth/google'; | ||||||||||||||||||||||
| import { useAppDispatch } from '@/redux/hooks'; | ||||||||||||||||||||||
| import axios from 'axios'; | ||||||||||||||||||||||
| import { userData } from '@/redux/slices/userSlice'; | ||||||||||||||||||||||
| import GlowButton from '@/components/ui/glowButton'; | ||||||||||||||||||||||
| import toast from 'react-hot-toast'; | ||||||||||||||||||||||
| import { Loader2, SparklesIcon } from 'lucide-react'; | ||||||||||||||||||||||
| import JobSearchResults from './job-result'; | ||||||||||||||||||||||
|
|
@@ -28,6 +27,13 @@ const HeroSection = ({ isLoggedIn }: { isLoggedIn: boolean }) => { | |||||||||||||||||||||
| const [showResumePopup, setShowResumePopup] = useState(false); // New state for resume popup | ||||||||||||||||||||||
| const [jobApiData, setJobApiData] = useState<any>(null) | ||||||||||||||||||||||
| const [isApiLoading, setIsApiLoading] = useState(false) | ||||||||||||||||||||||
| const buttonItems = [ | ||||||||||||||||||||||
| { text: 'NEW', secondaryText: 'Build a mobile app with Expo', icon: null }, | ||||||||||||||||||||||
| { text: 'Recharts dashboard', secondaryText: null, icon: null }, | ||||||||||||||||||||||
| { text: 'Habit tracker', secondaryText: null, icon: null }, | ||||||||||||||||||||||
| { text: 'Real estate listings', secondaryText: null, icon: null }, | ||||||||||||||||||||||
| { text: 'Developer portfolio', secondaryText: null, icon: null } | ||||||||||||||||||||||
|
Comment on lines
+31
to
+35
|
||||||||||||||||||||||
| { text: 'NEW', secondaryText: 'Build a mobile app with Expo', icon: null }, | |
| { text: 'Recharts dashboard', secondaryText: null, icon: null }, | |
| { text: 'Habit tracker', secondaryText: null, icon: null }, | |
| { text: 'Real estate listings', secondaryText: null, icon: null }, | |
| { text: 'Developer portfolio', secondaryText: null, icon: null } | |
| { text: 'NEW' }, | |
| { text: 'Recharts dashboard' }, | |
| { text: 'Habit tracker' }, | |
| { text: 'Real estate listings' }, | |
| { text: 'Developer portfolio' } |
Copilot
AI
Jan 2, 2026
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.
The buttonItems array is defined inside the component body, causing it to be recreated on every render. Since this is static data, it should be moved outside the component to prevent unnecessary re-renders and improve performance.
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.
The function may incorrectly throw an error on a successful deletion. A
DELETErequest can successfully complete with a204 No Contentstatus code, which means the response body will be empty. Attempting to callresponse.json()on an empty body will cause a JSON parsing error, making the function throw even though the operation succeeded on the backend.Confidence: 5/5
Suggested Fix
To fix this, check if the response status is
204. If it is, you can returnnullor another indicator of success, avoiding the attempt to parse a non-existent JSON body. This ensures that successful deletions are handled correctly.Prompt for AI
Copy this prompt to your AI IDE to fix this issue locally:
📍 This suggestion applies to lines 59-60