Skip to content

Commit

Permalink
feat: githublink validation in edit project (backend)
Browse files Browse the repository at this point in the history
  • Loading branch information
yp969803 committed May 19, 2024
1 parent 124c299 commit de8824f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ public ResponseEntity<?> updateProject(@Valid @RequestBody AddProjectRequest upd
return ResponseEntity.badRequest().body("User is not the admin or manager of the org");
}

Boolean isValidLink=githubService.isValidLink(addProjectRequest.getLink(),user.getAccesstoken());
if(!isValidLink){
return ResponseEntity.badRequest().body("Invalid link provided by the user");
}

project.setName(updateProjectRequest.getName());
project.setDescription(updateProjectRequest.getDescription());
project.setLink(updateProjectRequest.getLink());
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/features/AddProject/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const AddProject = () => {
const token = localStorage.getItem('token');
const { spaceName } = useParams();
const [orgProject, setOrgProjects] = useState<Projects | null>(null);

const isUnique = (name: string) => {
if (orgProject && name in orgProject) {
return false;
Expand Down Expand Up @@ -107,22 +106,20 @@ const AddProject = () => {
updatedForm.description = ' ';
}
const res = await addProject(token, spaceName, updatedForm);
// console.log(res);
// TODO: Update some stuff if the link is case sensitive
navigate(`/workspace/${spaceName}`);
};
toast.promise(func(), {
loading: 'Saving Project',
success: <b>Project saved</b>,
error: <b>Could not save</b>,
error: <b>Invalid link</b>,
});
} else {
toast.error('Invalid inputs');
}
} else {
toast.error('Form contains errors');
}
console.log('sanas');
};

const fetchData = async () => {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/features/AddWorkspace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const AddWorkspace = () => {
) {
setForm({ ...form, members: [...form.members, form.member] });
setForm({ ...form, member: '' });
console.log(form);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/EditProject/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const EditProject = () => {
toast.promise(func(), {
loading: 'Saving Project',
success: <b>Project saved</b>,
error: <b>Could not save</b>,
error: <b>Invalid link</b>,
});
} else {
toast.error('Invalid inputs');
Expand Down
1 change: 0 additions & 1 deletion frontend/src/features/workspace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ const Workspace = () => {
};

const fetchData = async () => {
console.log(userContext?.username);
if (token && userContext?.username) {
try {
const userOrgsRes = await getUserOrgs(
Expand Down

0 comments on commit de8824f

Please sign in to comment.