Skip to content
Merged

Bork #23

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ backend/.classpath
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~

MtdrSpring/backend/api-service/src/main/java/com/springboot/TaskO/config/OracleConfiguration.java
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
Expand Down
3 changes: 2 additions & 1 deletion MtdrSpring/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/node_modules/**
**/build/**
**/dist/**
**/target/**
**/target/**
backend/api-service/src/main/java/com/springboot/TaskO/config/OracleConfiguration.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ResponseEntity<List<ProjectMemberItem>> getProjectMembers(@PathVariable U
}


@GetMapping("/")


@PostMapping(value = "/project/{projectId}/adduser/{teamId}")
public ResponseEntity<ProjectMemberItem> addUserToProject(@RequestBody Map<String, String> payload, @PathVariable UUID projectId, @PathVariable UUID teamId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import java.net.URI;
import java.util.List;

import java.util.UUID;

@RestController
public class TeamController {
Expand All @@ -21,11 +21,19 @@ public class TeamController {
public List<TeamItem> getAllToDoItems(){
return teamItemService.findAll();
}
@PostMapping("/team/add")
public ResponseEntity<TeamItem> postMethodName(@RequestBody TeamItem teamItem) {
TeamItem savedTeam = teamItemService.addTeamItem(teamItem);
return ResponseEntity.ok(savedTeam);
@GetMapping(value = "/team/{projectId}")
public ResponseEntity<List<TeamItem>> getTeamByProjectId(@PathVariable UUID projectId) {
List<TeamItem> teamItems = teamItemService.getTeamByProjectId(projectId);
if (teamItems.isEmpty()) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(teamItems, HttpStatus.OK);
}
@PostMapping("/team/add")
public ResponseEntity<TeamItem> postMethodName(@RequestBody TeamItem teamItem) {
TeamItem savedTeam = teamItemService.addTeamItem(teamItem);
return ResponseEntity.ok(savedTeam);
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,32 @@
import com.springboot.TaskO.service.UserItemService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.net.URI;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
public class UserItemController {
@Autowired
private UserItemService userItemService;
//@CrossOrigin
private final RestTemplate restTemplate = new RestTemplate();
private final ObjectMapper objectMapper = new ObjectMapper();
private final String clerkSecretKey = "sk_test_6Ib6VO3fmCDHpSNC2eJUXgkO9DrE70NusLvT7NmWFI";

@GetMapping(value = "/users/all")
public List<UserItem> getAllToDoItems(){
return userItemService.findAll();
Expand Down Expand Up @@ -80,31 +91,67 @@ public ResponseEntity<?> registerTelegramUser(@RequestBody Map<String, String> r
.body("Error registrando usuario de telegram: " + e.getMessage());
}
}
// @PostMapping("/users/register")
// public ResponseEntity<?> registerTelegramUser(@RequestBody Map<String, String> registration) {
// try {
// String userId = registration.get("username");
// String telegramId = registration.get("telegramId");

// if (userId == null || telegramId == null) {
// return ResponseEntity.badRequest().body("Username and telegramId are required");
// }

// // Add telegram to user and get the updated user
// UserItem updatedUser = userItemService.addTelegramToUserItem(userId, telegramId);
@PostMapping("/resolveusername")
public ResponseEntity<Map<String, String>> resolveUsers(@RequestBody List<String> userIds) {
try {
Map<String, String> userNames = new HashMap<>();

// if (updatedUser == null) {
// return ResponseEntity.status(HttpStatus.NOT_FOUND)
// .body("User not found with username: " + userId);
// }
for (String userId : userIds) {
try {
// Hacer llamada HTTP directa a la API de Clerk
String url = "https://api.clerk.com/v1/users/" + userId;

HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "Bearer " + clerkSecretKey);
headers.set("Content-Type", "application/json");

HttpEntity<String> entity = new HttpEntity<>(headers);

ResponseEntity<String> response = restTemplate.exchange(
url, HttpMethod.GET, entity, String.class);

if (response.getStatusCode() == HttpStatus.OK) {
JsonNode userJson = objectMapper.readTree(response.getBody());

String displayName = "";
String firstName = userJson.path("first_name").asText(null);
String lastName = userJson.path("last_name").asText(null);
String username = userJson.path("username").asText(null);

if (firstName != null && !firstName.isEmpty() && lastName != null && !lastName.isEmpty()) {
displayName = firstName + " " + lastName;
} else if (username != null && !username.isEmpty()) {
displayName = username;
} else {
JsonNode emailAddresses = userJson.path("email_addresses");
if (emailAddresses.isArray() && emailAddresses.size() > 0) {
String email = emailAddresses.get(0).path("email_address").asText();
if (email != null && !email.isEmpty()) {
displayName = email;
} else {
displayName = "User " + userId.replace("user_", "").substring(0, 8);
}
} else {
displayName = "User " + userId.replace("user_", "").substring(0, 8);
}
}

userNames.put(userId, displayName);
} else {
userNames.put(userId, "User " + userId.replace("user_", "").substring(0, 8));
}
} catch (Exception e) {
System.err.println("Error fetching user " + userId + ": " + e.getMessage());
userNames.put(userId, "User " + userId.replace("user_", "").substring(0, 8));
}
}

// // Return the updated user
// return ResponseEntity.ok(updatedUser);
// } catch (Exception e) {
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
// .body("Error registering telegram user: " + e.getMessage());
// }
// }
return ResponseEntity.ok(userNames);
} catch (Exception e) {
System.err.println("Error in resolveUsers: " + e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
import org.springframework.stereotype.Repository;

import java.util.UUID;
import java.util.List;

@Repository
public interface TeamItemRepository extends JpaRepository<TeamItem, UUID> {
// Method to find TeamItems by projectId
List<TeamItem> findByProjectId(UUID projectId);

// Additional custom query methods can go here
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public ResponseEntity<TeamItem> getTeamItemById(UUID id) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}
public List<TeamItem> getTeamByProjectId(UUID projectId) {
return teamItemRepository.findByProjectId(projectId);
}

public TeamItem addTeamItem(TeamItem teamItem) {
return teamItemRepository.save(teamItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

import { useProjects } from "@/context/ProjectContext"
import oracleLogo from "../assets/oracleLogo.svg"

interface HeaderProps {
title: string
currentTeamName?: string
}

export function Header({ title }: HeaderProps) {
export function Header({ title, currentTeamName }: HeaderProps) {
const { currentProject, loading } = useProjects()

// Determine href based on current path
const href = window.location.pathname === "/choosepath" ? "/dashboard" : "/choosepath"

// Get current date and format it
const currentDate = new Date()
const day = currentDate.toLocaleDateString('en-US', { weekday: 'long' })
Expand All @@ -23,15 +28,24 @@ export function Header({ title }: HeaderProps) {
<header className="bg-[#312D2A] py-4 px-8 flex items-center justify-between">
<div className="flex items-center gap-8">
<div className="flex items-center gap-4 ">
<a href="/choosepath"><img src={oracleLogo} alt="logo" className="w-32 h-8" /></a>
<a href={href}><img src={oracleLogo} alt="logo" className="w-32 h-8 hover:scale-110 transition-transform duration-300" /></a>
<h1 className="text-3xl font-medium tracking-tight text-gray-200">
<span>{title}</span>
</h1>
</div>
<div className="text-sm text-gray-400 border-l border-gray-200 pl-6">
Current Project: <span className="font-medium text-white">
{loading ? "Loading..." : currentProject?.projectName || "No Project Selected"}
</span>
<div className="flex items-center gap-6">
<div className="text-sm text-gray-400 border-l border-gray-200 pl-6">
Current Project: <span className="font-medium text-white">
{loading ? "Loading..." : currentProject?.projectName || "No Project Selected"}
</span>
</div>
{currentTeamName && (
<div className="text-sm text-gray-400 border-l border-gray-200 pl-6">
Current Team: <span className="font-medium text-white">
{currentTeamName}
</span>
</div>
)}
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import { useEffect, useState } from "react";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import { CircleDot, LayoutGrid, LogOut, Settings } from "lucide-react";
import { Calendar, LayoutGrid, LogOut, Settings, Zap } from "lucide-react";
import { useNavigate, useLocation } from "react-router-dom";
import { useAuth, useUser } from "@clerk/clerk-react"; // Importar useAuth y useUser de Clerk
import oracleLogo from "../assets/oracleLogo.svg";

export function Sidebar() {
const navigate = useNavigate();
Expand Down Expand Up @@ -65,7 +66,7 @@ export function Sidebar() {
<Avatar className="w-20 h-20 border-2 border-white shadow-lg">
<AvatarImage
src={
userData.profilePicture || "/placeholder.svg?height=80&width=80"
userData.profilePicture || oracleLogo
}
alt={`${userData.firstName} ${userData.lastName}`}
/>
Expand Down Expand Up @@ -98,7 +99,7 @@ export function Sidebar() {
location.pathname === "/sprints" ? "bg-white/20 font-medium" : ""
}`}
>
<CircleDot className="mr-2 h-5 w-5" />
<Zap className="mr-2 h-5 w-5" />
Sprints
</Button>

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const getUserProject = async (userId: string) => {
}

const data = await response.json();
console.log(data);
return data;
} catch (error) {
console.error("Error fetching projects:", error);
Expand Down
Loading
Loading