mostrando minhas solicitgacoes
This commit is contained in:
parent
b8237e43ec
commit
211cc1ba6b
8 changed files with 220 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ import net.beetechgroup.beetask.usecase.organization.create.CreateOrganizationUs
|
|||
import net.beetechgroup.beetask.usecase.organization.search.SearchOrganizationsUseCase;
|
||||
import net.beetechgroup.beetask.usecase.organization.join.RequestJoinOrganizationUseCase;
|
||||
import net.beetechgroup.beetask.usecase.organization.requests.ListPendingRequestsUseCase;
|
||||
import net.beetechgroup.beetask.usecase.organization.requests.ListUserJoinRequestsUseCase;
|
||||
import net.beetechgroup.beetask.usecase.organization.requests.HandleJoinRequestUseCase;
|
||||
import net.beetechgroup.beetask.usecase.organization.auth.AuthorizeOrganizationAdminUseCase;
|
||||
import net.beetechgroup.beetask.usecase.repository.OrganizationRepository;
|
||||
|
|
@ -51,4 +52,10 @@ public class OrganizationUseCaseConfig {
|
|||
UserOrganizationRepository userOrganizationRepository) {
|
||||
return new HandleJoinRequestUseCase(authorizer, userOrganizationRepository);
|
||||
}
|
||||
|
||||
@Produces
|
||||
public ListUserJoinRequestsUseCase listUserJoinRequestsUseCase(UserOrganizationRepository userOrganizationRepository,
|
||||
UserRepository userRepository) {
|
||||
return new ListUserJoinRequestsUseCase(userOrganizationRepository, userRepository);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,6 @@ import jakarta.ws.rs.PATCH;
|
|||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import net.beetechgroup.beetask.usecase.organization.create.CreateOrganizationInput;
|
||||
import net.beetechgroup.beetask.usecase.organization.create.CreateOrganizationOutput;
|
||||
import net.beetechgroup.beetask.usecase.organization.create.CreateOrganizationUseCase;
|
||||
|
|
@ -18,6 +17,8 @@ import net.beetechgroup.beetask.usecase.organization.search.SearchOrganizationsU
|
|||
import net.beetechgroup.beetask.usecase.organization.search.SearchOrganizationOutput;
|
||||
import net.beetechgroup.beetask.usecase.organization.join.RequestJoinOrganizationUseCase;
|
||||
import net.beetechgroup.beetask.usecase.organization.requests.ListPendingRequestsUseCase;
|
||||
import net.beetechgroup.beetask.usecase.organization.requests.ListUserJoinRequestsUseCase;
|
||||
import net.beetechgroup.beetask.usecase.organization.requests.UserJoinRequestOutput;
|
||||
import net.beetechgroup.beetask.usecase.organization.requests.JoinRequestOutput;
|
||||
import net.beetechgroup.beetask.usecase.organization.requests.HandleJoinRequestUseCase;
|
||||
|
||||
|
|
@ -38,6 +39,9 @@ public class OrganizationController {
|
|||
@Inject
|
||||
ListPendingRequestsUseCase listPendingRequestsUseCase;
|
||||
|
||||
@Inject
|
||||
ListUserJoinRequestsUseCase listUserJoinRequestsUseCase;
|
||||
|
||||
@Inject
|
||||
HandleJoinRequestUseCase handleJoinRequestUseCase;
|
||||
|
||||
|
|
@ -97,4 +101,13 @@ public class OrganizationController {
|
|||
String userEmail = securityIdentity.getPrincipal().getName();
|
||||
handleJoinRequestUseCase.execute(userEmail, organizationId, new HandleJoinRequestUseCase.Input(userId, false));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/my-requests")
|
||||
@Authenticated
|
||||
@Operation(summary = "List my requests", description = "List all join requests made by the current user")
|
||||
public List<UserJoinRequestOutput> listMyRequests() {
|
||||
String userEmail = securityIdentity.getPrincipal().getName();
|
||||
return listUserJoinRequestsUseCase.execute(userEmail);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
package net.beetechgroup.beetask.usecase.organization.requests;
|
||||
|
||||
import net.beetechgroup.beetask.entities.User;
|
||||
import net.beetechgroup.beetask.usecase.repository.UserOrganizationRepository;
|
||||
import net.beetechgroup.beetask.usecase.repository.UserRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ListUserJoinRequestsUseCase {
|
||||
private final UserOrganizationRepository userOrganizationRepository;
|
||||
private final UserRepository userRepository;
|
||||
|
||||
public ListUserJoinRequestsUseCase(UserOrganizationRepository userOrganizationRepository, UserRepository userRepository) {
|
||||
this.userOrganizationRepository = userOrganizationRepository;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
public List<UserJoinRequestOutput> execute(String userEmail) {
|
||||
User user = userRepository.findByEmail(userEmail)
|
||||
.orElseThrow(() -> new RuntimeException("User not found"));
|
||||
|
||||
return userOrganizationRepository.findByUserId(user.getId()).stream()
|
||||
.map(uo -> new UserJoinRequestOutput(
|
||||
uo.getOrganization().getId(),
|
||||
uo.getOrganization().getName(),
|
||||
uo.getStatus()
|
||||
))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package net.beetechgroup.beetask.usecase.organization.requests;
|
||||
|
||||
import net.beetechgroup.beetask.entities.organization.UserOrganizationStatus;
|
||||
|
||||
public record UserJoinRequestOutput(Long organizationId, String organizationName, UserOrganizationStatus status) {}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useState } from 'react'
|
||||
import { Layout, ListTodo, PlusCircle, Columns, LogOut, Settings, Building2 } from 'lucide-react'
|
||||
import { Layout, ListTodo, PlusCircle, Columns, LogOut, Settings, Building2, Clock } from 'lucide-react'
|
||||
import { NavLink, Outlet, Navigate } from 'react-router-dom'
|
||||
import { useAuth } from '../contexts/AuthContext'
|
||||
import { OnboardingModal } from './OnboardingModal'
|
||||
|
|
@ -59,6 +59,10 @@ export function AppShell() {
|
|||
<Columns size={18} />
|
||||
Quadro
|
||||
</NavLink>
|
||||
<NavLink to="/requests" className={navLinkClassName}>
|
||||
<Clock size={18} />
|
||||
Solicitações
|
||||
</NavLink>
|
||||
<NavLink to="/new" className={navLinkClassName}>
|
||||
<PlusCircle size={18} />
|
||||
Nova Tarefa
|
||||
|
|
@ -123,6 +127,10 @@ export function AppShell() {
|
|||
<Columns size={18} />
|
||||
Quadro
|
||||
</NavLink>
|
||||
<NavLink to="/requests" className={navLinkClassName}>
|
||||
<Clock size={18} />
|
||||
Pedidos
|
||||
</NavLink>
|
||||
<NavLink to="/new" className={navLinkClassName}>
|
||||
<PlusCircle size={18} />
|
||||
Criar
|
||||
|
|
|
|||
140
frontend/src/pages/MyRequestsPage.tsx
Normal file
140
frontend/src/pages/MyRequestsPage.tsx
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import { motion } from "framer-motion";
|
||||
import { Clock, CheckCircle2, XCircle, Building2, ArrowLeft } from "lucide-react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { organizationService, type UserJoinRequest } from "../services/organizationService";
|
||||
|
||||
const StatusBadge: React.FC<{ status: UserJoinRequest["status"] }> = ({ status }) => {
|
||||
const configs = {
|
||||
PENDING: {
|
||||
label: "Pendente",
|
||||
icon: Clock,
|
||||
className: "bg-amber-500/10 text-amber-500 border-amber-500/20",
|
||||
},
|
||||
ACTIVE: {
|
||||
label: "Aprovado",
|
||||
icon: CheckCircle2,
|
||||
className: "bg-emerald-500/10 text-emerald-500 border-emerald-500/20",
|
||||
},
|
||||
REJECTED: {
|
||||
label: "Recusado",
|
||||
icon: XCircle,
|
||||
className: "bg-rose-500/10 text-rose-500 border-rose-500/20",
|
||||
},
|
||||
};
|
||||
|
||||
const config = configs[status];
|
||||
const Icon = config.icon;
|
||||
|
||||
return (
|
||||
<div className={`flex items-center gap-2 px-3 py-1 rounded-full text-xs font-bold border ${config.className}`}>
|
||||
<Icon size={14} />
|
||||
<span>{config.label}</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const MyRequestsPage: React.FC = () => {
|
||||
const [requests, setRequests] = useState<UserJoinRequest[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
const fetchRequests = async () => {
|
||||
try {
|
||||
const data = await organizationService.getUserRequests();
|
||||
setRequests(data);
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch requests", error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchRequests();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="min-h-[80vh] flex flex-col items-center justify-center p-6 bg-background relative overflow-hidden">
|
||||
{/* Background Orbs */}
|
||||
<div className="absolute top-0 -left-20 w-96 h-96 bg-brand/10 rounded-full blur-[100px] pointer-events-none" />
|
||||
<div className="absolute bottom-0 -right-20 w-96 h-96 bg-brand-secondary/10 rounded-full blur-[100px] pointer-events-none" />
|
||||
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
className="w-full max-w-3xl relative z-10"
|
||||
>
|
||||
<div className="bg-surface border border-border-soft p-10 rounded-[2.5rem] shadow-panel">
|
||||
<div className="flex items-center gap-4 mb-10">
|
||||
<button
|
||||
onClick={() => navigate(-1)}
|
||||
className="w-12 h-12 rounded-2xl bg-surface-muted/50 text-text-muted hover:bg-brand/10 hover:text-brand flex items-center justify-center transition-all group"
|
||||
>
|
||||
<ArrowLeft size={24} className="group-hover:-translate-x-1 transition-transform" />
|
||||
</button>
|
||||
<div>
|
||||
<h1 className="text-3xl font-black text-text-main tracking-tight">
|
||||
Minhas Solicitações
|
||||
</h1>
|
||||
<p className="text-text-muted font-medium">
|
||||
Acompanhe o status dos seus pedidos para entrar em organizações
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="space-y-4">
|
||||
{[1, 2, 3].map((i) => (
|
||||
<div key={i} className="h-20 bg-surface-muted/50 rounded-2xl animate-pulse" />
|
||||
))}
|
||||
</div>
|
||||
) : requests.length === 0 ? (
|
||||
<div className="bg-surface-muted/30 border border-dashed border-border-soft rounded-[2rem] p-12 text-center">
|
||||
<div className="w-16 h-16 bg-surface-muted rounded-2xl flex items-center justify-center mx-auto mb-4">
|
||||
<Building2 className="text-text-muted/50" size={32} />
|
||||
</div>
|
||||
<h3 className="text-xl font-bold text-text-main mb-2">Nenhuma solicitação encontrada</h3>
|
||||
<p className="text-text-muted mb-8 max-w-xs mx-auto">
|
||||
Você ainda não solicitou participar de nenhuma organização.
|
||||
</p>
|
||||
<button
|
||||
onClick={() => navigate("/join-organization")}
|
||||
className="bg-brand hover:bg-brand-dark text-white px-8 py-3 rounded-2xl font-bold shadow-lg shadow-brand/20 transition-all active:scale-95"
|
||||
>
|
||||
Buscar Organizações
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid gap-4">
|
||||
{requests.map((request, index) => (
|
||||
<motion.div
|
||||
key={request.organizationId}
|
||||
initial={{ opacity: 0, x: -20 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
transition={{ delay: index * 0.1 }}
|
||||
className="group bg-surface-muted/30 hover:bg-surface-muted/50 border border-border-soft p-5 rounded-2xl flex items-center justify-between transition-all"
|
||||
>
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="w-12 h-12 bg-white rounded-xl shadow-sm border border-border-soft flex items-center justify-center text-brand">
|
||||
<Building2 size={24} />
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="font-bold text-text-main group-hover:text-brand transition-colors">
|
||||
{request.organizationName}
|
||||
</h3>
|
||||
<span className="text-xs text-text-muted font-semibold tracking-wider uppercase">
|
||||
ID: {request.organizationId}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<StatusBadge status={request.status} />
|
||||
</motion.div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</motion.div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -9,6 +9,7 @@ import { RegisterPage } from "./pages/RegisterPage";
|
|||
import { CreateOrganizationPage } from "./pages/CreateOrganizationPage";
|
||||
import { JoinOrganizationPage } from "./pages/JoinOrganizationPage";
|
||||
import { OrganizationAdminPage } from "./pages/OrganizationAdminPage";
|
||||
import { MyRequestsPage } from "./pages/MyRequestsPage";
|
||||
|
||||
export const router = createBrowserRouter([
|
||||
{
|
||||
|
|
@ -47,6 +48,10 @@ export const router = createBrowserRouter([
|
|||
path: "admin",
|
||||
element: <OrganizationAdminPage />,
|
||||
},
|
||||
{
|
||||
path: "requests",
|
||||
element: <MyRequestsPage />,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,12 @@ export interface JoinRequest {
|
|||
photo?: string
|
||||
}
|
||||
|
||||
export interface UserJoinRequest {
|
||||
organizationId: number
|
||||
organizationName: string
|
||||
status: 'PENDING' | 'ACTIVE' | 'REJECTED'
|
||||
}
|
||||
|
||||
export const organizationService = {
|
||||
create: async (name: string): Promise<Organization> => {
|
||||
return apiFetch('/organizations', {
|
||||
|
|
@ -38,5 +44,9 @@ export const organizationService = {
|
|||
|
||||
rejectRequest: async (organizationId: number, userId: number): Promise<void> => {
|
||||
return apiFetch(`/organizations/${organizationId}/requests/${userId}/reject`, { method: 'PATCH' })
|
||||
},
|
||||
|
||||
getUserRequests: async (): Promise<UserJoinRequest[]> => {
|
||||
return apiFetch<UserJoinRequest[]>('/organizations/my-requests')
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue