Skip to content

Commit

Permalink
fix: updating types and interface
Browse files Browse the repository at this point in the history
  • Loading branch information
deepraj21 committed Oct 8, 2024
1 parent 91981a6 commit 9ef35b5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 32 deletions.
2 changes: 1 addition & 1 deletion client/src/components/MultiSelect/TagInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down
1 change: 0 additions & 1 deletion client/src/components/ui/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/EditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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."

Expand Down
62 changes: 33 additions & 29 deletions client/src/pages/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<ProfileProps> = ({ onLogout, username }) => {
return (
Expand All @@ -94,16 +99,15 @@ const Dashboard: React.FC<DashboardProps> = ({ loggedInUsername }) => {
const { username } = useParams<{ username: string }>();
const dispatch = useDispatch<AppDispatch>();
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<UserResponse>();
const [editing, setEditing] = useState(false);
const [githubData, setGithubData] = useState<GitHubData | null>(null);
const [languages, setLanguages] = useState<Language[]>([]);
const [streakStats, setStreakStats] = useState<string | null>(null);
const [pinnedRepos, setPinnedRepos] = useState<Project[]>([]);
const [leetcodeData, setLeetcodeData] = useState<LeetCodeData | null>(null);
const [leetcodeSvg, setLeetcodeSvg] = useState(null);
const [githubStreakSvg, setGithubStreakSvg] = useState(null);

Expand Down Expand Up @@ -248,13 +252,13 @@ const Dashboard: React.FC<DashboardProps> = ({ 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);
Expand Down

0 comments on commit 9ef35b5

Please sign in to comment.