Skip to content
Open
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
18 changes: 8 additions & 10 deletions components/admin/ManageEmployee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

import { useAuth } from "@/context/authContext";
import { useEffect, useState, useMemo } from "react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import {
CalendarCheck,
BarChart2,
Ticket,
Activity,
LucideIcon,
Users,
} from "lucide-react";
Expand Down Expand Up @@ -38,10 +35,10 @@ type EmployeeProfile = {
activities: ActivityLog[];
};

type DepartmentData = {
name: string;
count: number;
};
// type DepartmentData = {
// name: string;
// count: number;
// };

const employeeData: Record<string, EmployeeProfile> = {
EMP001: {
Expand Down Expand Up @@ -85,8 +82,8 @@ const employeeData: Record<string, EmployeeProfile> = {
const COLORS = ['#0088FE', '#00C49F', '#FFBB28', '#FF8042', '#8884D8', '#82CA9D', '#FFC658', '#FF6B6B'];

export default function EmployeeDashboard() {
const [searchId, setSearchId] = useState<string>("");
const [selectedId, setSelectedId] = useState<string>("EMP001");
// const [searchId, setSearchId] = useState<string>("");
// const [selectedId, setSelectedId] = useState<string>("EMP001");
const {userDetails}=useUser();
const [employees,setEmployees]=useState<DocumentData[]>([])
const [employeesFetched,setEmployeesFetched]=useState<boolean>(false)
Expand All @@ -107,7 +104,8 @@ export default function EmployeeDashboard() {
setEmployeesFetched(true)
}
catch(err){
alert("something went wrong")
alert("something went wrong");
console.log(err);
}
})()
},[])
Expand Down
5 changes: 0 additions & 5 deletions components/admin/ManageTeams.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
'use client';

import { useState } from 'react';
import { Button } from '@/components/ui/button';
import { Card, CardContent } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DialogTrigger } from '@/components/ui/dialog';
import { Pencil, PlusCircle, Trash } from 'lucide-react';
import AddNewTeam from './manageTeams/AddNewTeam';

