Skip to content

Commit 2ee836d

Browse files
Merge pull request #573 from CodebilityDev/orgchart/juryyy
feat: updated org chart with tree visual layout and accurate skeleton…
2 parents 6e2ee25 + 4b5fb9f commit 2ee836d

12 files changed

Lines changed: 750 additions & 341 deletions

File tree

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
"use client";
22

3-
import Link from "next/link";
3+
import { useRouter } from "next/navigation";
44
import { Button } from "@/components/ui/button";
5+
import { X } from "lucide-react";
56

67
export default function ProfileCloseButton() {
8+
const router = useRouter();
9+
710
const handleClose = () => {
8-
window.close();
11+
// If they came from somewhere within the app, go back.
12+
// In rare cases where they opened directly, they might need to go home, but router.back() handles history.
13+
router.back();
914
};
1015

1116
return (
12-
<Link href="/">
13-
<Button
14-
variant="hollow"
15-
className="bg-black-200 flex gap-2 border-zinc-700 text-white"
16-
onClick={handleClose}
17-
>
18-
Close
19-
</Button>
20-
</Link>
17+
<button
18+
onClick={handleClose}
19+
aria-label="Go back"
20+
className="text-white hover:text-gray-300 transition-colors"
21+
>
22+
<X className="h-6 w-6" />
23+
</button>
2124
);
2225
}

‎apps/codebility/app/home/_components/DynamicMainContent.tsx‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { ReactNode } from "react";
4+
import { usePathname } from "next/navigation";
45
import { useNavStore } from "@/hooks/use-sidebar";
56

67
interface DynamicMainContentProps {
@@ -9,13 +10,16 @@ interface DynamicMainContentProps {
910

1011
export default function DynamicMainContent({ children }: DynamicMainContentProps) {
1112
const { isToggleOpen } = useNavStore();
12-
13-
// Dynamic margin based on sidebar state - only apply on desktop (lg screens and up)
14-
const marginClass = isToggleOpen ? "lg:ml-64" : "lg:ml-20"; // 16rem = ml-64, 5rem = ml-20
15-
13+
const pathname = usePathname();
14+
15+
const isOrgChart = pathname === "/home/orgchart";
16+
17+
18+
const marginClass = isToggleOpen ? "lg:ml-64" : "lg:ml-20";
19+
1620
return (
17-
<main
18-
className={`background-lightsection_darksection flex-1 pt-[60px] overflow-y-auto overflow-x-hidden min-h-screen ${marginClass} transition-all duration-300 ease-in-out`}
21+
<main
22+
className={`background-lightsection_darksection flex-1 pt-[60px] ${isOrgChart ? "lg:overflow-hidden lg:h-[calc(100vh)] overflow-y-auto" : "overflow-y-auto"} overflow-x-hidden h-full ${marginClass} transition-all duration-300 ease-in-out`}
1923
>
2024
{children}
2125
</main>

‎apps/codebility/app/home/_components/LeftSidebarServer.tsx‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@ export default async function LeftSidebarServer() {
66
const supabase = await createClientServerComponent();
77

88
// Get user data server-side
9-
const { data: { user } } = await supabase.auth.getUser();
10-
if (!user) return null;
9+
const { data: authData } = await supabase.auth.getUser();
10+
const user = authData?.user;
11+
12+
if (!user) {
13+
const sidebarData = await getSidebarData(null);
14+
return <LeftSidebarClient initialSidebarData={sidebarData} />;
15+
}
1116

1217
const { data: userData } = await supabase
1318
.from("codev")
1419
.select("role_id, internal_status, availability_status")
1520
.eq("id", user.id)
1621
.single();
1722

18-
if (!userData) return null;
23+
if (!userData) {
24+
// Fallback if user exists in auth but not in codev table
25+
const sidebarData = await getSidebarData(null);
26+
return <LeftSidebarClient initialSidebarData={sidebarData} />;
27+
}
1928

2029
// Calculate roleId server-side
2130
const roleId = userData.internal_status === "INACTIVE" ||

‎apps/codebility/app/home/admin-controls/ticket-support/_components/TicketManagementView.tsx‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default function TicketManagementView({
3535
codevList,
3636
}: TicketManagementViewProps) {
3737
const router = useRouter();
38-
const { closeNav, toggleNav, isToggleOpen } = useNavStore();
38+
const { } = useNavStore();
3939
const [selectedTicket, setSelectedTicket] = useState<TicketSupport | null>(null);
4040
const [searchQuery, setSearchQuery] = useState("");
4141
const [sortField, setSortField] = useState<SortField>("created_at");
@@ -45,8 +45,6 @@ export default function TicketManagementView({
4545
const [filterAssignedTo, setFilterAssignedTo] = useState<string>("ALL");
4646
const [showArchived, setShowArchived] = useState(false);
4747

48-
const [wasSidebarOpen, setWasSidebarOpen] = useState(false);
49-
5048

5149
useEffect(() => {
5250
if (selectedTicket) {
@@ -130,17 +128,10 @@ export default function TicketManagementView({
130128

131129
const handleTicketSelect = (ticket: TicketSupport) => {
132130
setSelectedTicket(ticket);
133-
setWasSidebarOpen(isToggleOpen);
134-
if (isToggleOpen) {
135-
closeNav();
136-
}
137131
};
138132

139133
const handleCloseSidebar = () => {
140134
setSelectedTicket(null);
141-
if (wasSidebarOpen && !isToggleOpen) {
142-
toggleNav();
143-
}
144135
};
145136

146137
const handleTicketUpdated = () => {

0 commit comments

Comments
 (0)