Skip to content

Commit 5798e27

Browse files
authored
Merge pull request #83 from De-Project-Company/main
Updates from feedback
2 parents d8ace6a + 631c694 commit 5798e27

26 files changed

+1164
-383
lines changed

app/(employer)/notification/dropDown.tsx

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const NotificationDopDown = () => {
4040
fetchNotifications();
4141
}, []);
4242

43+
// console.log(notifications);
44+
4345
return (
4446
<>
4547
<div
@@ -57,33 +59,54 @@ const NotificationDopDown = () => {
5759
: "opacity-0 h-0 duration-200 overflow-hidden pointer-events-none"
5860
)}
5961
>
60-
<div className="flex flex-col w-[300px] items-center gap-3 pb-3">
61-
<div className=" sticky top-0 flex justify-between border-b w-full pb-2 dark:text-white px-4 py-2 bg-white dark:bg-primary">
62-
<h1 className="font-[600]">Notifications</h1>
63-
<Link href="/notification">View all</Link>
62+
<div className="flex flex-col w-[300px] items-center ">
63+
<div
64+
className=" sticky top-0 flex justify-between border-b w-full pb-2 dark:text-white px-4 py-2
65+
bg-white dark:bg-primary items-center"
66+
>
67+
<h1 className="font-[600] text-xs md:text-sm">Notifications</h1>
68+
<Link href="/notification " className="text-xs md:text-sm">
69+
View all
70+
</Link>
6471
</div>
6572

