Commit 4f5d2b3e authored by Thushara Thiwanka's avatar Thushara Thiwanka

CREATE: assignment view integrated

parent f408c290
import axios from "axios";
import { Link } from "react-router-dom";
import { Link, useParams } from "react-router-dom";
import React, { useEffect, useState } from "react";
import Sidebar from "../components/sidebar/Sidebar";
import TopNav from "../components/topnav/TopNav";
......@@ -10,8 +10,10 @@ import { RiDeleteBinLine } from "react-icons/ri";
import Popup from "./Popup";
const ViewAssignment = () => {
const { id } = useParams();
const siteId = localStorage.getItem("site");
const [Materials, setMaterials] = useState([]);
const [assignment, setAssignment] = useState({});
const students = [
{
email: "email@gmail.com",
......@@ -49,63 +51,23 @@ const ViewAssignment = () => {
approved: "success",
rejected: "danger",
};
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 [Order, setOrder] = useState({
item: {},
quantity: 0,
siteid: siteId,
requiredDate: "",
urgentOrder: false,
});
console.log(Order);
const FetchData = async () => {
const resMaterials = await axios.get(`materials`);
setMaterials(resMaterials.data.materials);
const resOrders = await axios.get("/orders");
setOrderDetail(resOrders.data.orders);
if (resOrders.statusText === "OK") {
setLoading(true);
const getAssignment = async () => {
setLoading(true);
try {
const res = await axios.get("/assignments/" + id);
console.log(res);
setAssignment(res.data.assignment);
setLoading(false);
} catch (err) {
console.log(err.response);
}
};
useEffect(() => {
FetchData();
getAssignment();
}, []);
const deleteHandler = async id => {
console.log(id);
try {
const res = await axios.delete(`/orders/delete/${id}`);
if (res.statusText === "OK") {
window.location.reload();
}
} catch (Err) {
console.log(Err.response);
}
};
const orderHandler = async () => {
try {
console.log(Order);
const res = await axios.post("/orders", Order);
if (res.statusText === "OK") {
window.location.reload();
}
} catch (Err) {
console.log(Err.response);
}
};
const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
const renderOrderBody = (item, index) => (
......@@ -124,27 +86,6 @@ const ViewAssignment = () => {
<td>{item.submittedAt}</td>
<td>
<div style={{ display: "flex", alignItems: "center" }}>
<button className="action-btn check">
<i
className="bx bx-check"
onClick={() => {
if (window.confirm("Are you sure to accept this submission?")) {
// successHandler(item._id);
}
}}
></i>
</button>
<button
className="action-btn x"
style={{ marginRight: "2rem" }}
onClick={() => {
if (window.confirm("Are you sure to remove this submission?")) {
deleteHandler(item._id);
}
}}
>
<RiDeleteBinLine />
</button>
<Link to={``}>
<button className="view-btn">View</button>
</Link>
......@@ -159,7 +100,6 @@ const ViewAssignment = () => {
<div id="main" className="layout__content">
<TopNav />
<div className="layout__content-main">
<h1 className="page-header">CTSE Assignment 01</h1>
<div className="row">
<div className="col-12">
<div className="card">
......@@ -176,25 +116,7 @@ const ViewAssignment = () => {
</div>
</div>
<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.
</p>
<p>{assignment.content}</p>
</div>
</div>
</div>
......
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