Skip to content

Commit b0b3338

Browse files
committed
fix: updated production issues
1 parent 9ef35b5 commit b0b3338

File tree

5 files changed

+49
-14
lines changed

5 files changed

+49
-14
lines changed
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/MultiSelect/TagInput.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const TAGS = [
2222
{ value: "fintech", label: "Fintech" },
2323
];
2424

25-
export function TagInput({ selectedTags, onTagsChange }) {
25+
export default function TagInput({ selectedTags, onTagsChange }) {
2626
const inputRef = React.useRef(null);
2727
const [open, setOpen] = React.useState(false);
2828
const [inputValue, setInputValue] = React.useState("");

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/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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ 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;
2631
repo?: string;
2732
link?: string;

0 commit comments

Comments
 (0)