Skip to content

Commit

Permalink
chore: Add profileUrl field to request schema and update request crea…
Browse files Browse the repository at this point in the history
…tion and display pages
  • Loading branch information
kvineet002 committed Aug 28, 2024
1 parent 9785402 commit a3887b6
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 81 deletions.
1 change: 1 addition & 0 deletions Backend/Models/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const requestSchema = new mongoose.Schema({
Request_sent_date: {
type: String,
},
profileUrl: String,
// "POR Position": {
// type: String,
// },
Expand Down
2 changes: 2 additions & 0 deletions Backend/controllers/requestsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ async function createRequest(req, res) {
"Sender Roll no": senderRollNo,
"Sender email": senderEmail,
"Request sent to":RequestsentTo,
profileUrl:profileUrl,
subject:subject,
body:body,
token
Expand All @@ -22,6 +23,7 @@ async function createRequest(req, res) {
"Sender Roll no": senderRollNo,
"Sender email": senderEmail,
"Request sent to":RequestsentTo,
profileUrl:profileUrl,
subject:subject,
body:body,
token
Expand Down
Binary file added Backend/uploads/220103118.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 39 additions & 25 deletions Frontend/src/Components/CheckUpdateModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function RequestDetailsModal({ isOpen, requestData, onRequestClose,SERVER_URL })
"Sender Roll no": PropTypes.string.isRequired,
"Sender email": PropTypes.string.isRequired,
"Request sent to": PropTypes.string.isRequired,
profileUrl: PropTypes.string.isRequired,
_id: PropTypes.string.isRequired,
}).isRequired,
encryptedEmail: PropTypes.string.isRequired,
Expand Down Expand Up @@ -67,8 +68,8 @@ function RequestDetailsModal({ isOpen, requestData, onRequestClose,SERVER_URL })
</div>
</div>
<div className="flex w-full mt-1 gap-1">
<div className=" w-[100%] flex p-6 bg-white shadow-[0px_1.6px_3.6px_0px_rgba(27,33,45,0.13),0px_0.3px_0.9px_0px_rgba(27,33,45,0.10)]">
<div className="w-[50%] flex flex-col gap-6">
<div className=" w-[100%] md:flex md:flex-row flex-col p-6 bg-white shadow-[0px_1.6px_3.6px_0px_rgba(27,33,45,0.13),0px_0.3px_0.9px_0px_rgba(27,33,45,0.10)]">
<div className="md:w-[50%] flex flex-col gap-6 pb-3">
<div className="flex flex-col">
<label className="text-[#353B47] text-sm">Status</label>
<div>{requestData.Status}</div>
Expand Down Expand Up @@ -102,9 +103,7 @@ function RequestDetailsModal({ isOpen, requestData, onRequestClose,SERVER_URL })
<label className="text-[#353B47] text-sm">Parent Body</label>
<div>{requestData["Parent Body"]}</div>
</div> */}
<div className=" flex gap-6">
<div>
<Modal
<Modal
isOpen={isWithdrawModalOpen}
onRequestClose={closeWithdrawModal}
className="absolute top-1/2 lg:left-[60%] left-[10%] right-[10%] lg:transform lg:-translate-x-1/2 -translate-y-1/2 bg-white p-4"
Expand Down Expand Up @@ -155,27 +154,12 @@ function RequestDetailsModal({ isOpen, requestData, onRequestClose,SERVER_URL })
</div>
</div>
</Modal>
{Status === "Pending" && (
<button
onClick={openWithdrawModal}
className="text-sm p-[5px] pl-3 pr-3 bg-[#2164E8] text-white rounded"
>
Withdraw
</button>
)}
</div>
<div>
<button
onClick={onRequestClose}
className="text-sm p-[5px] pl-3 pr-3 border border-[#767A81] rounded"
>
Go Back
</button>
</div>
</div>{" "}

</div>

<div className=" w-[50%] flex flex-col gap-6">

<div className=" w-full flex-col ">
<div className=" w-full flex-col md:flex md:flex-row">
<div className=" md:w-[50%] flex flex-col gap-6">
{/* <div className="flex flex-col">
<label className="text-[#353B47] text-sm">Request type</label>
<div>{requestData["Type of Request"]}</div>
Expand All @@ -195,9 +179,39 @@ function RequestDetailsModal({ isOpen, requestData, onRequestClose,SERVER_URL })
<div>{requestData["Request sent to"]}</div>
</div>
</div>
<div className=" md:w-[50%] flex flex-col gap-6 py-3">
{requestData.profileUrl ? (
<img src={requestData.profileUrl} alt="profile" className="w-[200px] object-cover" />
) :( <img className="w-[150px] rounded-full" src={`https://ui-avatars.com/api/?name=${requestData["Sender Name"]}&background=random&length=1`} />)}
</div>
</div>
<div className=" flex gap-6 my-3">
<div>
{Status === "Pending" && (
<button
onClick={openWithdrawModal}
className="text-sm p-[5px] pl-3 pr-3 bg-[#2164E8] text-white rounded"
>
Withdraw
</button>
)}
</div>
<div>
<button
onClick={onRequestClose}
className="text-sm p-[5px] pl-3 pr-3 border border-[#767A81] rounded"
>
Go Back
</button>
</div>
</div>


</div>
</div>

</div>

</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function AddNewRequest({ SERVER_URL }) {
UserDetails();
// eslint-disable-next-line
}, []);
console.log(user);
const handleSubmit = async () => {
try {
const response = await axios.post(`${SERVER_URL}/request`, {
Expand All @@ -75,12 +76,14 @@ function AddNewRequest({ SERVER_URL }) {
"Sender Roll no": user.roll,
"Sender email": `${decryptEmail(encryptedEmail)}@iitg.ac.in`,
Status: "Pending",
profileUrl: user.profileUrl,
"Request sent to": toemail.value,
subject: subject,
body: body,
});

console.log("Request created successfully");
console.log(response.data);
if (response.status === 201) {
navigate(
`/studentdashboard/createrequest/success?e=${encodeURIComponent(
Expand Down
22 changes: 14 additions & 8 deletions Frontend/src/Pages/Student/HistoryPage/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,20 @@ function History_Page({ SERVER_URL }) {
key={index}
className={`flex bg-white items-center shadow-[0px_1.6px_3.6px_0px_rgba(27,33,45,0.13),0px_0.3px_0.9px_0px_rgba(27,33,45,0.10)]`}
>
<div className="text-xs w-[10%] text-[#494D57] text-center py-5">
<div className="text-xs w-[10%] text-[#494D57] text-center py-3">
{sequenceNumber}
</div>
<div className="text-xs text-[#494D57] w-[25%] text-center py-5">
<div className="text-center w-[20%] py-3 flex justify-center items-center">
{data.profileUrl ? ( <img className="w-[35px] h-[35px] text-center rounded-full" src={data.profileUrl} />) : ( <img className="w-[30px] h-[30px] rounded-full" src={`https://ui-avatars.com/api/?name=${data["Sender Name"]}&background=random&length=1&rounded=true`} />)}
</div>
<div className="text-xs text-[#494D57] w-[15%] text-center py-3">
{data["Sender Name"]}
</div>

<div className="text-xs text-[#494D57] w-[25%] text-center py-5">
<div className="text-xs text-[#494D57] w-[15%] text-center py-3">
{data["Request_sent_date"]}
</div>
<div className={`text-xs text-center w-[20%] py-5 ${statusStyle}`}>
<div className={`text-xs text-center w-[20%] py-3 ${statusStyle}`}>
{data.Status}
</div>
<div
Expand Down Expand Up @@ -253,18 +256,21 @@ function History_Page({ SERVER_URL }) {
</div>
<div className=" w-full overflow-scroll no-scrollbar">
<div className=" flex flex-col gap-[3px] lg:w-full w-[720px]">
<div className=" flex mt-4 bg-[#E8E9EA] items-center shadow-[0px_1.6px_3.6px_0px_rgba(27,33,45,0.13),0px_0.3px_0.9px_0px_rgba(27,33,45,0.10)]">
<div className=" flex mt-4 bg-[#E8E9EA] items-center shadow-[0px_1.6px_3.6px_0px_rgba(27,33,45,0.13),0px_0.3px_0.9px_0px_rgba(27,33,45,0.10)]">
<div className=" text-sm w-[10%] text-center py-3">
Sl. No.
</div>
<div className=" text-sm w-[25%] justify-center gap-[3px] flex items-center py-3">
<div className=" text-sm w-[20%] justify-center gap-[3px] flex items-center py-3">
{"Profile"}
</div>
<div className=" text-sm w-[15%] justify-center gap-[3px] flex items-center py-3">
{"Sender's Name"}
<img src={sort} />
</div>

<div className=" text-sm w-[25%] justify-center gap-[3px] flex items-center py-3">
<div className=" text-sm w-[15%] justify-center gap-[3px] flex items-center py-3">
Date
<img src={Arrow_sort}/>
<img src={Arrow_sort} />
</div>
<div className=" text-sm w-[20%] text-center py-3">
Status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function RequestDetailsModal({ isOpen,onRequestClose, requestData, SERVER_URL })
"Sender Roll no": PropTypes.string.isRequired,
"Sender email": PropTypes.string.isRequired,
"Request sent to": PropTypes.string.isRequired,
profileUrl: PropTypes.string.isRequired,
_id: PropTypes.string.isRequired,
}).isRequired,
};
Expand Down Expand Up @@ -83,8 +84,8 @@ function RequestDetailsModal({ isOpen,onRequestClose, requestData, SERVER_URL })
<div className=" text-lg font-semibold ">{requestData["Sender Name"]}{"'s request recieved"}</div>
</div>
<div className="flex w-full mt-1 gap-1">
<div className=" w-[100%] flex p-6 bg-white shadow-[0px_1.6px_3.6px_0px_rgba(27,33,45,0.13),0px_0.3px_0.9px_0px_rgba(27,33,45,0.10)]">
<div className="w-[50%] flex flex-col gap-6">
<div className=" w-[100%] md:flex md:flex-row flex-col p-6 bg-white shadow-[0px_1.6px_3.6px_0px_rgba(27,33,45,0.13),0px_0.3px_0.9px_0px_rgba(27,33,45,0.10)]">
<div className=" md:w-[50%] flex flex-col pb-3 gap-6">
<div className="flex flex-col">
<label className="text-[#353B47] text-sm">Status</label>
<div>{requestData.Status}</div>
Expand All @@ -101,7 +102,6 @@ function RequestDetailsModal({ isOpen,onRequestClose, requestData, SERVER_URL })
<label className="text-[#353B47] text-sm">Body</label>
<div>{requestData["body"]}</div>
</div>
<div className=" flex gap-4 lg:mt-0 mt-16">
<Modal
isOpen={isApproveModalOpen}
onRequestClose={closeApproveModal}
Expand Down Expand Up @@ -129,31 +129,6 @@ function RequestDetailsModal({ isOpen,onRequestClose, requestData, SERVER_URL })
</div>
</div>
</Modal>
{Status === "Pending" && (
<button
onClick={openApproveModal}
className="text-sm p-[5px] px-4 bg-[#2164E8] text-white rounded"
>
Approve
</button>
)}
{Status === "Pending" && (
<button
onClick={openDenyModal}
className="text-sm p-[5px] px-4 border border-[#767A81] rounded"
>
Deny
</button>
)}
<div>
<button
onClick={onRequestClose}
className="text-sm p-[5px] pl-3 pr-3 border border-[#767A81] rounded"
>
Go Back
</button>
</div>

<Modal
isOpen={isDenyModalOpen}
onRequestClose={closeDenyModal}
Expand Down Expand Up @@ -182,16 +157,20 @@ function RequestDetailsModal({ isOpen,onRequestClose, requestData, SERVER_URL })
</div>
</div>
</Modal>
</div>
</div>

<div className=" w-[50%] flex flex-col gap-6">
<div className=" w-full flex-col ">
<div className=" w-full flex-col md:flex md:flex-row">
<div className=" md:w-[50%] flex flex-col gap-6">
{/* <div className="flex flex-col">
<label className="text-[#353B47] text-sm">Request type</label>
<div>{requestData["Type of Request"]}</div>
</div> */}
<div className="flex flex-col">
<label className="text-[#353B47] text-sm">Sender Roll no</label>
<label className="text-[#353B47] text-sm">{"Sender's Roll no"}</label>
<div>{requestData["Sender Roll no"]}</div>
</div>
<div className="flex flex-col">
<label className="text-[#353B47] text-sm">Sender Mail Id</label>
<label className="text-[#353B47] text-sm">{"Sender's Mail Id"}</label>
<div>{requestData["Sender email"]}</div>
</div>
<div className="flex flex-col">
Expand All @@ -201,6 +180,41 @@ function RequestDetailsModal({ isOpen,onRequestClose, requestData, SERVER_URL })
<div>{requestData["Request sent to"]}</div>
</div>
</div>
<div className=" md:w-[50%] flex flex-col gap-6 pt-5">
{requestData.profileUrl ? (
<img src={requestData.profileUrl} alt="profile" className="w-[200px] object-cover" />
) :( <img className="w-[150px] rounded-full" src={`https://ui-avatars.com/api/?name=${requestData["Sender Name"]}&background=random&length=1`} />)}
</div>
</div>
<div className=" flex gap-4 lg:mt-0 mt-5">
{Status === "Pending" && (
<button
onClick={openApproveModal}
className="text-sm p-[5px] px-4 bg-[#2164E8] text-white rounded"
>
Approve
</button>
)}
{Status === "Pending" && (
<button
onClick={openDenyModal}
className="text-sm p-[5px] px-4 border border-[#767A81] rounded"
>
Deny
</button>
)}
<div>
<button
onClick={onRequestClose}
className="text-sm p-[5px] pl-3 pr-3 border border-[#767A81] rounded"
>
Go Back
</button>
</div>


</div>
</div>
</div>
</div>
</div>
Expand Down
22 changes: 14 additions & 8 deletions Frontend/src/Pages/Student/RequestReceivdPage/RequestReceived.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,20 @@ function RequestReceived({ SERVER_URL }) {
key={index}
className={`flex bg-white items-center shadow-[0px_1.6px_3.6px_0px_rgba(27,33,45,0.13),0px_0.3px_0.9px_0px_rgba(27,33,45,0.10)]`}
>
<div className="text-xs text-[#494D57] w-[10%] text-center py-5">
<div className="text-xs w-[10%] text-[#494D57] text-center py-3">
{sequenceNumber}
</div>

<div className="text-xs text-[#494D57] w-[25%] text-center py-5">
<div className="text-center w-[20%] py-3 flex justify-center items-center">
{data.profileUrl ? ( <img className="w-[35px] h-[35px] text-center rounded-full" src={data.profileUrl} />) : ( <img className="w-[30px] h-[30px] rounded-full" src={`https://ui-avatars.com/api/?name=${data["Sender Name"]}&background=random&length=1&rounded=true`} />)}
</div>
<div className="text-xs text-[#494D57] w-[15%] text-center py-3">
{data["Sender Name"]}
</div>
<div className="text-xs text-[#494D57] w-[25%] text-center py-5">
{data.Request_sent_date}

<div className="text-xs text-[#494D57] w-[15%] text-center py-3">
{data["Request_sent_date"]}
</div>
<div className={`text-xs text-center w-[20%] py-5 ${statusStyle}`}>
<div className={`text-xs text-center w-[20%] py-3 ${statusStyle}`}>
{data.Status}
</div>

Expand Down Expand Up @@ -281,10 +284,13 @@ function RequestReceived({ SERVER_URL }) {
<div className=" text-sm w-[10%] text-center py-3">
Sl. No.
</div>
<div className=" text-sm w-[25%] text-center py-3">
<div className=" text-sm w-[20%] text-center py-3">
Profile
</div>
<div className=" text-sm w-[15%] text-center py-3">
Request Sender
</div>
<div className=" text-sm w-[25%] justify-center gap-[3px] flex items-center py-3">
<div className=" text-sm w-[15%] justify-center gap-[3px] flex items-center py-3">
Date
<img src={Arrow_sort} />
</div>
Expand Down
Loading

0 comments on commit a3887b6

Please sign in to comment.