Skip to content

Commit 14174a2

Browse files
authored
Merge branch 'devhub-ai:main' into Updated-Chat-UI
2 parents d83b1d2 + e4b820c commit 14174a2

File tree

10 files changed

+114
-124
lines changed

10 files changed

+114
-124
lines changed

.github/workflows/main_devhub-server.yml

Lines changed: 0 additions & 81 deletions
This file was deleted.

client/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

client/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Use an official node image as the base image
2+
FROM node:16-alpine
3+
4+
# Set the working directory
5+
WORKDIR /app
6+
7+
# Copy package.json and package-lock.json
8+
COPY package*.json ./
9+
10+
# Install dependencies
11+
RUN npm install
12+
13+
# Copy the rest of the application code
14+
COPY . .
15+
16+
# Set environment variable
17+
ENV VITE_BACKEND_URL=https://devhub-server-original.onrender.com
18+
19+
# Build the application
20+
RUN npm run build
21+
22+
# Expose the port the app runs on
23+
EXPOSE 3000
24+
25+
# Start the application
26+
CMD ["npm", "run", "serve"]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
declare module "@/components/MultiSelect/TagInput" {
2+
import { FC } from "react";
3+
4+
interface Tag {
5+
value: string;
6+
label: string;
7+
}
8+
9+
interface TagInputProps {
10+
selectedTags: Tag[];
11+
onTagsChange: (tags: Tag[]) => void;
12+
}
13+
14+
const TagInput: FC<TagInputProps>;
15+
export type { Tag }; // Export the Tag type
16+
export default TagInput;
17+
}

client/src/components/ui/sidebar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use client";
22
import { cn } from "@/lib/utils";
3-
import { Link, LinkProps } from 'react-router-dom';
43
import React, { useState, createContext, useContext } from "react";
54
import { AnimatePresence, motion } from "framer-motion";
65
import { IconMenu2, IconX } from "@tabler/icons-react";

