Skip to content

Commit 23732be

Browse files
Merge pull request #23 from Roberto-Teigeiro/bork
Bork
2 parents bc4c924 + 47cefaa commit 23732be

27 files changed

Lines changed: 2037 additions & 716 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ backend/.classpath
2222
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2323
hs_err_pid*
2424
*~
25-
25+
MtdrSpring/backend/api-service/src/main/java/com/springboot/TaskO/config/OracleConfiguration.java
2626
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2727

2828
# dependencies

MtdrSpring/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
**/node_modules/**
22
**/build/**
33
**/dist/**
4-
**/target/**
4+
**/target/**
5+
backend/api-service/src/main/java/com/springboot/TaskO/config/OracleConfiguration.java

MtdrSpring/backend/api-service/src/main/java/com/springboot/TaskO/config/OracleConfiguration.java

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

MtdrSpring/backend/api-service/src/main/java/com/springboot/TaskO/controller/ProjectMemberItemController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public ResponseEntity<List<ProjectMemberItem>> getProjectMembers(@PathVariable U
4646
}
4747

4848

49-
@GetMapping("/")
49+
5050

5151
@PostMapping(value = "/project/{projectId}/adduser/{teamId}")
5252
public ResponseEntity<ProjectMemberItem> addUserToProject(@RequestBody Map<String, String> payload, @PathVariable UUID projectId, @PathVariable UUID teamId) {

MtdrSpring/backend/api-service/src/main/java/com/springboot/TaskO/controller/TeamController.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import java.net.URI;
1212
import java.util.List;
13-
13+
import java.util.UUID;
1414

1515
@RestController
1616
public class TeamController {
@@ -21,11 +21,19 @@ public class TeamController {
2121
public List<TeamItem> getAllToDoItems(){
2222
return teamItemService.findAll();
2323
}
24-
@PostMapping("/team/add")
25-
public ResponseEntity<TeamItem> postMethodName(@RequestBody TeamItem teamItem) {
26-
TeamItem savedTeam = teamItemService.addTeamItem(teamItem);
27-
return ResponseEntity.ok(savedTeam);
24+
@GetMapping(value = "/team/{projectId}")
25+
public ResponseEntity<List<TeamItem>> getTeamByProjectId(@PathVariable UUID projectId) {
26+
List<TeamItem> teamItems = teamItemService.getTeamByProjectId(projectId);
27+
if (teamItems.isEmpty()) {
28+
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
29+
}
30+
return new ResponseEntity<>(teamItems, HttpStatus.OK);
2831
}
32+
@PostMapping("/team/add")
33+
public ResponseEntity<TeamItem> postMethodName(@RequestBody TeamItem teamItem) {
34+
TeamItem savedTeam = teamItemService.addTeamItem(teamItem);
35+
return ResponseEntity.ok(savedTeam);
36+
}
2937

3038

3139

MtdrSpring/backend/api-service/src/main/java/com/springboot/TaskO/controller/UserItemController.java

Lines changed: 70 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,32 @@
55
import com.springboot.TaskO.service.UserItemService;
66

77
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.http.HttpEntity;
89
import org.springframework.http.HttpHeaders;
10+
import org.springframework.http.HttpMethod;
911
import org.springframework.http.HttpStatus;
1012
import org.springframework.http.ResponseEntity;
1113
import org.springframework.web.bind.annotation.*;
14+
import org.springframework.web.client.RestTemplate;
1215

16+
import com.fasterxml.jackson.databind.JsonNode;
17+
import com.fasterxml.jackson.databind.ObjectMapper;
1318

1419
import java.net.URI;
20+
import java.util.HashMap;
1521
import java.util.List;
1622
import java.util.Map;
1723

24+
1825
@RestController
1926
public class UserItemController {
2027
@Autowired
2128
private UserItemService userItemService;
2229
//@CrossOrigin
30+
private final RestTemplate restTemplate = new RestTemplate();
31+
private final ObjectMapper objectMapper = new ObjectMapper();
32+
private final String clerkSecretKey = "sk_test_6Ib6VO3fmCDHpSNC2eJUXgkO9DrE70NusLvT7NmWFI";
33+
2334
@GetMapping(value = "/users/all")
2435
public List<UserItem> getAllToDoItems(){
2536
return userItemService.findAll();
@@ -80,31 +91,67 @@ public ResponseEntity<?> registerTelegramUser(@RequestBody Map<String, String> r
8091
.body("Error registrando usuario de telegram: " + e.getMessage());
8192
}
8293
}
83-
// @PostMapping("/users/register")
84-
// public ResponseEntity<?> registerTelegramUser(@RequestBody Map<String, String> registration) {
85-
// try {
86-
// String userId = registration.get("username");
87-
// String telegramId = registration.get("telegramId");
88-
89-
// if (userId == null || telegramId == null) {
90-
// return ResponseEntity.badRequest().body("Username and telegramId are required");
91-
// }
92-
93-
// // Add telegram to user and get the updated user
94-
// UserItem updatedUser = userItemService.addTelegramToUserItem(userId, telegramId);
94+
@PostMapping("/resolveusername")
95+
public ResponseEntity<Map<String, String>> resolveUsers(@RequestBody List<String> userIds) {
96+
try {
97+
Map<String, String> userNames = new HashMap<>();
9598

96-
// if (updatedUser == null) {
97-
// return ResponseEntity.status(HttpStatus.NOT_FOUND)
98-
// .body("User not found with username: " + userId);
99-
// }
99+
for (String userId : userIds) {
100+
try {
101+
// Hacer llamada HTTP directa a la API de Clerk
102+
String url = "https://api.clerk.com/v1/users/" + userId;
103+
104+
HttpHeaders headers = new HttpHeaders();
105+
headers.set("Authorization", "Bearer " + clerkSecretKey);
106+
headers.set("Content-Type", "application/json");
107+
108+
HttpEntity<String> entity = new HttpEntity<>(headers);
109+
110+
ResponseEntity<String> response = restTemplate.exchange(
111+
url, HttpMethod.GET, entity, String.class);
112+
113+
if (response.getStatusCode() == HttpStatus.OK) {
114+
JsonNode userJson = objectMapper.readTree(response.getBody());
115+
116+
String displayName = "";
117+
String firstName = userJson.path("first_name").asText(null);
118+
String lastName = userJson.path("last_name").asText(null);
119+
String username = userJson.path("username").asText(null);
120+
121+
if (firstName != null && !firstName.isEmpty() && lastName != null && !lastName.isEmpty()) {
122+
displayName = firstName + " " + lastName;
123+
} else if (username != null && !username.isEmpty()) {
124+
displayName = username;
125+
} else {
126+
JsonNode emailAddresses = userJson.path("email_addresses");
127+
if (emailAddresses.isArray() && emailAddresses.size() > 0) {
128+
String email = emailAddresses.get(0).path("email_address").asText();
129+
if (email != null && !email.isEmpty()) {
130+
displayName = email;
131+
} else {
132+
displayName = "User " + userId.replace("user_", "").substring(0, 8);
133+
}
134+
} else {
135+
displayName = "User " + userId.replace("user_", "").substring(0, 8);
136+
}
137+
}
138+
139+
userNames.put(userId, displayName);
140+
} else {
141+
userNames.put(userId, "User " + userId.replace("user_", "").substring(0, 8));
142+
}
143+
} catch (Exception e) {
144+
System.err.println("Error fetching user " + userId + ": " + e.getMessage());
145+
userNames.put(userId, "User " + userId.replace("user_", "").substring(0, 8));
146+
}
147+
}
100148

101-
// // Return the updated user
102-
// return ResponseEntity.ok(updatedUser);
103-
// } catch (Exception e) {
104-
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
105-
// .body("Error registering telegram user: " + e.getMessage());
106-
// }
107-
// }
149+
return ResponseEntity.ok(userNames);
150+
} catch (Exception e) {
151+
System.err.println("Error in resolveUsers: " + e.getMessage());
152+
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
153+
}
154+
}
108155
}
109156

110157

MtdrSpring/backend/api-service/src/main/java/com/springboot/TaskO/repository/TeamItemRepository.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
import org.springframework.stereotype.Repository;
66

77
import java.util.UUID;
8+
import java.util.List;
89

910
@Repository
1011
public interface TeamItemRepository extends JpaRepository<TeamItem, UUID> {
12+
// Method to find TeamItems by projectId
13+
List<TeamItem> findByProjectId(UUID projectId);
14+
1115
// Additional custom query methods can go here
1216
}

MtdrSpring/backend/api-service/src/main/java/com/springboot/TaskO/service/TeamItemService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public ResponseEntity<TeamItem> getTeamItemById(UUID id) {
2828
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
2929
}
3030
}
31+
public List<TeamItem> getTeamByProjectId(UUID projectId) {
32+
return teamItemRepository.findByProjectId(projectId);
33+
}
3134

3235
public TeamItem addTeamItem(TeamItem teamItem) {
3336
return teamItemRepository.save(teamItem);

MtdrSpring/backend/frontend-service/src/main/frontend/src/components/Header.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
import { useProjects } from "@/context/ProjectContext"
44
import oracleLogo from "../assets/oracleLogo.svg"
5+
56
interface HeaderProps {
67
title: string
8+
currentTeamName?: string
79
}
810

9-
export function Header({ title }: HeaderProps) {
11+
export function Header({ title, currentTeamName }: HeaderProps) {
1012
const { currentProject, loading } = useProjects()
1113

14+
// Determine href based on current path
15+
const href = window.location.pathname === "/choosepath" ? "/dashboard" : "/choosepath"
16+
1217
// Get current date and format it
1318
const currentDate = new Date()
1419
const day = currentDate.toLocaleDateString('en-US', { weekday: 'long' })
@@ -23,15 +28,24 @@ export function Header({ title }: HeaderProps) {
2328
<header className="bg-[#312D2A] py-4 px-8 flex items-center justify-between">
2429
<div className="flex items-center gap-8">
2530
<div className="flex items-center gap-4 ">
26-
<a href="/choosepath"><img src={oracleLogo} alt="logo" className="w-32 h-8" /></a>
31+
<a href={href}><img src={oracleLogo} alt="logo" className="w-32 h-8 hover:scale-110 transition-transform duration-300" /></a>
2732
<h1 className="text-3xl font-medium tracking-tight text-gray-200">
2833
<span>{title}</span>
2934
</h1>
3035
</div>
31-
<div className="text-sm text-gray-400 border-l border-gray-200 pl-6">
32-
Current Project: <span className="font-medium text-white">
33-
{loading ? "Loading..." : currentProject?.projectName || "No Project Selected"}
34-
</span>
36+
<div className="flex items-center gap-6">
37+
<div className="text-sm text-gray-400 border-l border-gray-200 pl-6">
38+
Current Project: <span className="font-medium text-white">
39+
{loading ? "Loading..." : currentProject?.projectName || "No Project Selected"}
40+
</span>
41+
</div>
42+
{currentTeamName && (
43+
<div className="text-sm text-gray-400 border-l border-gray-200 pl-6">
44+
Current Team: <span className="font-medium text-white">
45+
{currentTeamName}
46+
</span>
47+
</div>
48+
)}
3549
</div>
3650
</div>
3751

MtdrSpring/backend/frontend-service/src/main/frontend/src/components/Sidebar.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
import { useEffect, useState } from "react";
33
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
44
import { Button } from "@/components/ui/button";
5-
import { CircleDot, LayoutGrid, LogOut, Settings } from "lucide-react";
5+
import { Calendar, LayoutGrid, LogOut, Settings, Zap } from "lucide-react";
66
import { useNavigate, useLocation } from "react-router-dom";
77
import { useAuth, useUser } from "@clerk/clerk-react"; // Importar useAuth y useUser de Clerk
8+
import oracleLogo from "../assets/oracleLogo.svg";
89

910
export function Sidebar() {
1011
const navigate = useNavigate();
@@ -65,7 +66,7 @@ export function Sidebar() {
6566
<Avatar className="w-20 h-20 border-2 border-white shadow-lg">
6667
<AvatarImage
6768
src={
68-
userData.profilePicture || "/placeholder.svg?height=80&width=80"
69+
userData.profilePicture || oracleLogo
6970
}
7071
alt={`${userData.firstName} ${userData.lastName}`}
7172
/>
@@ -98,7 +99,7 @@ export function Sidebar() {
9899
location.pathname === "/sprints" ? "bg-white/20 font-medium" : ""
99100
}`}
100101
>
101-
<CircleDot className="mr-2 h-5 w-5" />
102+
<Zap className="mr-2 h-5 w-5" />
102103
Sprints
103104
</Button>
104105

@@ -109,7 +110,7 @@ export function Sidebar() {
109110
location.pathname === "/calendar" ? "bg-white/20 font-medium" : ""
110111
}`}
111112
>
112-
<CircleDot className="mr-2 h-5 w-5" />
113+
<Calendar className="mr-2 h-5 w-5" />
113114
Calendar
114115
</Button>
115116

0 commit comments

Comments
 (0)