66-
<div>
67-
<ul className="flex flex-col w-full">
73+
<div className="w-full">
74+
<ul className="flex flex-col w-full ">
6875
{notifications?.map((notification) => (
69-
<li
70-
key={notification._id}
71-
className={`h-fit py-4 flex flex-col `}
72-
>
73-
<div className="flex w-full gap-1 items-center justify-between">
76+
<li key={notification._id} className={`h-fit flex flex-col `}>
77+
<div
78+
className="flex w-full gap-1 items-center justify-between px-3 mb-1 last:mb-0
79+
hover:bg-gray-100 cursor-pointer pt-1 group"
80+
>
7481
{/* <div className="m-auto w-fit p-2 rounded-full">
7582
<NotificationIcon size="20" />
7683
</div> */}
77-
<div className="flex items-center gap-1 pb-1 justify-center flex-col w-full border-b-[1px] border-header dark:border-white">
78-
<span className="font-normal text-[#5B5F5E] dark:text-white text-xs">
79-
{notification.message.length > 50
84+
85+
<div className="each_wrapper flex space-x-1">
86+
<div className="status h-2 w-2 rounded-full bg-green-500 block self-start mt-1"></div>
87+
{/* did most tweek here */}
88+
<div
89+
className="flex items-center space-y-2 justify-center flex-col w-full
90+
border-gray-200 border-b-[1px] pb-1 dark:border-white "
91+
>
92+
<p
93+
className="text-[#5B5F5E] dark:text-white text-xs font-medium
94+
w-fit block group-hover:font-bold "
95+
>
96+
{/* {notification.message.length > 50
8097
? notification.message.slice(0, 40) + "..."
81-
: notification.message}
82-
</span>
98+
: notification.message} */}
99+
100+
{notification?.message}
101+
</p>
83102

84-
<p className="text-gray-600 dark:text-white w-full float-left text-sm text-left justify-start items-start align-baseline">
85-
{timeAgo(notification.createdAt)}
86-
</p>
103+
<p
104+
className="text-gray-400 dark:text-white w-full float-left text-xs text-left justify-start
105+
items-start align-baseline"
106+
>
107+
{timeAgo(notification.createdAt)}
108+
</p>
109+
</div>
87110
</div>
88111
</div>
89112
</li>

app/(employer)/projects/[details]/content/AddTeamModal.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import FormError from "@/components/form/Error";
99
import { X } from "lucide-react";
1010
import Button from "@/components/ui/Button";
1111
import { MinusCirlce } from "iconsax-react";
12+
import { useProjectCtx } from "@/context/Projectctx";
1213

1314
interface AssognTaskProp {
1415
projectid?: string;
@@ -20,6 +21,7 @@ const Team = ({ projectid }: AssognTaskProp) => {
2021
const [success, setSuccess] = useState<string | undefined>("");
2122
const [error, setError] = useState<string | undefined>("");
2223
const [teamMembers, setTeamMembers] = useState<string[]>([""]);
24+
const { setUpdate } = useProjectCtx();
2325

2426
const handleInputChange = (index: number, value: string) => {
2527
const updatedTeamMembers = [...teamMembers];
@@ -46,6 +48,7 @@ const Team = ({ projectid }: AssognTaskProp) => {
4648
AddMembers({ teamMembers }, projectid!).then((data) => {
4749
setSuccess(data?.success);
4850
setError(data?.error);
51+
setUpdate(true);
4952
if (data?.success) {
5053
setTimeout(() => {
5154
setaddTeamMemberMoal(false);

app/(employer)/projects/[details]/content/ChangeStatusModal.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useStateCtx } from "@/context/StateCtx";
88
import FormSuccess from "@/components/form/Success";
99
import FormError from "@/components/form/Error";
1010
import { updateProjectStatus } from "@/actions/project";
11+
import { useProjectCtx } from "@/context/Projectctx";
1112

1213
type StatusProps = {
1314
id?: number;
@@ -35,6 +36,8 @@ interface ChanegStatusProps {
3536
const ChangeProjectStatus = ({ projectid }: ChanegStatusProps) => {
3637
const { ChangeProjectStatusModal, setChangeProjectStatusModal } =
3738
useStateCtx();
39+
const { setUpdate } = useProjectCtx();
40+
3841
const [selectedStatus, setSelectedStatus] = useState<
3942
StatusProps["label"] | null
4043
>(null);
@@ -50,15 +53,12 @@ const ChangeProjectStatus = ({ projectid }: ChanegStatusProps) => {
5053
const result = await updateProjectStatus(projectid!, selectedStatus!);
5154

5255
if (result?.status === "success") {
56+
setUpdate(true);
5357
setSuccess("Project status updated successfully!");
5458
setTimeout(() => {
5559
setChangeProjectStatusModal(false);
5660
router.refresh();
5761
}, 3000);
58-
59-
setTimeout(() => {
60-
setChangeProjectStatusModal(false);
61-
}, 5000);
6262
} else {
6363
// console.error("Error updating project status:", result?.error);
6464
setError(result?.error);

app/(employer)/projects/[details]/content/DetailsContainer.tsx

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import { ProjectProps } from "@/types";
88
import { getPojectdetails } from "@/actions/project";
99
import { Edit2, More, Trash, Status } from "iconsax-react";
1010
import TeamSection from "./TeamMembers";
11-
import { cn, daysToHours, calculateCountdown } from "@/utils";
11+
import { cn } from "@/utils";
1212
import useCountdown from "@/hooks/useCountdown";
1313
import DeletePojectModal from "./DeletePojectModal";
1414
import { useStateCtx } from "@/context/StateCtx";
1515
import ChangeProjectStatus from "./ChangeStatusModal";
1616
import ProjectComments from "./coment";
1717
import TaskSesion from "./TaskSesion";
18+
import ProjectDoc from "./Doc";
19+
import { useProjectCtx } from "@/context/Projectctx";
1820

1921
const DetailsContainer = ({ title, id }: { title?: string; id?: string }) => {
2022
const { user } = useUserCtx();
@@ -23,38 +25,42 @@ const DetailsContainer = ({ title, id }: { title?: string; id?: string }) => {
2325
setDeleteProjectModal,
2426
setChangeProjectStatusModal,
2527
} = useStateCtx();
28+
const { setUpdate, Update } = useProjectCtx();
2629

2730
const [projectData, setProjectData] = useState<ProjectProps | null>(null);
2831

29-
useEffect(() => {
30-
const fetchProjectDetails = async () => {
31-
try {
32-
const project = await getPojectdetails(id!);
33-
if (project?.status === "success") {
34-
setProjectData(project.project);
35-
}
36-
} catch (error) {
37-
console.error(
38-
"An error occurred while fetching project details:",
39-
error
40-
);
32+
const fetchProjectDetails = async () => {
33+
try {
34+
const project = await getPojectdetails(id!);
35+
if (project?.status === "success") {
36+
setProjectData(project.project);
37+
setUpdate(false);
4138
}
42-
};
39+
} catch (error) {
40+
console.error("An error occurred while fetching project details:", error);
41+
}
42+
};
4343

44+
useEffect(() => {
4445
fetchProjectDetails();
4546
}, [id]);
4647

48+
useEffect(() => {
49+
if (Update) {
50+
fetchProjectDetails();
51+
}
52+
}, [Update]);
53+
4754
const admin = projectData?.teamMembers?.find(
4855
(member) => member.user._id === projectData?.owner?._id
4956
);
5057
const isNotAdmin = admin?.user._id !== user?.id;
5158

5259
const fullName = user?.name;
5360
const [firstName] = fullName!.split(/\s+/);
54-
const hours = daysToHours(projectData?.duration!);
55-
const time = calculateCountdown(projectData?.endDate!);
5661
const countDownTIme = useCountdown(projectData?.endDate!);
5762
const [isDotMenu, setIsDotMenu] = useState(false);
63+
const [docsNum, setDocsNum] = useState(5);
5864

5965
useEffect(() => {
6066
if (isDotMenu) {
@@ -73,6 +79,8 @@ const DetailsContainer = ({ title, id }: { title?: string; id?: string }) => {
7379
return () => document.removeEventListener("keyup", handleKeyUp);
7480
}, [isDotMenu]);
7581

82+
const docs = [1, 2, 3, 4, 5, 6, 7, 8, 9];
83+
7684
return (
7785
<>
7886
<DeletePojectModal
@@ -220,36 +228,31 @@ const DetailsContainer = ({ title, id }: { title?: string; id?: string }) => {
220228

221229
{/* Projects Images */}
222230
<div className="grid md:grid-cols-2 gap-4 ">
223-
<div className="projectDesc mt-12 bg-[#F9F9F9] px-4 py-5 border border-neutral-100 rounded-lg shadow-sm">
224-
<div className="flex justify-between items-center my-5">
225-
<div className="flex space-x-2 items-center">
226-
<div className=" bg-[#ECEBFF] h-10 w-10 rounded-full flex items-center justify-center">
227-
<FaBriefcase />
228-
</div>
229-
<h5 className="font-bold text-primary text-xl items-center ">
230-
Project Images
231-
</h5>
231+
<div className="flex flex-col w-full py-3 sm:p-3 mt-12 sm:rounded-xl h-full">
232+
<h3 className="text-lg font-semibold text-header dark:text-gray-100 pb-4">
233+
Project Documents
234+
</h3>
235+
<div className="flex flex-col h-full max-h-[250px] overflow-y-auto sidebar-scroll w-full">
236+
<div className="flex flex-col gap-y-4 px-1">
237+
{docs.slice(0, docsNum).map((num) => (
238+
<ProjectDoc key={num} />
239+
))}
240+
</div>
241+
<div className="flex">
242+
<button
243+
type="button"
244+
className="text-primary dark:text-color-dark underline text-sm font-medium pt-4 capitalize"
245+
onClick={() => {
246+
if (docsNum === docs.length) {
247+
setDocsNum(5);
248+
return;
249+
}
250+
setDocsNum(docs.length);
251+
}}
252+
>
253+
{docsNum === docs.length ? " See less" : "See All"}
254+
</button>
232255
</div>
233-
234-
<p className="block text-primary font-medium hover:font-bold cursor-pointer text-xs md:text-sm">
235-
See More
236-
</p>
237-
</div>
238-
239-
{/* Images section */}
240-
<div className="grid grid-cols-3 gap-2 overflow-hidden">
241-
{[1, 2, 3].map((index) => (
242-
<div key={index} className="h-[140.69px] w-[167px] relative ">
243-
<Image
244-
key={index}
245-
src="/assets/screenshot/screenshot_showcase.png"
246-
height={400}
247-
width={400}
248-
alt="Project Images"
249-
className="h-full w-full object-fit "
250-
/>
251-
</div>
252-
))}
253256
</div>
254257
</div>
255258

@@ -266,6 +269,7 @@ const DetailsContainer = ({ title, id }: { title?: string; id?: string }) => {
266269
tasks={projectData?.tasks}
267270
teamMembers={projectData?.teamMembers}
268271
owner={projectData?.owner}
272+
endDate={projectData?.endDate}
269273
/>
270274
{/* Projects Comment Section */}
271275
<ProjectComments projectId={id!} />
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Document, DocumentDownload, Share } from "iconsax-react";
2+
import React from "react";
3+
4+
const ProjectDoc = () => {
5+
return (
6+
<div className="flex gap-y-2 w-full sm:h-[30px] sm:items-center justify-between border-b border-[#e1e1e1] dark:border-primary-light py-1 sm:py-0">
7+
<div className="flex items-center justify-between gap-x-2 dark:text-gray-200">
8+
<Document size={18} />
9+
<span className="text-base max-[359px]:text-sm ">
10+
Project proposal <span className="opacity-80">.pdf</span>
11+
</span>
12+
</div>
13+
<div className="flex gap-y-2 flex-col sm:flex-row items-start sm:items-center justify-between gap-x-4">
14+
<button
15+
type="button"
16+
className="flex items-center gap-x-1 text-sm max-[359px]:text-xs dark:text-gray-200"
17+
>
18+
{" "}
19+
<Share size={16} />
20+
<span>Share</span>
21+
</button>
22+
23+
<button
24+
type="button"
25+
className="flex items-center gap-x-1 text-sm max-[359px]:text-xs dark:text-gray-200"
26+
>
27+
{" "}
28+
<DocumentDownload size={16} />
29+
<span>Download</span>
30+
</button>
31+
</div>
32+
</div>
33+
);
34+
};
35+
36+
export default ProjectDoc;

app/(employer)/projects/[details]/content/TaskSesion.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface User {
2020
__v: number;
2121
}
2222

23-
interface UserWithRole {
23+
export interface UserWithRole {
2424
user: User;
2525
role: string;
2626
accepted: boolean;
@@ -47,13 +47,15 @@ interface TasksessionProp {
4747
tasks?: Task[];
4848
teamMembers?: UserWithRole[];
4949
owner?: Owner;
50+
endDate?: string;
5051
}
5152

5253
const TaskSesion = ({
5354
projectid,
5455
tasks,
5556
teamMembers,
5657
owner,
58+
endDate,
5759
}: TasksessionProp) => {
5860
const [isMenu, setIsMenu] = useState(false);
5961
const { setaddTaskModal } = useStateCtx();
@@ -78,7 +80,6 @@ const TaskSesion = ({
7880
return () => document.removeEventListener("keyup", handleKeyUp);
7981
}, [isMenu]);
8082

81-
8283
return (
8384
<>
8485
<div
@@ -161,7 +162,11 @@ const TaskSesion = ({
161162
)}
162163

163164
{/* Create Task Modal */}
164-
<AssignTask projectid={projectid} />
165+
<AssignTask
166+
projectid={projectid}
167+
teamMembers={teamMembers}
168+
endDate={endDate}
169+
/>
165170
</div>
166171
</>
167172
);

0 commit comments

Comments
 (0)