client/src/lib/userSlice.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const userSlice = createSlice({
1616
name: 'user',
1717
initialState,
1818
reducers: {
19+
setUser: (state, action: PayloadAction<UserState>) => {
20+
return { ...state, ...action.payload };
21+
},
1922
setUsername(state, action: PayloadAction<string | null>) {
2023
state.username = action.payload;
2124
},
@@ -28,5 +31,6 @@ const userSlice = createSlice({
2831
},
2932
});
3033

31-
export const { setUsername, setFriends, setFriendStatus } = userSlice.actions;
34+
export const { setUser, setUsername, setFriends, setFriendStatus } = userSlice.actions;
3235
export default userSlice.reducer;
36+
export type { UserState };

client/src/pages/EditForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function ProfileForm() {
7474
control: form.control,
7575
})
7676

77-
function onSubmit(data: ProfileFormValues) {
77+
function onSubmit() {
7878
toast.success("Signup successful", {
7979
description: "You can now log in with your new account."
8080

client/src/pages/EditProfileForm.tsx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ import { toast } from "sonner";
99

1010
const backendUrl = import.meta.env.VITE_BACKEND_URL || 'http://localhost:5000';
1111

12+
interface Tag {
13+
value: string;
14+
label: string;
15+
}
16+
1217
interface Project {
1318
id?: number;
1419
title: string;
1520
description: string;
1621
repoLink: string;
17-
tags: string[];
22+
tags: Tag[];
1823
}
1924

2025

@@ -76,10 +81,15 @@ const EditProfileForm: React.FC<EditProfileFormProps> = ({ onProjectAdded }) =>
7681
const handleProjectChange = (e: React.ChangeEvent<HTMLInputElement>) => {
7782
const { name, value } = e.target;
7883
if (selectedProject) {
79-
setSelectedProject((prevProject: Project) => ({
80-
...prevProject,
81-
[name]: value,
82-
}));
84+
setSelectedProject((prevProject: Project | null) => {
85+
if (prevProject) {
86+
return {
87+
...prevProject,
88+
[name]: value,
89+
};
90+
}
91+
return null; // or return a default Project object if you prefer
92+
});
8393
} else {
8494
setNewProject((prevProject: Project) => ({
8595
...prevProject,
@@ -110,15 +120,14 @@ const EditProfileForm: React.FC<EditProfileFormProps> = ({ onProjectAdded }) =>
110120
const handleAddProject = async () => {
111121
try {
112122
console.log("Tags:", newProject.tags);
113-
const tagsString = newProject.tags.map(tag => tag.value).join(",");
114-
123+
const tagsArray = newProject.tags.map(tag => ({ value: tag, label: tag })); // Convert Tag objects to strings
115124

116-
console.log("Adding project:", tagsString);
125+
console.log("Adding project:", tagsArray);
117126
const response = await axios.post(`${backendUrl}/profile/${username}/projects`, {
118127
title: newProject.title,
119128
description: newProject.description,
120129
repo_link: newProject.repoLink,
121-
tags: tagsString,
130+
tags: tagsArray, // Use the formatted tagsArray
122131
}, { withCredentials: true });
123132
if(response.status === 200)
124133
// console.log("Project added successfully:", );
@@ -356,8 +365,8 @@ const EditProfileForm: React.FC<EditProfileFormProps> = ({ onProjectAdded }) =>
356365
<div>
357366
<Label>Project Tags</Label>
358367
<TagInput
359-
selectedTags={newProject.tags}
360-
onTagsChange={(tags: string[]) => setNewProject({ ...newProject, tags })}
368+
selectedTags={newProject.tags} // This should be an array of Tag objects
369+
onTagsChange={(tags: Tag[]) => setNewProject({ ...newProject, tags })} // Ensure tags are of type Tag[]
361370
/>
362371

363372
</div>

client/src/pages/Profile.tsx

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,21 @@ interface ProfileProps {
1818
username: string;
1919
}
2020

21+
export interface Tag {
22+
value: string;
23+
label: string;
24+
}
25+
2126
interface Project {
2227
description: string;
2328
repoLink: string;
24-
tags: string;
29+
tags: Tag[];
2530
title: string;
31+
repo?: string;
32+
link?: string;
33+
language?: string;
34+
stars?: number;
35+
forks?: number;
2636
}
2737

2838
interface UserResponse {
@@ -50,28 +60,28 @@ interface Language {
5060
percentage: string;
5161
}
5262

53-
interface LeetCodeData {
54-
totalSolved: number;
55-
totalSubmissions: number;
56-
totalQuestions: number;
57-
easySolved: number;
58-
totalEasy: number;
59-
mediumSolved: number;
60-
totalMedium: number;
61-
hardSolved: number;
62-
totalHard: number;
63-
ranking: number;
64-
contributionPoint: number;
65-
reputation: number;
66-
submissionCalendar: string;
67-
recentSubmissions: {
68-
title: string;
69-
titleSlug: string;
70-
timestamp: string;
71-
statusDisplay: string;
72-
lang: string;
73-
}[];
74-
}
63+
// interface LeetCodeData {
64+
// totalSolved: number;
65+
// totalSubmissions: number;
66+
// totalQuestions: number;
67+
// easySolved: number;
68+
// totalEasy: number;
69+
// mediumSolved: number;
70+
// totalMedium: number;
71+
// hardSolved: number;
72+
// totalHard: number;
73+
// ranking: number;
74+
// contributionPoint: number;
75+
// reputation: number;
76+
// submissionCalendar: string;
77+
// recentSubmissions: {
78+
// title: string;
79+
// titleSlug: string;
80+
// timestamp: string;
81+
// statusDisplay: string;
82+
// lang: string;
83+
// }[];
84+
// }
7585

7686
const Profile: React.FC<ProfileProps> = ({ onLogout, username }) => {
7787
return (
@@ -94,16 +104,15 @@ const Dashboard: React.FC<DashboardProps> = ({ loggedInUsername }) => {
94104
const { username } = useParams<{ username: string }>();
95105
const dispatch = useDispatch<AppDispatch>();
96106
const friends = useSelector((state: RootState) => state.user.friends);
97-
const friendStatus = useSelector(
98-
(state: RootState) => state.user.friendStatus
99-
);
107+
// const friendStatus = useSelector(
108+
// (state: RootState) => state.user.friendStatus
109+
// );
100110
const [profileData, setProfileData] = useState<UserResponse>();
101111
const [editing, setEditing] = useState(false);
102112
const [githubData, setGithubData] = useState<GitHubData | null>(null);
103113
const [languages, setLanguages] = useState<Language[]>([]);
104114
const [streakStats, setStreakStats] = useState<string | null>(null);
105115
const [pinnedRepos, setPinnedRepos] = useState<Project[]>([]);
106-
const [leetcodeData, setLeetcodeData] = useState<LeetCodeData | null>(null);
107116
const [leetcodeSvg, setLeetcodeSvg] = useState(null);
108117
const [githubStreakSvg, setGithubStreakSvg] = useState(null);
109118

@@ -248,13 +257,13 @@ const Dashboard: React.FC<DashboardProps> = ({ loggedInUsername }) => {
248257
data: { friend_username: loggedInUsername },
249258
});
250259
setProfileData((prev) => (prev ? { ...prev, isFriend: false } : prev));
251-
dispatch(setFriendStatus(false)); // Update Redux state
260+
dispatch(setFriendStatus({ username: loggedInUsername, isFriend: false })); // Updated to pass an object
252261
} else {
253262
await axios.post(`${backendUrl}/profile/${username}/friends`, {
254263
friend_username: loggedInUsername,
255264
});
256265
setProfileData((prev) => (prev ? { ...prev, isFriend: true } : prev));
257-
dispatch(setFriendStatus(true)); // Update Redux state
266+
dispatch(setFriendStatus({ username: loggedInUsername, isFriend: true })); // Updated to pass an object
258267
}
259268
} catch (error) {
260269
console.error("Failed to update friend status:", error);

client/vercel.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rewrites": [
3+
{"source": "/:a*", "destination": "/"}
4+
]
5+
}

0 commit comments

Comments
 (0)