type Team = {
Expand Down
2 changes: 1 addition & 1 deletion components/admin/ManageTickets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default function ManageTickets() {
Critical: 'bg-red-100 text-red-600',
};

const formatDate = (ts?: any) =>
const formatDate = (ts?:any) =>
ts?.toDate().toLocaleDateString('en-IN', {
day: 'numeric',
month: 'short',
Expand Down
8 changes: 3 additions & 5 deletions components/admin/manageTeams/AddNewTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {
Dialog,
DialogContent,
DialogDescription,

DialogHeader,
DialogTitle,
DialogTrigger,
Expand All @@ -18,9 +18,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
import { useMemo, useRef, useState } from "react"
import { Button } from "@/components/ui/button"
import { PlusCircle } from "lucide-react"
import { useState } from "react"
import { DocumentData } from "firebase-admin/firestore"
import { Textarea } from "@/components/ui/textarea"
import { TfiControlBackward } from "react-icons/tfi";
Expand Down Expand Up @@ -122,7 +120,7 @@ export default function AddNewTeam() {
setEmployeesFetched(true)
}
catch (err) {
console.log("error while fetching employees for creating new team")
console.log("error while fetching employees for creating new team",err)
}
}}>
<SelectTrigger className="w-full">
Expand Down
2 changes: 1 addition & 1 deletion components/basic/completeAdminProfile.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { firestoreConfig } from "@/config/firestoreConfig";
import { useAuth } from "@/context/authContext";
import { addDoc, collection, doc, DocumentData, getDocs, query, serverTimestamp, setDoc, where } from "firebase/firestore";
import { collection, doc, DocumentData, getDocs, query, serverTimestamp, setDoc, where } from "firebase/firestore";
import Image from "next/image";
import { Dispatch, SetStateAction, useState } from "react";

Expand Down
4 changes: 2 additions & 2 deletions components/employee/EmployeeSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';
import { useAuth } from "@/context/authContext";
import { useRouter } from "next/navigation";
// import { useRouter } from "next/navigation";
import { Clock, Users, User, LogOut, CalendarDays, Ticket } from "lucide-react";

interface Props {
Expand All @@ -10,7 +10,7 @@ interface Props {

export default function EmployeeSidebar({ active, setActive }: Props) {
const { signOut } = useAuth();
const router = useRouter();
// const router = useRouter();

return (
<aside className="w-64 min-h-screen bg-white border-r p-4 flex flex-col justify-between">
Expand Down
30 changes: 1 addition & 29 deletions components/employee/LeaveSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,7 @@ export default function LeaveSection(): React.JSX.Element {
setProcessing(false)
}
};
// const getStatusColor = (status: string): string => {
// switch (status.toLowerCase()) {
// case 'open':
// return 'bg-yellow-100 text-yellow-800';
// case 'in progress':
// return 'bg-blue-100 text-blue-800';
// case 'resolved':
// return 'bg-green-100 text-green-800';
// case 'closed':
// return 'bg-gray-100 text-gray-800';
// default:
// return 'bg-gray-100 text-gray-800';
// }
// };

// const getPriorityColor = (priority: string): string => {
// switch (priority.toLowerCase()) {
// case 'critical':
// return 'bg-red-100 text-red-800';
// case 'high':
// return 'bg-red-100 text-orange-800';
// case 'medium':
// return 'bg-yellow-100 text-yellow-800';
// case 'low':
// return 'bg-green-100 text-green-800';
// default:
// return 'bg-gray-100 text-gray-800';
// }
// };

const handleCancel = (): void => {
// Reset form and close dialog
Expand Down Expand Up @@ -144,7 +116,7 @@ export default function LeaveSection(): React.JSX.Element {
console.log("error while fetching your leaves",err)
}
})()
},[])
})
return (
<div className="space-y-6">
<Card className="w-full max-w-2xl mx-auto">
Expand Down
123 changes: 94 additions & 29 deletions components/employee/ProfileSection.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,110 @@
'use client';

import { useUser } from "@/context/userContext";
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import { ClipboardCopy } from "lucide-react";

export default function ProfileSection() {
const { userDetails } = useUser();

const formatDate = (date: any) =>
date?.toDate
? date.toDate().toLocaleDateString("en-IN", {
day: "numeric",
month: "short",
year: "numeric",
})
: "—";

return (
<div className="bg-white p-6 rounded-2xl shadow-md border border-gray-100 max-w-3xl mx-auto">
<h2 className="text-2xl font-bold text-blue-700 mb-6 border-b pb-2">Profile Information</h2>

<div className="grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4 text-sm text-gray-700">
<ProfileRow label="Name" value={userDetails?.name} />
<ProfileRow label="Role" value={userDetails?.current_role || userDetails?.role} />
<ProfileRow label="Email" value={userDetails?.employee_id || userDetails?.personal_email} />
<ProfileRow label="Team" value={userDetails?.team || '—'} />
<ProfileRow label="Department" value={userDetails?.department || '—'} />
<ProfileRow label="Status" value={userDetails?.current_status || '—'} />
<ProfileRow label="Organization" value={userDetails?.organization_name} />
<ProfileRow
label="Joining Date"
value={
userDetails?.joining_date
? userDetails.joining_date.toDate().toLocaleDateString("en-IN", {
day: "numeric",
month: "short",
year: "numeric",
})
: '—'
}
/>
<ProfileRow label="Yearly Leaves" value={userDetails?.yearly_leaves?.toString() || '—'} />
<div className="bg-gradient-to-br from-blue-50 to-white p-[2px] rounded-3xl shadow-lg max-w-4xl mx-auto mt-10">
<div className="bg-white rounded-[22px] p-8 sm:p-10">
{/* Header with Avatar */}
<div className="flex flex-col sm:flex-row sm:items-center gap-6 mb-10">
<div className="relative w-20 h-20">
<Avatar className="w-full h-full ring-4 ring-blue-200 shadow-md">
<AvatarFallback className="text-lg">
{userDetails?.name?.[0] || "E"}
</AvatarFallback>
</Avatar>
</div>

<div>
<h2 className="text-3xl font-bold text-gray-800 tracking-tight">
{userDetails?.name || "—"}
</h2>
<p className="text-blue-600 font-medium mt-1">
{userDetails?.current_role || userDetails?.role || "—"}
</p>
</div>
</div>

{/* Divider */}
<div className="border-t border-dashed border-gray-200 mb-6" />

{/* Profile Details Grid */}
<div className="grid grid-cols-1 sm:grid-cols-2 gap-x-10 gap-y-6 text-sm text-gray-700">
<ProfileRow label="Email / Employee ID" value={userDetails?.employee_id || userDetails?.personal_email} copyable />
<ProfileRow label="Team" value={userDetails?.team} />
<ProfileRow label="Department" value={userDetails?.department} />
<ProfileRow label="Status" value={userDetails?.current_status} highlightStatus />
<ProfileRow label="Organization" value={userDetails?.organization_name} />
<ProfileRow label="Joining Date" value={formatDate(userDetails?.joining_date)} />
<ProfileRow label="Yearly Leaves" value={userDetails?.yearly_leaves?.toString()} />
</div>
</div>
</div>
);
}

function ProfileRow({ label, value }: { label: string; value: string | undefined }) {
function ProfileRow({
label,
value,
copyable = false,
highlightStatus = false,
}: {
label: string;
value: string | undefined;
copyable?: boolean;
highlightStatus?: boolean;
}) {
const handleCopy = () => {
if (value) navigator.clipboard.writeText(value);
};

return (
<div>
<p className="text-gray-500 font-medium">{label}</p>
<p className="text-gray-800">{value || '—'}</p>
<div className="flex items-start justify-between gap-3 group">
<div>
<p className="text-gray-500 font-medium mb-1">{label}</p>
{highlightStatus ? (
<span
className={`inline-block text-xs px-2 py-1 rounded-full font-semibold transition ${
value === "Active"
? "bg-green-100 text-green-700"
: value === "Inactive"
? "bg-gray-100 text-gray-600"
: "bg-yellow-100 text-yellow-800"
}`}
>
{value || "—"}
</span>
) : (
<p className="text-gray-900 text-sm">{value || "—"}</p>
)}
</div>

{copyable && value && (
<Button
variant="ghost"
size="icon"
onClick={handleCopy}
title="Copy to clipboard"
className="opacity-0 group-hover:opacity-100 transition"
>
<ClipboardCopy className="h-4 w-4 text-gray-400 hover:text-gray-600" />
</Button>
)}
</div>
);
}
}
7 changes: 2 additions & 5 deletions components/employee/TeamOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ function getDeadlineStatus(deadline: Timestamp | undefined) {
return { label: 'Upcoming', color: 'bg-green-100 text-green-600' };
}

const teams = [
{ id: 1, name: "UI Team", manager: "Raj Mehra", members: 5 },
{ id: 2, name: "API Team", manager: "Sonal Gupta", members: 4 },
];


export default function TeamOverview() {

Expand All @@ -51,7 +48,7 @@ export default function TeamOverview() {
console.log("error while getting teams", err);
}
})()
}, [])
})
return (
<div className="bg-white p-6 rounded-2xl">
<h2 className="text-2xl font-bold text-blue-700 mb-6 border-b pb-2">
Expand Down
23 changes: 11 additions & 12 deletions components/employee/TicketsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client';

import { useState, ChangeEvent, FormEvent, useEffect } from 'react';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import {
Expand All @@ -26,16 +25,16 @@ interface TicketData {
category: string;
}

interface Ticket {
id: string;
title: string;
description: string;
priority: string;
category: string;
status: string;
createdAt: string;
updatedAt: string;
}
// interface Ticket {
// id: string;
// title: string;
// description: string;
// priority: string;
// category: string;
// status: string;
// createdAt: string;
// updatedAt: string;
// }

export default function TicketsSection(): React.JSX.Element {
const [ticketData, setTicketData] = useState<TicketData>({
Expand Down Expand Up @@ -159,7 +158,7 @@ export default function TicketsSection(): React.JSX.Element {
console.log("error while fetching tickets", err)
}
})()
}, [])
})
return (
<div className="space-y-6">
{/* Raise Ticket Section */}
Expand Down
Loading