From 9ef35b5e6682da7685ffdc732461c6c47ec43307 Mon Sep 17 00:00:00 2001 From: Deepraj Date: Tue, 8 Oct 2024 21:32:59 +0530 Subject: [PATCH] fix: updating types and interface --- .../src/components/MultiSelect/TagInput.jsx | 2 +- client/src/components/ui/sidebar.tsx | 1 - client/src/pages/EditForm.tsx | 2 +- client/src/pages/Profile.tsx | 62 ++++++++++--------- 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/client/src/components/MultiSelect/TagInput.jsx b/client/src/components/MultiSelect/TagInput.jsx index 0a2f245..e9209cc 100644 --- a/client/src/components/MultiSelect/TagInput.jsx +++ b/client/src/components/MultiSelect/TagInput.jsx @@ -22,7 +22,7 @@ const TAGS = [ { value: "fintech", label: "Fintech" }, ]; -export default function TagInput({ selectedTags, onTagsChange }) { +export function TagInput({ selectedTags, onTagsChange }) { const inputRef = React.useRef(null); const [open, setOpen] = React.useState(false); const [inputValue, setInputValue] = React.useState(""); diff --git a/client/src/components/ui/sidebar.tsx b/client/src/components/ui/sidebar.tsx index 87ed308..34112e5 100644 --- a/client/src/components/ui/sidebar.tsx +++ b/client/src/components/ui/sidebar.tsx @@ -1,6 +1,5 @@ "use client"; import { cn } from "@/lib/utils"; -import { Link, LinkProps } from 'react-router-dom'; import React, { useState, createContext, useContext } from "react"; import { AnimatePresence, motion } from "framer-motion"; import { IconMenu2, IconX } from "@tabler/icons-react"; diff --git a/client/src/pages/EditForm.tsx b/client/src/pages/EditForm.tsx index 6618480..660b45d 100644 --- a/client/src/pages/EditForm.tsx +++ b/client/src/pages/EditForm.tsx @@ -74,7 +74,7 @@ export function ProfileForm() { control: form.control, }) - function onSubmit(data: ProfileFormValues) { + function onSubmit() { toast.success("Signup successful", { description: "You can now log in with your new account." diff --git a/client/src/pages/Profile.tsx b/client/src/pages/Profile.tsx index 685f85c..f2d9f5a 100644 --- a/client/src/pages/Profile.tsx +++ b/client/src/pages/Profile.tsx @@ -21,8 +21,13 @@ interface ProfileProps { interface Project { description: string; repoLink: string; - tags: string; + tags: string[]; title: string; + repo?: string; + link?: string; + language?: string; + stars?: number; + forks?: number; } interface UserResponse { @@ -50,28 +55,28 @@ interface Language { percentage: string; } -interface LeetCodeData { - totalSolved: number; - totalSubmissions: number; - totalQuestions: number; - easySolved: number; - totalEasy: number; - mediumSolved: number; - totalMedium: number; - hardSolved: number; - totalHard: number; - ranking: number; - contributionPoint: number; - reputation: number; - submissionCalendar: string; - recentSubmissions: { - title: string; - titleSlug: string; - timestamp: string; - statusDisplay: string; - lang: string; - }[]; -} +// interface LeetCodeData { +// totalSolved: number; +// totalSubmissions: number; +// totalQuestions: number; +// easySolved: number; +// totalEasy: number; +// mediumSolved: number; +// totalMedium: number; +// hardSolved: number; +// totalHard: number; +// ranking: number; +// contributionPoint: number; +// reputation: number; +// submissionCalendar: string; +// recentSubmissions: { +// title: string; +// titleSlug: string; +// timestamp: string; +// statusDisplay: string; +// lang: string; +// }[]; +// } const Profile: React.FC = ({ onLogout, username }) => { return ( @@ -94,16 +99,15 @@ const Dashboard: React.FC = ({ loggedInUsername }) => { const { username } = useParams<{ username: string }>(); const dispatch = useDispatch(); const friends = useSelector((state: RootState) => state.user.friends); - const friendStatus = useSelector( - (state: RootState) => state.user.friendStatus - ); + // const friendStatus = useSelector( + // (state: RootState) => state.user.friendStatus + // ); const [profileData, setProfileData] = useState(); const [editing, setEditing] = useState(false); const [githubData, setGithubData] = useState(null); const [languages, setLanguages] = useState([]); const [streakStats, setStreakStats] = useState(null); const [pinnedRepos, setPinnedRepos] = useState([]); - const [leetcodeData, setLeetcodeData] = useState(null); const [leetcodeSvg, setLeetcodeSvg] = useState(null); const [githubStreakSvg, setGithubStreakSvg] = useState(null); @@ -248,13 +252,13 @@ const Dashboard: React.FC = ({ loggedInUsername }) => { data: { friend_username: loggedInUsername }, }); setProfileData((prev) => (prev ? { ...prev, isFriend: false } : prev)); - dispatch(setFriendStatus(false)); // Update Redux state + dispatch(setFriendStatus({ username: loggedInUsername, isFriend: false })); // Updated to pass an object } else { await axios.post(`${backendUrl}/profile/${username}/friends`, { friend_username: loggedInUsername, }); setProfileData((prev) => (prev ? { ...prev, isFriend: true } : prev)); - dispatch(setFriendStatus(true)); // Update Redux state + dispatch(setFriendStatus({ username: loggedInUsername, isFriend: true })); // Updated to pass an object } } catch (error) { console.error("Failed to update friend status:", error);