Commit a3686902 authored by Weerasinghe D.N.H's avatar Weerasinghe D.N.H

FRONTEND : Student components updated

parent bf761743
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -18,29 +18,23 @@ import ProfilePicture from "../assets/images/admin-user-img.jpg"; ...@@ -18,29 +18,23 @@ import ProfilePicture from "../assets/images/admin-user-img.jpg";
import status from "../helpers/greeting"; import status from "../helpers/greeting";
const SupplierDashboard = () => { const StudentDashboard = () => {
const [error, setError] = useState(""); const [error, setError] = useState("");
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const [orderDetails, setOrderDetails] = useState([]); const [StudentSubjects, setStudentSubjects] = useState([]);
const [value, onChange] = useState(new Date()); const [value, onChange] = useState(new Date());
const fields = [ const fields = ["", "Assignment", "Subject", "Subject Code"];
"",
"Assignment",
"Subject",
"Subject Code",
];
const subjects = [ const subjects = [
{ ModuleCode: "IT20300", ModuleName: "CTSE", assign: "Assignment 01" }, { ModuleCode: "IT20300", ModuleName: "CTSE", assign: "Assignment 01" },
{ ModuleCode: "IT30300", ModuleName: "DMS", assign: "Assignment 02" }, { ModuleCode: "IT30300", ModuleName: "DMS", assign: "Assignment 02" },
{ ModuleCode: "IT40300", ModuleName: "SPM", assign: "Assignment 03" } { ModuleCode: "IT40300", ModuleName: "SPM", assign: "Assignment 03" },
] ];
const renderOrderHead = (item, index) => <th key={index}>{item}</th>; const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
const renderOrderBody = (item, index) => ( const renderOrderBody = (item, index) => (
<tr key={index}> <tr key={index}>
<td>{ }</td> <td>{}</td>
<td>{item.assign}</td> <td>{item.assign}</td>
<td>{item.ModuleName}</td> <td>{item.ModuleName}</td>
<td>{item.ModuleCode}</td> <td>{item.ModuleCode}</td>
...@@ -64,17 +58,17 @@ const SupplierDashboard = () => { ...@@ -64,17 +58,17 @@ const SupplierDashboard = () => {
</tr> </tr>
); );
const getAllOrders = async () => { const getAllSubjects = async () => {
try { try {
const res = await axios.get("orders/supplier/my"); const res = await axios.get("/subjects");
setOrderDetails(res.data.orders); setStudentSubjects(subjects);
setIsLoading(false); setIsLoading(false);
} catch (err) { } catch (err) {
console.log(err.response); console.log(err.response);
} }
}; };
useEffect(() => getAllOrders(), []); useEffect(() => getAllSubjects(), []);
return ( return (
<div> <div>
...@@ -91,16 +85,16 @@ const SupplierDashboard = () => { ...@@ -91,16 +85,16 @@ const SupplierDashboard = () => {
<h3> <h3>
Today you have{" "} Today you have{" "}
{ {
orderDetails.filter( StudentSubjects.filter(
(orderDetail) => (StudentSubject) =>
orderDetail.DeliveryStatus === "pending" StudentSubject.stubjectstatus === "pending"
).length ).length
} }
{localStorage.setItem( {localStorage.setItem(
"notifications", "notifications",
orderDetails.filter( StudentSubjects.filter(
(orderDetail) => (StudentSubject) =>
orderDetail.DeliveryStatus === "pending" StudentSubject.stubjectstatus === "pending"
).length ).length
)}{" "} )}{" "}
Assignments to Complete Assignments to Complete
...@@ -140,18 +134,17 @@ const SupplierDashboard = () => { ...@@ -140,18 +134,17 @@ const SupplierDashboard = () => {
<div className="card"> <div className="card">
<div className="flex"> <div className="flex">
<h2 className="request-title">Assignments to complete</h2> <h2 className="request-title">Assignments to complete</h2>
</div> </div>
{/* {isLoading ? ( {/* {isLoading ? (
<Spinner /> <Spinner />
) : orderDetails.length > 0 ? ( */} ) : orderDetails.length > 0 ? ( */}
<Table <Table
limit="5" limit="5"
headData={fields} headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)} renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={subjects} bodyData={subjects}
renderBody={(item, index) => renderOrderBody(item, index)} renderBody={(item, index) => renderOrderBody(item, index)}
/> />
{/* ) : ( {/* ) : (
<> <>
{setError("No Assignments found")} {setError("No Assignments found")}
...@@ -184,4 +177,4 @@ const SupplierDashboard = () => { ...@@ -184,4 +177,4 @@ const SupplierDashboard = () => {
); );
}; };
export default SupplierDashboard; export default StudentDashboard;
...@@ -5,34 +5,41 @@ import TopNav from "../components/topnav/TopNav"; ...@@ -5,34 +5,41 @@ import TopNav from "../components/topnav/TopNav";
import Table from "../components/table/Table"; import Table from "../components/table/Table";
import Badge from "../components/badge/Badge"; import Badge from "../components/badge/Badge";
import Spinner from "../components/loading/Spinner"; import Spinner from "../components/loading/Spinner";
import { MdDelete } from "react-icons/md" import { MdDelete } from "react-icons/md";
import { VscReport } from "react-icons/vsc" import { VscReport } from "react-icons/vsc";
import Popup from "./Popup"; import Popup from "./Popup";
const SiteManagerForm = () => { const StudentSubjectAssingment = () => {
const siteId = localStorage.getItem("site"); const siteId = localStorage.getItem("site");
const [Materials, setMaterials] = useState([]); const [Materials, setMaterials] = useState([]);
const fields = ["", "Required Date", "Item", "Quantity", "Order Status", "Delivery Status", "Action", "Goods Receipt"]; const fields = [
const [OrderDetail, setOrderDetail] = useState([]) "",
"Required Date",
"Item",
"Quantity",
"Order Status",
"Delivery Status",
"Action",
"Goods Receipt",
];
const [OrderDetail, setOrderDetail] = useState([]);
const [Loading, setLoading] = useState(false); const [Loading, setLoading] = useState(false);
const [Trigger, setTrigger] = useState(false); const [Trigger, setTrigger] = useState(false);
const [Name, setName] = useState(""); const [Name, setName] = useState("");
const [Id, setId] = useState(""); const [Id, setId] = useState("");
const [ItemName, setItemName] = useState("") const [ItemName, setItemName] = useState("");
const [Description, setDescription] = useState("") const [Description, setDescription] = useState("");
const [Order, setOrder] = useState({ const [Order, setOrder] = useState({
item: {}, item: {},
quantity: 0, quantity: 0,
siteid: siteId, siteid: siteId,
requiredDate: "", requiredDate: "",
urgentOrder: false urgentOrder: false,
}); });
console.log(Order); console.log(Order);
const FetchData = async () => { const FetchData = async () => {
const resMaterials = await axios.get(`materials`); const resMaterials = await axios.get(`materials`);
setMaterials(resMaterials.data.materials); setMaterials(resMaterials.data.materials);
...@@ -40,13 +47,11 @@ const SiteManagerForm = () => { ...@@ -40,13 +47,11 @@ const SiteManagerForm = () => {
setOrderDetail(resOrders.data.orders); setOrderDetail(resOrders.data.orders);
if (resOrders.statusText === "OK") { if (resOrders.statusText === "OK") {
setLoading(true) setLoading(true);
} }
}; };
useEffect(() => { useEffect(() => {
FetchData(); FetchData();
}, []); }, []);
...@@ -55,7 +60,7 @@ const SiteManagerForm = () => { ...@@ -55,7 +60,7 @@ const SiteManagerForm = () => {
try { try {
const res = await axios.delete(`/orders/delete/${id}`); const res = await axios.delete(`/orders/delete/${id}`);
if (res.statusText === "OK") { if (res.statusText === "OK") {
window.location.reload() window.location.reload();
} }
} catch (Err) { } catch (Err) {
console.log(Err.response); console.log(Err.response);
...@@ -67,7 +72,7 @@ const SiteManagerForm = () => { ...@@ -67,7 +72,7 @@ const SiteManagerForm = () => {
console.log(Order); console.log(Order);
const res = await axios.post("/orders", Order); const res = await axios.post("/orders", Order);
if (res.statusText === "OK") { if (res.statusText === "OK") {
window.location.reload() window.location.reload();
} }
} catch (Err) { } catch (Err) {
console.log(Err.response); console.log(Err.response);
...@@ -99,23 +104,28 @@ const SiteManagerForm = () => { ...@@ -99,23 +104,28 @@ const SiteManagerForm = () => {
</td> </td>
<td> <td>
<div className="row-user" style={{ paddingTop: "0" }}> <div className="row-user" style={{ paddingTop: "0" }}>
{item.isApprovedByManager === "approved" ? (item.DeliveryStatus === "pending" ? ( {item.isApprovedByManager === "approved" ? (
<Badge type="warning" content={item.DeliveryStatus} /> item.DeliveryStatus === "pending" ? (
) : item.DeliveryStatus === "preparing" ? ( <Badge type="warning" content={item.DeliveryStatus} />
<Badge type="primary" content={item.DeliveryStatus} /> ) : item.DeliveryStatus === "preparing" ? (
) : item.DeliveryStatus === "delivering" ? ( <Badge type="primary" content={item.DeliveryStatus} />
<Badge type="success" content={item.DeliveryStatus} /> ) : item.DeliveryStatus === "delivering" ? (
) : item.DeliveryStatus === "delivered" ? ( <Badge type="success" content={item.DeliveryStatus} />
<Badge type="success" content={item.DeliveryStatus} /> ) : item.DeliveryStatus === "delivered" ? (
) : item.DeliveryStatus === "submitted" ? ( <Badge type="success" content={item.DeliveryStatus} />
<Badge type="normal" content={item.DeliveryStatus} /> ) : item.DeliveryStatus === "submitted" ? (
<Badge type="normal" content={item.DeliveryStatus} />
) : (
""
)
) : ( ) : (
"" ""
)) : ""} )}
</div> </div>
</td> </td>
<td className=""> <td className="">
{item.isApprovedByManager === "pending" && !(item.isApprovedByOfficer === "rejected") ? ( {item.isApprovedByManager === "pending" &&
!(item.isApprovedByOfficer === "rejected") ? (
<> <>
<button className="action-btn x"> <button className="action-btn x">
<MdDelete <MdDelete
...@@ -127,18 +137,17 @@ const SiteManagerForm = () => { ...@@ -127,18 +137,17 @@ const SiteManagerForm = () => {
/> />
</button> </button>
</> </>
) : item.isApprovedByManager === "rejected" || item.isApprovedByOfficer === "rejected" ? ( ) : item.isApprovedByManager === "rejected" ||
item.isApprovedByOfficer === "rejected" ? (
<> <>
<button className="action-btn W"> <button className="action-btn W">
<VscReport <VscReport
onClick={() => { onClick={() => {
setName("Rejection") setName("Rejection");
setDescription(item.rejectMassage) setDescription(item.rejectMassage);
setTrigger(true) setTrigger(true);
}} }}
/> />
</button> </button>
<Popup <Popup
trigger={Trigger} trigger={Trigger}
...@@ -149,32 +158,29 @@ const SiteManagerForm = () => { ...@@ -149,32 +158,29 @@ const SiteManagerForm = () => {
item={ItemName} item={ItemName}
/> />
</> </>
) : ""} ) : (
""
)}
</td> </td>
<td> <td>
{item.DeliveryStatus === "submitted" ? ( {item.DeliveryStatus === "submitted" ? (
<div
onClick={() => {
<div onClick={() => { setName("GoodsReceipt");
setName("GoodsReceipt") setId(item._id);
setId(item._id) setItemName(item.itemName);
setItemName(item.itemName) setTrigger(true);
setTrigger(true) }}
}}> >
<Badge type="normal" content="view" <Badge type="normal" content="view" />
/>
</div> </div>
) : (
) : "" ""
)}
}
</td> </td>
</tr> </tr>
); );
return ( return (
<div> <div>
<Sidebar /> <Sidebar />
...@@ -189,35 +195,48 @@ const SiteManagerForm = () => { ...@@ -189,35 +195,48 @@ const SiteManagerForm = () => {
<h2 className="request-title">Asignment 01</h2> <h2 className="request-title">Asignment 01</h2>
</div> </div>
<br /> <br />
<h3>Analyze the case study given below and draw a usecase diagram. <h3>
Analyze the case study given below and draw a usecase diagram.
</h3> </h3>
<br /> <br />
<p> <p>
GlamourFashions (GF) is a clothing store situated in Colombo and its planning to build an GlamourFashions (GF) is a clothing store situated in Colombo
online shopping system to promote their sales further. The management of clothing store and its planning to build an online shopping system to
hired you as a System Analyst and asked to come up with the design models for promote their sales further. The management of clothing store
GlamourFashions Online Store (GFOS). hired you as a System Analyst and asked to come up with the
GlamourFashions (GF) Online Clothing Store is expected to organize clothing items under design models for GlamourFashions Online Store (GFOS).
several categories like office wear, casual wear, evening wear and so on. A visitor can browse GlamourFashions (GF) Online Clothing Store is expected to
on items without being registering to the system. If he/she likes to order item, the system organize clothing items under several categories like office
facilitates to add selected items into the shopping cart and directly move to checkout option. wear, casual wear, evening wear and so on. A visitor can
If the user interested to be a regular user, the system will provide registration facility as browse on items without being registering to the system. If
well. Without even registering, the user can directly go for the checkout. he/she likes to order item, the system facilitates to add
For a registered user, the system is expected to send a promotion code for users mobile every selected items into the shopping cart and directly move to
month which can be used only once. when the user logs into the system to do online checkout option. If the user interested to be a regular user,
shopping, user can enter this code which will give a 5% discount for the order he/she makes. the system will provide registration facility as well.
If the user does not use the code within the month, automatically the system must discard Without even registering, the user can directly go for the
promotion code. If its been already used, the system must display a message saying its checkout. For a registered user, the system is expected to
already been used. After adding the items into a shopping cart, user can select the checkout send a promotion code for users mobile every month which can
button which gives two payment options, Cash on Delivery or Pay by Card. be used only once. when the user logs into the system to do
Once the user goes to the payment option, the system will display details about the order the online shopping, user can enter this code which will give a 5%
customer has made. It will display the order number, each item details with an image of discount for the order he/she makes. If the user does not use
clothing item, total amount to be paid. If any item needs to be removed from the current the code within the month, automatically the system must
order system will facilitate it as well. Finally, the system will ask user to enter delivery details discard promotion code. If its been already used, the
including any comments which is optional. Based on the location to be delivered it will system must display a message saying its already been used.
indicate the delivery cost and final amount to be paid for the order. The according to user After adding the items into a shopping cart, user can select
preferences, Cash on Delivery or Pay by Card can be selected. If the user provides credit or the checkout button which gives two payment options, Cash on
debit card details, card information will be verified using a payment gateway. Delivery or Pay by Card. Once the user goes to the payment
option, the system will display details about the order the
customer has made. It will display the order number, each item
details with an image of clothing item, total amount to be
paid. If any item needs to be removed from the current order
system will facilitate it as well. Finally, the system will
ask user to enter delivery details including any comments
which is optional. Based on the location to be delivered it
will indicate the delivery cost and final amount to be paid
for the order. The according to user preferences, Cash on
Delivery or Pay by Card can be selected. If the user provides
credit or debit card details, card information will be
verified using a payment gateway.
</p> </p>
</div> </div>
</div> </div>
...@@ -226,7 +245,6 @@ const SiteManagerForm = () => { ...@@ -226,7 +245,6 @@ const SiteManagerForm = () => {
<div className="col-12"> <div className="col-12">
<div className="card"> <div className="card">
<div className="row "> <div className="row ">
<div className="col-6"> <div className="col-6">
<div className="row-user"> <div className="row-user">
<input <input
...@@ -244,17 +262,13 @@ const SiteManagerForm = () => { ...@@ -244,17 +262,13 @@ const SiteManagerForm = () => {
<button type="submit">Submit</button> <button type="submit">Submit</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
); );
}; };
export default SiteManagerForm; export default StudentSubjectAssingment;
...@@ -11,155 +11,44 @@ import Badge from "../components/badge/Badge"; ...@@ -11,155 +11,44 @@ import Badge from "../components/badge/Badge";
import "../assets/css/Usercreate.css"; import "../assets/css/Usercreate.css";
const ManageOrdersSupplier = () => { const SubjectsStudent = () => {
const [error, setError] = useState(""); const [error, setError] = useState("");
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const [orderDetails, setOrderDetails] = useState([]); const [SudentSubjects, setSudentSubjects] = useState([]);
const fields = [ const fields = ["", "Module Code", "Module Name", "Year", "", "Actions"];
"",
"Module Code",
"Module Name",
"Year",
"",
"Actions",
];
const subjects = [ const subjects = [
{ ModuleCode: "IT20300", ModuleName: "CTSE", Year: "4th Year" }, { ModuleCode: "IT20300", ModuleName: "CTSE", Year: "4th Year" },
{ ModuleCode: "IT30300", ModuleName: "DMS", Year: "4th Year" }, { ModuleCode: "IT30300", ModuleName: "DMS", Year: "4th Year" },
{ ModuleCode: "IT40300", ModuleName: "SPM:", Year: "4th Year" } { ModuleCode: "IT40300", ModuleName: "SPM:", Year: "4th Year" },
] ];
const renderOrderHead = (item, index) => <th key={index}>{item}</th>; const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
const renderOrderBody = (item, index) => ( const renderOrderBody = (item, index) => (
<tr key={index}> <tr key={index}>
<td>{ }</td> <td>{}</td>
<td>{item.ModuleCode}</td> <td>{item.ModuleCode}</td>
<td>{item.ModuleName}</td> <td>{item.ModuleName}</td>
<td>{item.Year}</td> <td>{item.Year}</td>
<td>{ }</td> <td>{}</td>
<td><Link to={`/auth/student/assignment`}>
<button className="view-btn">View</button>
</Link></td>
<td> <td>
<div className="row-user" style={{ paddingTop: "0" }}> <Link to={`/auth/student/assignment`}>
{item.DeliveryStatus === "pending" ? ( <button className="view-btn">View</button>
<div </Link>
style={{ cursor: "pointer" }}
onClick={() => {
if (
window.confirm(
"Are you sure to change order status as preparing?"
)
) {
changeDeliveryStatusAsPreparing(item._id);
}
}}
>
<Badge type="warning" content="Mark as preparing" />
</div>
) : item.DeliveryStatus === "preparing" ? (
<div
style={{ cursor: "pointer" }}
onClick={() => {
if (
window.confirm(
"Are you sure to change order status as delivering?"
)
) {
changeDeliveryStatusAsDelivering(item._id);
}
}}
>
<Badge type="primary" content="Mark as delivering" />
</div>
) : item.DeliveryStatus === "delivering" ? (
<div
style={{ cursor: "pointer" }}
onClick={() => {
if (
window.confirm(
"Are you sure to change order status as delivered?"
)
) {
changeDeliveryStatusAsDelivered(item._id);
}
}}
>
<Badge type="success" content="Mark as delivered" />
</div>
) : item.DeliveryStatus === "delivered" ? (
<div style={{ cursor: "pointer" }}>
<Link to={`/auth/supplier/deliveryreports/${item._id}`}>
<Badge type="normal" content="Send Delivery Report" />
</Link>
</div>
) : item.DeliveryStatus === "submitted" ? (
<div>
<Badge type="normal" content="Completed" />
</div>
) : (
""
)}
</div>
</td> </td>
</tr> </tr>
); );
const changeDeliveryStatusAsPreparing = async (id) => { const getAllSubjects = async () => {
try {
const res = await axios.put(`orders/supplier/prepare/${id}`);
if (res.statusText === "OK") {
setIsLoading(true);
getAllOrders();
setError("");
window.alert("Delivery status changed as preparing");
window.location.reload();
setIsLoading(false);
}
} catch (err) {
console.log(err.response);
}
};
const changeDeliveryStatusAsDelivering = async (id) => {
try {
const res = await axios.put(`orders/supplier/deliver/${id}`);
if (res.statusText === "OK") {
getAllOrders();
setIsLoading(false);
window.alert("Delivery status changed as delivering");
window.location.reload();
}
} catch (err) {
console.log(err.response);
}
};
const changeDeliveryStatusAsDelivered = async (id) => {
try {
const res = await axios.put(`orders/supplier/delivered/${id}`);
if (res.statusText === "OK") {
getAllOrders();
window.alert("Delivery status changed as delivered");
setIsLoading(false);
window.location.reload();
}
} catch (err) {
console.log(err.response);
}
};
const getAllOrders = async () => {
try { try {
const res = await axios.get("orders/supplier"); const res = await axios.get("/subjects");
setOrderDetails(res.data.orders); setSudentSubjects(res.data.orders);
setIsLoading(false); setIsLoading(false);
} catch (err) { } catch (err) {
console.log(err.response); console.log(err.response);
} }
}; };
useEffect(() => getAllOrders(), []); useEffect(() => getAllSubjects(), []);
return ( return (
<div> <div>
...@@ -193,4 +82,4 @@ const ManageOrdersSupplier = () => { ...@@ -193,4 +82,4 @@ const ManageOrdersSupplier = () => {
); );
}; };
export default ManageOrdersSupplier; export default SubjectsStudent;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment