Commit 704c5c1a authored by Weerasinghe D.N.H's avatar Weerasinghe D.N.H

Merge branch 'IT19070704' into 'master'

FRONTEND : Student components updated

See merge request !99
parents 82e05909 a3686902
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";
import status from "../helpers/greeting";
const SupplierDashboard = () => {
const StudentDashboard = () => {
const [error, setError] = useState("");
const [isLoading, setIsLoading] = useState(true);
const [orderDetails, setOrderDetails] = useState([]);
const [StudentSubjects, setStudentSubjects] = useState([]);
const [value, onChange] = useState(new Date());
const fields = [
"",
"Assignment",
"Subject",
"Subject Code",
];
const fields = ["", "Assignment", "Subject", "Subject Code"];
const subjects = [
{ ModuleCode: "IT20300", ModuleName: "CTSE", assign: "Assignment 01" },
{ 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 renderOrderBody = (item, index) => (
<tr key={index}>
<td>{ }</td>
<td>{}</td>
<td>{item.assign}</td>
<td>{item.ModuleName}</td>
<td>{item.ModuleCode}</td>
......@@ -64,17 +58,17 @@ const SupplierDashboard = () => {
</tr>
);
const getAllOrders = async () => {
const getAllSubjects = async () => {
try {
const res = await axios.get("orders/supplier/my");
setOrderDetails(res.data.orders);
const res = await axios.get("/subjects");
setStudentSubjects(subjects);
setIsLoading(false);
} catch (err) {
console.log(err.response);
}
};
useEffect(() => getAllOrders(), []);
useEffect(() => getAllSubjects(), []);
return (
<div>
......@@ -91,16 +85,16 @@ const SupplierDashboard = () => {
<h3>
Today you have{" "}
{
orderDetails.filter(
(orderDetail) =>
orderDetail.DeliveryStatus === "pending"
StudentSubjects.filter(
(StudentSubject) =>
StudentSubject.stubjectstatus === "pending"
).length
}
{localStorage.setItem(
"notifications",
orderDetails.filter(
(orderDetail) =>
orderDetail.DeliveryStatus === "pending"
StudentSubjects.filter(
(StudentSubject) =>
StudentSubject.stubjectstatus === "pending"
).length
)}{" "}
Assignments to Complete
......@@ -140,18 +134,17 @@ const SupplierDashboard = () => {
<div className="card">
<div className="flex">
<h2 className="request-title">Assignments to complete</h2>
</div>
{/* {isLoading ? (
<Spinner />
) : orderDetails.length > 0 ? ( */}
<Table
limit="5"
headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={subjects}
renderBody={(item, index) => renderOrderBody(item, index)}
/>
<Table
limit="5"
headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={subjects}
renderBody={(item, index) => renderOrderBody(item, index)}
/>
{/* ) : (
<>
{setError("No Assignments found")}
......@@ -184,4 +177,4 @@ const SupplierDashboard = () => {
);
};
export default SupplierDashboard;
export default StudentDashboard;
......@@ -5,34 +5,41 @@ import TopNav from "../components/topnav/TopNav";
import Table from "../components/table/Table";
import Badge from "../components/badge/Badge";
import Spinner from "../components/loading/Spinner";
import { MdDelete } from "react-icons/md"
import { VscReport } from "react-icons/vsc"
import { MdDelete } from "react-icons/md";
import { VscReport } from "react-icons/vsc";
import Popup from "./Popup";
const SiteManagerForm = () => {
const StudentSubjectAssingment = () => {
const siteId = localStorage.getItem("site");
const [Materials, setMaterials] = useState([]);
const fields = ["", "Required Date", "Item", "Quantity", "Order Status", "Delivery Status", "Action", "Goods Receipt"];
const [OrderDetail, setOrderDetail] = useState([])
const fields = [
"",
"Required Date",
"Item",
"Quantity",
"Order Status",
"Delivery Status",
"Action",
"Goods Receipt",
];
const [OrderDetail, setOrderDetail] = useState([]);
const [Loading, setLoading] = useState(false);
const [Trigger, setTrigger] = useState(false);
const [Name, setName] = useState("");
const [Id, setId] = useState("");
const [ItemName, setItemName] = useState("")
const [Description, setDescription] = useState("")
const [ItemName, setItemName] = useState("");
const [Description, setDescription] = useState("");
const [Order, setOrder] = useState({
item: {},
quantity: 0,
siteid: siteId,
requiredDate: "",
urgentOrder: false
urgentOrder: false,
});
console.log(Order);
const FetchData = async () => {
const resMaterials = await axios.get(`materials`);
setMaterials(resMaterials.data.materials);
......@@ -40,13 +47,11 @@ const SiteManagerForm = () => {
setOrderDetail(resOrders.data.orders);
if (resOrders.statusText === "OK") {
setLoading(true)
setLoading(true);
}
};
useEffect(() => {
FetchData();
}, []);
......@@ -55,7 +60,7 @@ const SiteManagerForm = () => {
try {
const res = await axios.delete(`/orders/delete/${id}`);
if (res.statusText === "OK") {
window.location.reload()
window.location.reload();
}
} catch (Err) {
console.log(Err.response);
......@@ -67,7 +72,7 @@ const SiteManagerForm = () => {
console.log(Order);
const res = await axios.post("/orders", Order);
if (res.statusText === "OK") {
window.location.reload()
window.location.reload();
}
} catch (Err) {
console.log(Err.response);
......@@ -99,23 +104,28 @@ const SiteManagerForm = () => {
</td>
<td>
<div className="row-user" style={{ paddingTop: "0" }}>
{item.isApprovedByManager === "approved" ? (item.DeliveryStatus === "pending" ? (
<Badge type="warning" content={item.DeliveryStatus} />
) : item.DeliveryStatus === "preparing" ? (
<Badge type="primary" content={item.DeliveryStatus} />
) : item.DeliveryStatus === "delivering" ? (
<Badge type="success" content={item.DeliveryStatus} />
) : item.DeliveryStatus === "delivered" ? (
<Badge type="success" content={item.DeliveryStatus} />
) : item.DeliveryStatus === "submitted" ? (
<Badge type="normal" content={item.DeliveryStatus} />
{item.isApprovedByManager === "approved" ? (
item.DeliveryStatus === "pending" ? (
<Badge type="warning" content={item.DeliveryStatus} />
) : item.DeliveryStatus === "preparing" ? (
<Badge type="primary" content={item.DeliveryStatus} />
) : item.DeliveryStatus === "delivering" ? (
<Badge type="success" content={item.DeliveryStatus} />
) : item.DeliveryStatus === "delivered" ? (
<Badge type="success" content={item.DeliveryStatus} />
) : item.DeliveryStatus === "submitted" ? (
<Badge type="normal" content={item.DeliveryStatus} />
) : (
""
)
) : (
""
)) : ""}
)}
</div>
</td>
<td className="">
{item.isApprovedByManager === "pending" && !(item.isApprovedByOfficer === "rejected") ? (
{item.isApprovedByManager === "pending" &&
!(item.isApprovedByOfficer === "rejected") ? (
<>
<button className="action-btn x">
<MdDelete
......@@ -127,18 +137,17 @@ const SiteManagerForm = () => {
/>
</button>
</>
) : item.isApprovedByManager === "rejected" || item.isApprovedByOfficer === "rejected" ? (
) : item.isApprovedByManager === "rejected" ||
item.isApprovedByOfficer === "rejected" ? (
<>
<button className="action-btn W">
<VscReport
onClick={() => {
setName("Rejection")
setDescription(item.rejectMassage)
setTrigger(true)
setName("Rejection");
setDescription(item.rejectMassage);
setTrigger(true);
}}
/>
</button>
<Popup
trigger={Trigger}
......@@ -149,32 +158,29 @@ const SiteManagerForm = () => {
item={ItemName}
/>
</>
) : ""}
) : (
""
)}
</td>
<td>
{item.DeliveryStatus === "submitted" ? (
<div onClick={() => {
setName("GoodsReceipt")
setId(item._id)
setItemName(item.itemName)
setTrigger(true)
}}>
<Badge type="normal" content="view"
/>
<div
onClick={() => {
setName("GoodsReceipt");
setId(item._id);
setItemName(item.itemName);
setTrigger(true);
}}
>
<Badge type="normal" content="view" />
</div>
) : ""
}
) : (
""
)}
</td>
</tr>
);
return (
<div>
<Sidebar />
......@@ -189,35 +195,48 @@ const SiteManagerForm = () => {
<h2 className="request-title">Asignment 01</h2>
</div>
<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>
<br />
<p>
GlamourFashions (GF) is a clothing store situated in Colombo and its planning to build an
online shopping system to promote their sales further. The management of clothing store
hired you as a System Analyst and asked to come up with the design models for
GlamourFashions Online Store (GFOS).
GlamourFashions (GF) Online Clothing Store is expected to organize clothing items under
several categories like office wear, casual wear, evening wear and so on. A visitor can browse
on items without being registering to the system. If he/she likes to order item, the system
facilitates to add selected items into the shopping cart and directly move to checkout option.
If the user interested to be a regular user, the system will provide registration facility as
well. Without even registering, the user can directly go for the checkout.
For a registered user, the system is expected to send a promotion code for users mobile every
month which can be used only once. when the user logs into the system to do online
shopping, user can enter this code which will give a 5% discount for the order he/she makes.
If the user does not use the code within the month, automatically the system must discard
promotion code. If its been already used, the system must display a message saying its
already been used. After adding the items into a shopping cart, user can select the checkout
button which gives two payment options, Cash on 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.
GlamourFashions (GF) is a clothing store situated in Colombo
and its planning to build an online shopping system to
promote their sales further. The management of clothing store
hired you as a System Analyst and asked to come up with the
design models for GlamourFashions Online Store (GFOS).
GlamourFashions (GF) Online Clothing Store is expected to
organize clothing items under several categories like office
wear, casual wear, evening wear and so on. A visitor can
browse on items without being registering to the system. If
he/she likes to order item, the system facilitates to add
selected items into the shopping cart and directly move to
checkout option. If the user interested to be a regular user,
the system will provide registration facility as well.
Without even registering, the user can directly go for the
checkout. For a registered user, the system is expected to
send a promotion code for users mobile every month which can
be used only once. when the user logs into the system to do
online shopping, user can enter this code which will give a 5%
discount for the order he/she makes. If the user does not use
the code within the month, automatically the system must
discard promotion code. If its been already used, the
system must display a message saying its already been used.
After adding the items into a shopping cart, user can select
the checkout button which gives two payment options, Cash on
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>
</div>
</div>
......@@ -226,7 +245,6 @@ const SiteManagerForm = () => {
<div className="col-12">
<div className="card">
<div className="row ">
<div className="col-6">
<div className="row-user">
<input
......@@ -244,17 +262,13 @@ const SiteManagerForm = () => {
<button type="submit">Submit</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
};
export default SiteManagerForm;
export default StudentSubjectAssingment;
......@@ -11,155 +11,44 @@ import Badge from "../components/badge/Badge";
import "../assets/css/Usercreate.css";
const ManageOrdersSupplier = () => {
const SubjectsStudent = () => {
const [error, setError] = useState("");
const [isLoading, setIsLoading] = useState(true);
const [orderDetails, setOrderDetails] = useState([]);
const fields = [
"",
"Module Code",
"Module Name",
"Year",
"",
"Actions",
];
const [SudentSubjects, setSudentSubjects] = useState([]);
const fields = ["", "Module Code", "Module Name", "Year", "", "Actions"];
const subjects = [
{ ModuleCode: "IT20300", ModuleName: "CTSE", 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 renderOrderBody = (item, index) => (
<tr key={index}>
<td>{ }</td>
<td>{}</td>
<td>{item.ModuleCode}</td>
<td>{item.ModuleName}</td>
<td>{item.Year}</td>
<td>{ }</td>
<td><Link to={`/auth/student/assignment`}>
<button className="view-btn">View</button>
</Link></td>
<td>{}</td>
<td>
<div className="row-user" style={{ paddingTop: "0" }}>
{item.DeliveryStatus === "pending" ? (
<div
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>
<Link to={`/auth/student/assignment`}>
<button className="view-btn">View</button>
</Link>
</td>
</tr>
);
const changeDeliveryStatusAsPreparing = async (id) => {
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 () => {
const getAllSubjects = async () => {
try {
const res = await axios.get("orders/supplier");
setOrderDetails(res.data.orders);
const res = await axios.get("/subjects");
setSudentSubjects(res.data.orders);
setIsLoading(false);
} catch (err) {
console.log(err.response);
}
};
useEffect(() => getAllOrders(), []);
useEffect(() => getAllSubjects(), []);
return (
<div>
......@@ -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