Skip to content

Commit

Permalink
Client Panel Table Fields change, some modifications to leads section…
Browse files Browse the repository at this point in the history
…....
  • Loading branch information
naumanch969 committed Nov 28, 2023
1 parent 541b76b commit 6dbff1a
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 92 deletions.
35 changes: 7 additions & 28 deletions client/src/Client Panel/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Table = () => {

const dispatch = useDispatch();
const { leads, isFetching, error } = useSelector((state) => state.lead);
console.log('leads', leads)
const { loggedUser } = useSelector((state) => state.user);
const phoneNumber = loggedUser?.phone;

Expand Down Expand Up @@ -54,45 +55,23 @@ const Table = () => {
},
{
field: "leads?.degree",
headerName: "Degree",
headerName: "Property City",
width: 160,
headerClassName: "super-app-theme--header",
renderCell: (params) => (
<Tooltip arrow placement="bottom" title={params.row?.degree}>
<div className="font-primary font-light capitalize">{params.row?.degree}</div>
<Tooltip arrow placement="bottom" title={params.row?.property?.city}>
<div className="font-primary font-light capitalize">{params.row?.property?.city}</div>
</Tooltip>
),
},
{
field: "major",
headerName: "Major",
headerName: "Title",
width: 160,
headerClassName: "super-app-theme--header",
renderCell: (params) => (
<Tooltip arrow placement="bottom" title={params.row?.major}>
<div className="font-primary font-light capitalize">{params.row?.major}</div>
</Tooltip>
),
},
{
field: "country",
headerName: "Country",
width: 160,
headerClassName: "super-app-theme--header",
renderCell: (params) => (
<Tooltip arrow placement="bottom" title={params.row?.country}>
<div className="font-primary font-light capitalize">{params.row?.country}</div>
</Tooltip>
),
},
{
field: "visa",
headerName: "Visa",
width: 160,
headerClassName: "super-app-theme--header",
renderCell: (params) => (
<Tooltip arrow placement="bottom" title={params.row?.visa}>
<div className="font-primary font-light capitalize">{params.row?.visa}</div>
<Tooltip arrow placement="bottom" title={params.row?.property?.title}>
<div className="font-primary font-light capitalize">{params.row?.property?.title}</div>
</Tooltip>
),
},
Expand Down
119 changes: 61 additions & 58 deletions client/src/Components/Navbar/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ const Navbar = ({ setShowSidebar, showSidebar, open, setOpen }) => {
/////////////////////////////////////////// USE EFFECTS ////////////////////////////////////////////
useEffect(() => {
var timer = setInterval(() => setDate(new Date()), 1000);

return function cleanup() {
clearInterval(timer);
};
Expand Down Expand Up @@ -155,65 +154,69 @@ const Navbar = ({ setShowSidebar, showSidebar, open, setOpen }) => {
<div className="flex gap-[20px] ">
{/* icons */}
<div className="sm:flex items-center hidden gap-[10px] ">
<Dropdown>
<MenuButton>
<Tooltip title="Notifications" arrow placement="bottom">
<IconButton
className="h-fit hover:text-sky-400 inline-block relative"
size="small"
aria-label="menu">
<PiBell
className={`text-[25px] animate-none ${
notifications.length > 0 ? "text-sky-400" : ""
}`}
/>
{notifications.length > 0 && (
<span className="animate-ping absolute top-1.5 right-2 block h-1 w-1 rounded-full ring-2 ring-sky-400 bg-sky-600"></span>
)}
</IconButton>
</Tooltip>
</MenuButton>
<Menu slots={{ listbox: StyledListbox }}>
{notifications.length > 0 ? (
<div className="flex flex-col gap-[8px]">
<div className="w-full bg-sky-400 font-primary text-2xl text-white p-4">
Notifications

{/* Notification */}
{
loggedUser.role != 'employee' &&
<Dropdown>
<MenuButton>
<Tooltip title="Notifications" arrow placement="bottom">
<IconButton
className="h-fit hover:text-sky-400 inline-block relative"
size="small"
aria-label="menu">
<PiBell
className={`text-[25px] animate-none ${notifications.length > 0 ? "text-sky-400" : ""
}`}
/>
{notifications.length > 0 && (
<span className="animate-ping absolute top-1.5 right-2 block h-1 w-1 rounded-full ring-2 ring-sky-400 bg-sky-600"></span>
)}
</IconButton>
</Tooltip>
</MenuButton>
<Menu slots={{ listbox: StyledListbox }}>
{notifications.length > 0 ? (
<div className="flex flex-col gap-[8px]">
<div className="w-full bg-sky-400 font-primary text-2xl text-white p-4">
Notifications
</div>
{notifications.slice(0, 5).map((notification, index) => (
<React.Fragment key={index}>
<StyledMenuItem
onClick={() => navigate("/authorization/refund")}
className="text-gray-600 flex items-center gap-2">
<div>
<Avatar />
</div>
<div className="font-primary">
<span className="text-lg font-light text-sky-400 font-primary">
{notification.title}
</span>
<br />
{notification.description}
<br />
</div>
</StyledMenuItem>
</React.Fragment>
))}
{notifications.length > 5 && (
<Link to="/notifications" className="hover:underline text-blue-500 ">
More
</Link>
)}
</div>
{notifications.slice(0, 5).map((notification, index) => (
<React.Fragment key={index}>
<StyledMenuItem
onClick={() => navigate("/authorization/refund")}
className="text-gray-600 flex items-center gap-2">
<div>
<Avatar />
</div>
<div className="font-primary">
<span className="text-lg font-light text-sky-400 font-primary">
{notification.title}
</span>
<br />
{notification.description}
<br />
</div>
</StyledMenuItem>
</React.Fragment>
))}
{notifications.length > 5 && (
<Link to="/notifications" className="hover:underline text-blue-500 ">
More
</Link>
)}
</div>
) : (
<div className="z-1000 flex flex-col items-center p-2">
<img className="p-4" src="/images/notifications.png" />
<div className="font-primary text-lg font-light">
No Notifications Yet
) : (
<div className="z-1000 flex flex-col items-center p-2">
<img className="p-4" src="/images/notifications.png" />
<div className="font-primary text-lg font-light">
No Notifications Yet
</div>
</div>
</div>
)}
</Menu>
</Dropdown>
)}
</Menu>
</Dropdown>
}

<Dropdown>
<MenuButton>
Expand Down
27 changes: 23 additions & 4 deletions client/src/Pages/Leads/Leads.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ function Leads({ type, showSidebar }) {
const dispatch = useDispatch();
const navigate = useNavigate();
const { leads, allLeads, isFetching, error } = useSelector((state) => state.lead);
console.log('leads', leads)
const { currentProject } = useSelector((state) => state.project);
const archivedLeads = leads.filter((lead) => lead.isArchived);
const unarchivedLeads = leads.filter((lead) => !lead.isArchived);
Expand All @@ -114,6 +115,25 @@ function Leads({ type, showSidebar }) {
width: 70,
renderCell: (params) => <div className="font-primary font-light">{params.row?.uid}</div>,
},
{
field: "allocatedTo",
headerName: "Allocated To",
headerClassName: "super-app-theme--header",
width: 140,
renderCell: (params) => (
<div
className={`capitalize font-primary font-light`}
onClick={() => handleOpenViewModal(params.row?._id)}>
{
params.row?.allocatedTo?.length > 0
?
params.row?.allocatedTo?.map((user) => <span className="text-[#20aee3] hover:text-[#007bff] cursor-pointer " >{user?.username} </span>)
:
<span >Not Allocated</span>
}
</div>
),
},
{
field: "clientName",
headerName: "Client Name",
Expand All @@ -133,7 +153,7 @@ function Leads({ type, showSidebar }) {
headerClassName: "super-app-theme--header",
width: 150,
renderCell: (params) => (
<div className={`font-primary font-light`}>{params.row?.client?.phone || params.row?.clientPhone }</div>
<div className={`font-primary font-light`}>{params.row?.client?.phone || params.row?.clientPhone}</div>
),
},
{
Expand Down Expand Up @@ -244,7 +264,7 @@ function Leads({ type, showSidebar }) {
<StyledMenuItem
className="text-gray-600 flex font-primary"
onClick={() => handleOpenShareLeadModal(params.row)}>
Share Lead
{params.row?.allocatedTo?.length > 0 ? 'Share Lead' : 'Allocate Lead'}
</StyledMenuItem>
<StyledMenuItem
className="text-gray-600 flex font-primary"
Expand All @@ -262,7 +282,7 @@ function Leads({ type, showSidebar }) {
),
},
];

const filteredColumns = () => { }
let modifiedColumns = columns;
if (role == "employee" && type == "all") {
modifiedColumns = modifiedColumns.filter((column) => column.field != "allocatedTo");
Expand All @@ -271,7 +291,6 @@ function Leads({ type, showSidebar }) {
////////////////////////////////////// STATES //////////////////////////////
const [openAttachmentModal, setOpenAttachmentModal] = useState(false);
const [openEditModal, setOpenEditModal] = useState(false);
const [openViewModal, setOpenViewModal] = useState(false);
const [openDeleteModal, setOpenDeleteModal] = useState(false);
const [openStatusModal, setOpenStatusModal] = useState(false);
const [openShiftLeadModal, setOpenShiftLeadModal] = useState(false);
Expand Down
6 changes: 4 additions & 2 deletions server/controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ export const register = async (req, res, next) => {

const newUser = await User.create({ firstName, lastName, username, email, phone, password: hashedPassword, city, role })

if(findedLead){
const updatedLead = await Lead.findByIdAndUpdate(findedLead._id, {$set: {client: newUser._id}} , { new: true }).populate('client').populate('allocatedTo').exec()
console.log('new', newUser, findedLead)
if (findedLead) {
const updated = await Lead.findByIdAndUpdate(findedLead._id, { $set: { client: newUser._id } }, { new: true }).populate('client').populate('allocatedTo').exec()
console.log('udpate', updated)
}

res.status(200).json({ result: newUser, message: 'User created successfully', success: true })
Expand Down
1 change: 1 addition & 0 deletions server/controllers/lead.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const getLeadByPhone = async (req, res, next) => {
const findedLead = await Lead.find({ client: findedUser?._id })
.populate('client')
.populate('allocatedTo')
.populate('property')
.exec();

res.status(200).json({ result: findedLead, message: 'Lead fetched successfully', success: true });
Expand Down

0 comments on commit 6dbff1a

Please sign in to comment.