Commit 5d4ba196 authored by Weerasinghe D.N.H's avatar Weerasinghe D.N.H

BACKEND : Merge conflict fixed

parents c20fbbe4 c0a2b07e
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/backend" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="149" name="Python" />
</Languages>
</inspection_tool>
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="E128" />
<option value="E501" />
</list>
</option>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/backend.iml" filepath="$PROJECT_DIR$/.idea/backend.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
...@@ -11,7 +11,6 @@ from routes.module_routes import module ...@@ -11,7 +11,6 @@ from routes.module_routes import module
from routes.assignment_routes import assignment from routes.assignment_routes import assignment
from routes.diagram_routes import diagram from routes.diagram_routes import diagram
from routes.submission_routes import submission from routes.submission_routes import submission
from routes.plagiarism_routes import use_case_diagram_plagiarism
APP_ROOT = os.path.dirname(os.path.abspath(__file__)) APP_ROOT = os.path.dirname(os.path.abspath(__file__))
...@@ -48,7 +47,6 @@ app.register_blueprint(module) ...@@ -48,7 +47,6 @@ app.register_blueprint(module)
app.register_blueprint(assignment) app.register_blueprint(assignment)
app.register_blueprint(diagram) app.register_blueprint(diagram)
app.register_blueprint(submission) app.register_blueprint(submission)
app.register_blueprint(use_case_diagram_plagiarism)
@app.before_first_request @app.before_first_request
......
...@@ -5,6 +5,7 @@ import pytesseract as ts ...@@ -5,6 +5,7 @@ import pytesseract as ts
from PIL import Image from PIL import Image
from models.attribute_model import Attribute from models.attribute_model import Attribute
from object_detection.utils import label_map_util from object_detection.utils import label_map_util
import matplotlib.pyplot as plt
import app import app
import tensorflow as tf import tensorflow as tf
import spacy import spacy
...@@ -20,47 +21,41 @@ ts.pytesseract.tesseract_cmd = r'C:\Users\DELL\AppData\Local\Programs\Tesseract- ...@@ -20,47 +21,41 @@ ts.pytesseract.tesseract_cmd = r'C:\Users\DELL\AppData\Local\Programs\Tesseract-
def component_separation(filename, class_comp_id): def component_separation(filename, class_comp_id):
"""
detect class diagram component predictions from SSD model & direct the components to correct method
:param filename: name of the submitted image file
:param class_comp_id: ID of the submission
"""
mdl1_path = app.CLASS_SAVED_MODEL_PATH mdl1_path = app.CLASS_SAVED_MODEL_PATH
lbl1_path = app.CLASS_SAVED_LABEL_PATH lbl1_path = app.CLASS_SAVED_LABEL_PATH
img1_path = app.SUBMISSION_PATH_CLASS + '/' + filename img1_path = app.SUBMISSION_PATH_CLASS + '/' + filename
image_nparray = np.array(Image.open(img1_path)) image_nparray = np.array(Image.open(img1_path))
# print(img1_path)
boxes, accurate_indexes, category_index, class_id = class_object_detection(mdl1_path, boxes, accurate_indexes, category_index, class_id = class_object_detection(mdl1_path,
lbl1_path, lbl1_path,
image_nparray) image_nparray)
for index in range(0, len(accurate_indexes)): for index in range(0, len(accurate_indexes)):
# get the category name of the component # Convert the class id in their name
if len(accurate_indexes) > 1: if len(accurate_indexes) > 1:
category = category_index[class_id[index]]['name'] category = category_index[class_id[index]]['name']
elif len(accurate_indexes) == 1: elif len(accurate_indexes) == 1:
category = category_index[class_id]['name'] category = category_index[class_id]['name']
# print(category)
# select the component type and provide method to detect further details
if category == 'class': if category == 'class':
# print(filename, 'class')
class_details_detection(image_nparray, boxes, index, class_comp_id, category) class_details_detection(image_nparray, boxes, index, class_comp_id, category)
elif category == 'interface': elif category == 'interface':
# print(filename, 'interface')
class_details_detection(image_nparray, boxes, index, class_comp_id, category) class_details_detection(image_nparray, boxes, index, class_comp_id, category)
else: else:
# print(filename, 'relationship')
detect_class_relationship(image_nparray, boxes, index, class_comp_id, category) detect_class_relationship(image_nparray, boxes, index, class_comp_id, category)
# relationship_details_detection(image_nparray, boxes, index, class_comp_id, category) # relationship_details_detection(image_nparray, boxes, index, class_comp_id, category)
def class_object_detection(model_path, label_path, image_nparray): def class_object_detection(model_path, label_path, image_nparray):
"""
do predictions using trained models
:param model_path: path to the saved model
:param label_path: path to the label_map.pbtxt
:param image_nparray: numpy array for image
:return: prediction details
"""
detect_fn = tf.saved_model.load(model_path) detect_fn = tf.saved_model.load(model_path)
category_index = label_map_util.create_category_index_from_labelmap(label_path, use_display_name=True) category_index = label_map_util.create_category_index_from_labelmap(label_path, use_display_name=True)
image_np = image_nparray image_np = image_nparray
...@@ -85,17 +80,10 @@ def class_object_detection(model_path, label_path, image_nparray): ...@@ -85,17 +80,10 @@ def class_object_detection(model_path, label_path, image_nparray):
def class_details_detection(image_nparray, boxes, index, class_comp_id, class_type): def class_details_detection(image_nparray, boxes, index, class_comp_id, class_type):
"""
detect class or interface details(name, methods & attributes) and save them in the database
:param image_nparray: numpy array for cropped classes or interfaces
:param boxes: coordinates of detected components
:param index: index of the loop in component_separation method
:param class_comp_id: ID of the submission
:param class_type: whether the component a class or interface
"""
methods_attributes = [] methods_attributes = []
_image, cl_ymin, cl_xmin, cl_ymax, cl_xmax = crop_image_(image_nparray, boxes, index) _image, cl_ymin, cl_xmin, cl_ymax, cl_xmax = crop_image_(image_nparray, boxes, index)
# cv2.imwrite('image_1.jpg', _image)
mdl2_path = app.CLASS_COMP_SAVED_MODEL_PATH mdl2_path = app.CLASS_COMP_SAVED_MODEL_PATH
lbl2_path = app.CLASS_COMP_SAVED_LABEL_PATH lbl2_path = app.CLASS_COMP_SAVED_LABEL_PATH
...@@ -108,51 +96,52 @@ def class_details_detection(image_nparray, boxes, index, class_comp_id, class_ty ...@@ -108,51 +96,52 @@ def class_details_detection(image_nparray, boxes, index, class_comp_id, class_ty
else: else:
category = category_index[class_id]['name'] category = category_index[class_id]['name']
# print(category)
if category == 'class_attributes': if category == 'class_attributes':
# print(category, 'line 96 - inside attributes')
class_attributes, y_min, x_min, y_max, x_max = crop_image_(_image, boxes_class, j) class_attributes, y_min, x_min, y_max, x_max = crop_image_(_image, boxes_class, j)
class_attributes = cv2.resize(class_attributes, None, fx=2, fy=2) class_attributes = cv2.resize(class_attributes, None, fx=2, fy=2)
# cv2.imwrite('image.jpg', class_attributes)
text = text_extraction(class_attributes) text = text_extraction(class_attributes)
attr = save_attributes_methods(text, 'attribute') attr = save_attributes_methods(text, 'attribute')
methods_attributes.append(attr) methods_attributes.append(attr)
elif category == 'class_methods': elif category == 'class_methods':
# print(category, 'line 103 - inside methods')
class_methods, y_min, x_min, y_max, x_max = crop_image_(_image, boxes_class, j) class_methods, y_min, x_min, y_max, x_max = crop_image_(_image, boxes_class, j)
class_methods = cv2.resize(class_methods, None, fx=2, fy=2) class_methods = cv2.resize(class_methods, None, fx=2, fy=2)
text = text_extraction(class_methods) text = text_extraction(class_methods)
methods = save_attributes_methods(text, 'method') methods = save_attributes_methods(text, 'method')
methods_attributes.append(methods) methods_attributes.append(methods)
# print(text, '111 line')
comp_name = class_name_detection(_image, boxes_class, category_index, accurate_indexes, class_id) comp_name = class_name_detection(_image, boxes_class, category_index, accurate_indexes, class_id)
# print(comp_name, 'comp_name line 118')
comp = save_class_interface(class_type, comp_name, cl_ymin, cl_xmin, cl_ymax, cl_xmax, class_comp_id) comp = save_class_interface(class_type, comp_name, cl_ymin, cl_xmin, cl_ymax, cl_xmax, class_comp_id)
# print(comp, 'component_id line 120')
alter_attributes_methods(methods_attributes, comp.id) alter_attributes_methods(methods_attributes, comp.id)
# crop image using boxes & index
def crop_image_(image, boxes, index): def crop_image_(image, boxes, index):
"""
crop image according to the given coordinates
:param image: numpy array for image
:param boxes: detection coordinates of predictions
:param index: index of the loop in component_separation method
:return: cropped image as numpy array
"""
height, width, c = image.shape height, width, c = image.shape
# crop box format: xmin, ymin, xmax, ymax
ymin = boxes[index][0] * height ymin = boxes[index][0] * height
xmin = boxes[index][1] * width xmin = boxes[index][1] * width
ymax = boxes[index][2] * height ymax = boxes[index][2] * height
xmax = boxes[index][3] * width xmax = boxes[index][3] * width
cropped_image = image[int(ymin):int(ymax), int(xmin):int(xmax)] cropped_image = image[int(ymin):int(ymax), int(xmin):int(xmax)]
# image = cv2.cvtColor(cropped_image, cv2.COLOR_BGR2GRAY)
# image = cv2.resize(image, (800, 500))
# returns cropped image , ymin,xmin,ymax & xmax
return cropped_image, ymin, xmin, ymax, xmax return cropped_image, ymin, xmin, ymax, xmax
# extract text from provided image
def text_extraction(image): def text_extraction(image):
"""
extract text of image component
:param image: numpy array of image
:return: extracted text as a list
"""
config = '-l eng --oem 1 --psm 4' config = '-l eng --oem 1 --psm 4'
text = ts.image_to_string(image, config=config) text = ts.image_to_string(image, config=config)
text = text.splitlines() text = text.splitlines()
...@@ -161,15 +150,12 @@ def text_extraction(image): ...@@ -161,15 +150,12 @@ def text_extraction(image):
return text return text
# save attributes and methods in database
def save_attributes_methods(text, typ): def save_attributes_methods(text, typ):
"""
detect attribute or method component and save them inside database
:param text: list of text
:param typ: type of object(attribute or method)
:return: all saved attributes and methods
"""
saved_data = [] saved_data = []
nlp = spacy.load('en_core_web_sm')
for element in text: for element in text:
# print(element, 'line 145')
# removable = str.maketrans('', '', '()') # removable = str.maketrans('', '', '()')
nlp_ner = spacy.load('ner_models/model-best') nlp_ner = spacy.load('ner_models/model-best')
nlp_output = nlp_ner(element) nlp_output = nlp_ner(element)
...@@ -199,11 +185,13 @@ def save_attributes_methods(text, typ): ...@@ -199,11 +185,13 @@ def save_attributes_methods(text, typ):
method.return_type = token.text method.return_type = token.text
if typ == 'attribute': if typ == 'attribute':
# print(attr, 'line 175 - attr')
db.session.add(attr) db.session.add(attr)
db.session.commit() db.session.commit()
saved_data.append(attr) saved_data.append(attr)
else: else:
# print(method, 'line 181 method')
db.session.add(method) db.session.add(method)
db.session.commit() db.session.commit()
saved_data.append(method) saved_data.append(method)
...@@ -211,24 +199,18 @@ def save_attributes_methods(text, typ): ...@@ -211,24 +199,18 @@ def save_attributes_methods(text, typ):
return saved_data return saved_data
# update attributes and methods with relevant class id
def alter_attributes_methods(element_list, component_id): def alter_attributes_methods(element_list, component_id):
"""
Update saved method and attributes with class component ID
:param element_list: attributes and method as a list
:param component_id: class ID
"""
for j in element_list: for j in element_list:
for element in j: for element in j:
# print(component_id)
# print(element_list)
element.class_id = component_id element.class_id = component_id
db.session.commit() db.session.commit()
# convert symbol access specifier to string
def covert_to_access_specifier(access): def covert_to_access_specifier(access):
"""
convert access specifier symbols to strings
:param access: access specifier symbol
:return: access specifier string
"""
if access == "-": if access == "-":
return "Private" return "Private"
...@@ -246,23 +228,20 @@ def covert_to_access_specifier(access): ...@@ -246,23 +228,20 @@ def covert_to_access_specifier(access):
def class_name_detection(image, boxes, category_index, accurate_indexes, class_id): def class_name_detection(image, boxes, category_index, accurate_indexes, class_id):
""" # print(category_index, 'category_index')
detect & return class or interface name
:param image: class or interface component image # print(class_id, 'class_id')
:param boxes: predicted coordinates of methods and attributes
:param category_index: category index of each component
:param accurate_indexes:
:param class_id:
:return: name of the class or interface
"""
height, width, c = image.shape height, width, c = image.shape
for i in range(0, len(accurate_indexes)): for i in range(0, len(accurate_indexes)):
if len(accurate_indexes) > 1: if len(accurate_indexes) > 1:
category = category_index[class_id[i]]['name'] category = category_index[class_id[i]]['name']
# print(category, '225 line')
else: else:
category = category_index[class_id]['name'] category = category_index[class_id]['name']
# print(category, '225 line')
if category != 'interface_name' or category != 'class_name': if category != 'interface_name' or category != 'class_name':
ymin = boxes[i][0] * height ymin = boxes[i][0] * height
...@@ -271,9 +250,12 @@ def class_name_detection(image, boxes, category_index, accurate_indexes, class_i ...@@ -271,9 +250,12 @@ def class_name_detection(image, boxes, category_index, accurate_indexes, class_i
xmax = boxes[i][3] * width xmax = boxes[i][3] * width
cv2.rectangle(image, (int(xmin), int(ymin)), (int(xmax), int(ymax)), (255, 255, 255), -1) cv2.rectangle(image, (int(xmin), int(ymin)), (int(xmax), int(ymax)), (255, 255, 255), -1)
# cv2.imwrite('image_2.jpg', image)
class_name = text_extraction(image) class_name = text_extraction(image)
# print(class_name, 'line 249 class name')
if ''.join(class_name) is not None: if ''.join(class_name) is not None:
# print(class_name, 'line 251 class name')
if "interface" in ''.join(class_name): if "interface" in ''.join(class_name):
name = ''.join(class_name).replace("<<interface>>", "") name = ''.join(class_name).replace("<<interface>>", "")
else: else:
...@@ -283,20 +265,10 @@ def class_name_detection(image, boxes, category_index, accurate_indexes, class_i ...@@ -283,20 +265,10 @@ def class_name_detection(image, boxes, category_index, accurate_indexes, class_i
def save_class_interface(class_type, comp_name, cl_ymin, cl_xmin, cl_ymax, cl_xmax, class_comp_id): def save_class_interface(class_type, comp_name, cl_ymin, cl_xmin, cl_ymax, cl_xmax, class_comp_id):
"""
save class component and interface components in database
:param class_type: type of component (interface or class)
:param comp_name: name of interface or class
:param cl_ymin:
:param cl_xmin:
:param cl_ymax:
:param cl_xmax:
:param class_comp_id: submission ID of diagram
:return: database saved object
"""
comp = Component(class_answer=class_comp_id, name=comp_name, type=class_type, x_min=cl_xmin, y_min=cl_ymin, comp = Component(class_answer=class_comp_id, name=comp_name, type=class_type, x_min=cl_xmin, y_min=cl_ymin,
x_max=cl_xmax, x_max=cl_xmax,
y_max=cl_ymax) y_max=cl_ymax)
db.session.add(comp) db.session.add(comp)
db.session.commit() db.session.commit()
# print(comp, 'line 261 comp')
return comp return comp
...@@ -15,9 +15,15 @@ from models.class_relationship_muplicity import Multiplicity ...@@ -15,9 +15,15 @@ from models.class_relationship_muplicity import Multiplicity
def detect_class_relationship(image_nparray, boxes, index, class_comp_id, category): def detect_class_relationship(image_nparray, boxes, index, class_comp_id, category):
# image = cv2.imread(app.SUBMISSION_PATH + '/' + filename)
height, width, c = image_nparray.shape height, width, c = image_nparray.shape
class_objects = Component.query.filter_by(class_answer=class_comp_id).all() class_objects = Component.query.filter_by(class_answer=class_comp_id).all()
# for i in range(0, len(accurate_indexes))
# if category_index[class_id[i]]['name'] != 'class' and category_index[class_id[i]]['name'] != 'interface':
# category_name = category_index[class_id[i]]['name']
ymin = boxes[index][0] * height ymin = boxes[index][0] * height
xmin = boxes[index][1] * width xmin = boxes[index][1] * width
ymax = boxes[index][2] * height ymax = boxes[index][2] * height
...@@ -238,13 +244,20 @@ def relationship_details_detection(image_nparray, boxes, index, class_comp_id, c ...@@ -238,13 +244,20 @@ def relationship_details_detection(image_nparray, boxes, index, class_comp_id, c
if result is not None: if result is not None:
relationship_text(_image, result, relationship) relationship_text(_image, result, relationship)
# print(relationship, 'relationship')
def relationship_text(_image, result, relationship): def relationship_text(_image, result, relationship):
# boxes = [res[0] for res in result]
# texts = [res[1][0] for res in result]
# scores = [res[1][1] for res in result]
for element in result: for element in result:
text = element[1][0] text = element[1][0]
box = element[0] box = element[0]
nlp_ner = spacy.load('ner_models/model-best') nlp_ner = spacy.load('ner_models/model-best')
nlp_output = nlp_ner(text) nlp_output = nlp_ner(text)
# print(text, 'line 290')
# box = np.array(box,dtype=float)
box = np.array(box).astype(np.int32) box = np.array(box).astype(np.int32)
xmin = min(box[:, 0]) xmin = min(box[:, 0])
...@@ -252,6 +265,8 @@ def relationship_text(_image, result, relationship): ...@@ -252,6 +265,8 @@ def relationship_text(_image, result, relationship):
xmax = max(box[:, 0]) xmax = max(box[:, 0])
ymax = max(box[:, 1]) ymax = max(box[:, 1])
for token in nlp_output.ents: for token in nlp_output.ents:
# print(token.text, 'line 301')
# print(token.label_, 'line 302')
if token.label_ == 'MULTIPLICITY' or contains_number(text): if token.label_ == 'MULTIPLICITY' or contains_number(text):
multiplicity = Multiplicity(value=token.text, relationship_id=relationship.id, x_min=xmin, multiplicity = Multiplicity(value=token.text, relationship_id=relationship.id, x_min=xmin,
...@@ -272,12 +287,14 @@ def contains_number(string): ...@@ -272,12 +287,14 @@ def contains_number(string):
# crop image using boxes & index # crop image using boxes & index
def crop_image_(image, boxes, index): def crop_image_(image, boxes, index):
height, width, c = image.shape height, width, c = image.shape
# crop box format: xmin, ymin, xmax, ymax
ymin = boxes[index][0] * height ymin = boxes[index][0] * height
xmin = boxes[index][1] * width xmin = boxes[index][1] * width
ymax = boxes[index][2] * height ymax = boxes[index][2] * height
xmax = boxes[index][3] * width xmax = boxes[index][3] * width
cropped_image = image[int(ymin):int(ymax), int(xmin):int(xmax)] cropped_image = image[int(ymin):int(ymax), int(xmin):int(xmax)]
# image = cv2.cvtColor(cropped_image, cv2.COLOR_BGR2GRAY)
# image = cv2.resize(image, (800, 500))
# returns cropped image , ymin,xmin,ymax & xmax # returns cropped image , ymin,xmin,ymax & xmax
return cropped_image, ymin, xmin, ymax, xmax return cropped_image, ymin, xmin, ymax, xmax
import React, { useEffect, useState } from "react";
import axios from "axios";
import { useParams } from "react-router-dom";
import Sidebar from "../components/sidebar/Sidebar";
import TopNav from "../components/topnav/TopNav";
import "../assets/css/Usercreate.css";
const DeliveryReportSubmit = () => {
const { id } = useParams();
const [btnState, setBtnState] = useState(false);
const [error, setError] = useState("");
const [deliveryReport, setDeliveryReport] = useState({});
const saveDeliveryReport = async (e) => {
e.preventDefault();
setBtnState(true);
if (!deliveryReport.description) {
setBtnState(false);
return setError("Please fill all the fields");
}
try {
const res = await axios.post("/reports/deliveryreport", deliveryReport);
if (res.status === 201) {
setDeliveryReport({});
getOrderDetails();
setError("");
const res = await axios.put(`orders/supplier/submitted/${id}`);
if (res.status === 200) {
window.alert("Delivery report registered successfully");
window.location.href = "/auth/supplier/deliveryreports";
}
}
setBtnState(false);
} catch (err) {
setBtnState(false);
console.log(err.response);
}
};
const getOrderDetails = async () => {
try {
const res = await axios.get(`orders/${id}`);
console.log(res.data);
setDeliveryReport(res.data.order);
} catch (err) {
console.log(err.response);
}
};
useEffect(() => getOrderDetails(), []);
return (
<div>
<Sidebar />
<div id="main" className="layout__content">
<TopNav />
<div className="layout__content-main">
<h1 className="page-header">Submit Delivery Report</h1>
<div className="row">
<div className="col-12">
<form className="card" style={{ position: "relative" }}>
{error && (
<div className="error-bg" style={{ left: "3%" }}>
<p>{error}</p>
</div>
)}
<div className="row">
<div className="col-4">
<label htmlFor="">Order Item</label>
<div className="row-user">
<input
disabled
type="text"
placeholder="Delivered Item"
value={deliveryReport.itemName}
required
/>
</div>
</div>
<div className="col-4">
<label htmlFor="">Order ID</label>
<div className="row-user">
<input
disabled
type="text"
placeholder="Order ID"
value={deliveryReport._id}
required
/>
</div>
</div>
<div className="col-4">
<label htmlFor="">Quantity</label>
<div className="row-user">
<input
disabled
type="text"
placeholder="Quantity"
value={deliveryReport.quantity}
required
/>
</div>
</div>
</div>
<div className="row">
<div className="col-4">
<label htmlFor="">Total</label>
<div className="row-user">
<input
disabled
type="text"
placeholder="Delivered Item"
value={deliveryReport.total}
required
/>
</div>
</div>
<div className="col-4">
<label htmlFor="">Order Type</label>
<div className="row-user">
<input
disabled
type="text"
placeholder="Order ID"
value={
deliveryReport.urgentOrder === false
? "Regular Order"
: "Urgent Order"
}
required
/>
</div>
</div>
</div>
<div className="row">
<div className="col-12">
<div className="row-user">
<input
type="text"
placeholder="Description"
value={deliveryReport.description}
onChange={(e) =>
setDeliveryReport({
...deliveryReport,
description: e.target.value,
})
}
required
/>
</div>
</div>
</div>
<div className="row-user">
<button type="submit" onClick={saveDeliveryReport}>
{btnState ? "Saving" : "Save"}
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
);
};
export default DeliveryReportSubmit;
import React, { useState, useEffect } from "react";
import { Link } from "react-router-dom";
import Sidebar from "../components/sidebar/Sidebar";
import TopNav from "../components/topnav/TopNav";
import Table from "../components/table/Table";
import Badge from "../components/badge/Badge";
import axios from "axios";
const ManageAllOrders = () => {
const fields = [
"Order ID",
"Item Name",
"Quantity",
"Total",
"Created Date",
"Status",
];
const [orders, setOrders] = useState(null);
const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
const renderOrderBody = (item, index) => (
<tr key={index}>
<td>{index + 1}</td>
<td>{item.itemName}</td>
<td>{item.quantity}</td>
<td>{item.total}</td>
<td>{new Date(item.createdAt).toLocaleDateString()}</td>
<td>
<Badge
type={permissionStatus[item.isApprovedByOfficer]}
content={item.isApprovedByOfficer}
/>
</td>
</tr>
);
const getAllOrder = async () => {
const res = await axios.get("orders/getAllOrdersByManager");
console.log(res.data.orders);
setOrders(res.data.orders);
};
useEffect(() => {
getAllOrder();
}, []);
const permissionStatus = {
pending: "warning",
approved: "success",
rejected: "danger",
};
return (
<div>
<Sidebar />
<div id="main" className="layout__content">
<TopNav />
<div className="layout__content-main">
<div className="card">
<h2>All Order Details</h2>
{orders && (
<Table
limit="10"
headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={orders}
renderBody={(item, index) => renderOrderBody(item, index)}
/>
)}
</div>
<Link to={"/auth/manager/ApprovedOrders"}>
<div className="row-user">
<button>Approved Orders</button>
</div>
</Link>
</div>
</div>
</div>
);
};
export default ManageAllOrders;
import React, { useState, useEffect } from "react";
import axios from "axios";
import Sidebar from "../components/sidebar/Sidebar";
import Spinner from "../components/loading/Spinner";
import TopNav from "../components/topnav/TopNav";
import Table from "../components/table/Table";
import Badge from "../components/badge/Badge";
import "../components/badge/badge.css";
import "react-calendar/dist/Calendar.css";
const ManageDeliveryReports = () => {
const [suppliers, setSuppliers] = useState([]);
const [isLoading, setIsLoading] = useState(true);
const fields = [
"",
"Item",
"Quantity",
"Description",
"Total",
"Delivered Address",
"Order Type",
];
const getAllSuppliers = async () => {
setIsLoading(true);
try {
const res = await axios.get(`reports/deliveryreport/supplier`);
console.log(res);
setSuppliers(res.data.reports);
setIsLoading(false);
} catch (err) {
console.log(err.response);
}
};
useEffect(() => getAllSuppliers(), []);
const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
const renderOrderBody = (item, index) => (
<tr key={index}>
<td>{index + 1}</td>
<td>{item.item}</td>
<td>{item.quantity}</td>
<td>{item.description}</td>
<td>{item.total}</td>
<td>{item.address}</td>
<td>
{item.urgentOrder ? (
<div style={{ cursor: "pointer" }}>
<Badge type="danger" content="Urgent" />
</div>
) : (
<div style={{ cursor: "pointer" }}>
<Badge type="primary" content="Regular" />
</div>
)}
</td>
</tr>
);
return (
<div>
<Sidebar />
<div id="main" className="layout__content">
<TopNav />
<div className="layout__content-main">
<h1 className="page-header">Manage Delivery Reports</h1>
<div className="row"></div>
<div className="row">
<div className="col-12">
<div className="card">
{isLoading ? (
<Spinner />
) : (
<Table
limit="5"
headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={suppliers}
renderBody={(item, index) => renderOrderBody(item, index)}
/>
)}
</div>
</div>
</div>
</div>
</div>
</div>
);
};
export default ManageDeliveryReports;
import React, { useEffect, useState } from "react";
import Sidebar from "../components/sidebar/Sidebar";
import TopNav from "../components/topnav/TopNav";
import Table from "../components/table/Table";
import Spinner from "../components/loading/Spinner";
import "../assets/css/Usercreate.css";
import axios from "axios";
const ManageUsers = () => {
const [error, setError] = useState("");
const [btnState, setBtnState] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [siteManagers, setSiteManagers] = useState([]);
const [sites, setSites] = useState([]);
const [site, setSite] = useState({
name: "",
location: "",
siteManagerId: "",
});
const fields = ["", "Site Name", "Location", "Site Manager", "Email"];
const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
const renderOrderBody = (item, index) => (
<tr key={index}>
<td>{index + 1}</td>
<td>{item.name}</td>
<td>{item.location}</td>
<td>{item.siteManagerId ? item.siteManagerId.name : "Not Assigned"}</td>
<td>{item.siteManagerId ? item.siteManagerId.email : "Not Assigned"}</td>
</tr>
);
const saveSite = async (e) => {
e.preventDefault();
setBtnState(true);
for (let key of Object.keys(site)) {
if (!site[key]) {
setBtnState(false);
return setError("Please fill all the fields");
}
}
if (site.siteManagerId === "sitemanager") {
setBtnState(false);
return setError("Please fill all the fields");
}
try {
const res = await axios.post("sites", site);
setSite({
name: "",
location: "",
siteManagerId: "",
});
getAllSites();
setError("");
window.alert("Site registered successfully");
setBtnState(false);
setIsLoading(true);
} catch (err) {
setBtnState(false);
console.log(err.response);
}
};
const getAllSites = async () => {
try {
const res = await axios.get(`sites`);
setSites(res.data.sites);
console.log(res.data.sites);
setIsLoading(false);
} catch (err) {
console.log(err.response);
}
};
const getAllSiteManagers = async () => {
try {
const res = await axios.get(`sitemanagers`);
setSiteManagers(res.data.sitemanagers);
} catch (err) {
console.log(err.response);
}
};
useEffect(() => {
getAllSites();
getAllSiteManagers();
}, []);
return (
<div>
<Sidebar />
<div id="main" className="layout__content">
<TopNav />
<div className="layout__content-main">
<h1 className="page-header">Manage Sites</h1>
<div className="row">
<div className="col-12">
<form className="card" style={{ position: "relative" }}>
{error && (
<div className="error-bg" style={{ left: "3%" }}>
<p>{error}</p>
</div>
)}
<div className="row">
<div className="col-6">
<div className="row-user">
<input
type="text"
placeholder="Site Name"
value={site.name}
onChange={(e) =>
setSite({
...site,
name: e.target.value,
})
}
required
/>
</div>
</div>
<div className="col-6">
<div className="row-user">
<input
type="text"
placeholder="Site Location"
value={site.location}
onChange={(e) =>
setSite({
...site,
location: e.target.value,
})
}
required
/>
</div>
</div>
<div className="col-6">
<div className="row-user">
<select
name="site"
id="site"
value={site.siteManagerId}
onChange={(e) =>
setSite({
...site,
siteManagerId: e.target.value,
})
}
required
>
<option defaultValue value="sitemanager">
SELECT SITE MANAGER
</option>
{siteManagers.length !== 0 &&
siteManagers.map((siteManager) => (
<option value={siteManager._id}>
{siteManager.name}
</option>
))}
</select>
</div>
</div>
</div>
<div className="row-user">
<button type="submit" onClick={saveSite}>
{btnState ? "Saving" : "Save"}
</button>
</div>
</form>
</div>
</div>
<div className="card">
<h2>Site Details</h2>
{isLoading ? (
<Spinner />
) : (
<Table
limit="5"
headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={sites}
renderBody={(item, index) => renderOrderBody(item, index)}
/>
)}
</div>
</div>
</div>
</div>
);
};
export default ManageUsers;
import React, { useState, useEffect } from "react";
import { Link } from "react-router-dom";
import Calendar from "react-calendar";
import Sidebar from "../components/sidebar/Sidebar";
import TopNav from "../components/topnav/TopNav";
import Table from "../components/table/Table";
import "react-calendar/dist/Calendar.css";
import "../components/badge/badge.css";
import AdminGreeting from "../assets/images/admin-greeting.png";
import Badge from "../components/badge/Badge";
import profilePicture from "../assets/images/admin-user-img.jpg";
import axios from "axios";
import status from "../helpers/greeting";
const OfficerDashboard = () => {
const [value, onChange] = useState(new Date());
const [orders, setOrders] = useState(null);
const fields = [
"Order ID",
"Item Name",
"Quantity",
"Total",
"Created Date",
"Status",
];
const rows = [
{
id: "1",
date: "2021.08.06",
houseOwner: "Gayath Chandula",
providence: "Pool",
status: "Approved",
},
{
id: "2",
date: "2021.08.06",
houseOwner: "Gayath Chandula",
providence: "Pool",
status: "Pending",
},
{
id: "3",
date: "2021.08.06",
houseOwner: "Gayath Chandula",
providence: "Pool",
status: "Declined",
},
{
id: "4",
date: "2021.08.06",
houseOwner: "Gayath Chandula",
providence: "Pool",
status: "Pending",
},
{
id: "4",
date: "2021.08.06",
houseOwner: "Gayath Chandula",
providence: "Pool",
status: "Pending",
},
{
id: "4",
date: "2021.08.06",
houseOwner: "Gayath Chandula",
providence: "Pool",
status: "Pending",
},
];
const permissionStatus = {
pending: "warning",
Approved: "success",
Declined: "danger",
};
const deleteHandler = (id) => {
console.log(id);
};
const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
const renderOrderBody = (item, index) => (
<tr key={index}>
<td>{index + 1}</td>
<td>{item.itemName}</td>
<td>{item.quantity}</td>
<td>{item.total}</td>
<td>{new Date(item.createdAt).toLocaleDateString()}</td>
<td>
<Badge
type={permissionStatus[item.isApprovedByOfficer]}
content={item.isApprovedByOfficer}
/>
</td>
<td className="">
{item.status === "Pending" && (
<>
<button className="action-btn check">
<i className="bx bx-check"></i>
</button>
<button className="action-btn x">
<i
className="bx bx-x"
onClick={() => {
if (window.confirm("Are you sure to delete this request?")) {
deleteHandler(item.id);
}
}}
></i>
</button>
</>
)}
</td>
</tr>
);
const getAllOrder = async () => {
const res = await axios.get("orders/officer");
setOrders(res.data.orders);
console.log(res);
};
console.log(orders);
useEffect(() => {
getAllOrder();
}, []);
return (
<div>
<Sidebar />
<div id="main" className="layout__content">
<TopNav />
<div className="layout__content-main">
<div className="row">
<div className="col-8 full-width">
<div className="card greeting-card">
<div className="row">
<div className="col-8 flex-column">
<h1 className="page-header">{`Good ${status}!`} </h1>
<h3>
Today you have{" "}
{orders &&
orders.filter(
(order) => order.isApprovedByOfficer === "pending"
).length}{" "}
new notifications
</h3>
<h3>Also new booking appointments for approval</h3>
<Link className="read-more">
Read more <i className="bx bx-right-arrow-alt"></i>
</Link>
</div>
<div className="col-4">
<img
className="admin-greeting"
src={AdminGreeting}
alt=""
/>
</div>
</div>
</div>
</div>
<div className="col-4 full-width">
<div className="card">
<h2
className="request-title"
style={{ color: "transparent", marginBottom: "-.2rem" }}
>
Calender
</h2>
<Calendar
className="calender"
onChange={onChange}
value={value}
/>
</div>
</div>
</div>
<div className="row">
<div className="col-8">
<div className="card">
<div className="flex">
<h2 className="request-title">New Orders</h2>
<Link to={`/auth/officers/orderlist`}>
<button className="view-btn">View All</button>
</Link>
</div>
{orders ? (
<Table
limit="5"
headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={orders}
renderBody={(item, index) => renderOrderBody(item, index)}
/>
) : (
<div></div>
)}
</div>
</div>
<div className="col-4">
<div className="card">
<div className="row">
<div className="col-4 full-width-1496">
<img
src={profilePicture}
alt=""
className="profile-picture"
/>
</div>
<div className="col-8">
<h2>{localStorage.getItem("name")}</h2>
<h3 className="lighter">OFFICER</h3>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
};
export default OfficerDashboard;
import React, { useState, useEffect } from "react";
import Sidebar from "../components/sidebar/Sidebar";
import TopNav from "../components/topnav/TopNav";
import Table from "../components/table/Table";
import Badge from "../components/badge/Badge";
import axios from "axios";
import Popup from "./Popup";
import { MdDelete } from "react-icons/md";
import {
FaCheckCircle,
FaExclamationTriangle,
FaCheckDouble,
} from "react-icons/fa";
const OfficerOrders = () => {
const fields = [
"Order ID",
"Item Name",
"Quantity",
"Total",
"Created Date",
"Status",
"Actions",
];
const [orders, setOrders] = useState(null);
const [trigger, setTrigger] = useState(false);
const acceptOrder = async (id) => {
console.log("hi");
try {
const res = await axios.put(`orders/officer/${id}`, {
status: "approved",
});
console.log(res);
} catch (err) {
console.log(err.response);
}
getAllOrder();
};
const deleteHandler = async (id) => {
// console.log("hi");
try {
const res = await axios.put(`orders/officer/${id}`, {
status: "rejected",
});
console.log(res);
} catch (err) {
console.log(err.response);
}
getAllOrder();
};
const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
const renderOrderBody = (item, index) => (
<tr key={index}>
<td>{index + 1}</td>
<td>{item.itemName}</td>
<td>{item.quantity}</td>
<td>{item.total}</td>
<td>{new Date(item.createdAt).toLocaleDateString()}</td>
<td>
<Badge
type={permissionStatus[item.isApprovedByOfficer]}
content={item.isApprovedByOfficer}
/>
</td>
<td>
{item.isApprovedByOfficer == "pending" ? (
<FaCheckCircle
className="action-btn check"
onClick={() => {
acceptOrder(item._id);
window.alert("order accepted successfully");
window.location.reload();
}}
/>
) : item.isApprovedByOfficer == "approved" ? (
<FaCheckDouble className="action-btn check " />
) : (
""
)}
{item.isApprovedByOfficer == "pending" ? (
<>
<MdDelete
className="action-btn x"
onClick={() => {
// if (window.confirm("Are you sure to delete this request?")) {
deleteHandler(item._id);
setTrigger(true);
// }
}}
/>
<Popup
trigger={trigger}
setTrigger={setTrigger}
orderId={item._id}
name="rejectReason"
/>
</>
) : item.isApprovedByOfficer == "rejected" ? (
<FaExclamationTriangle className="action-btn x" />
) : (
""
)}
{item.isApprovedByOfficer == "approved" && !item.supplierId ? (
<>
<button
className="action-btn item-assign "
onClick={() => {
setTrigger(true);
}}
>
<i className="bx bxs-user-plus"></i>
</button>
<Popup
trigger={trigger}
setTrigger={setTrigger}
order={item.itemName}
orderId={item._id}
materialId={item.orderItem}
sitemng={item.siteManagerId}
total={item.total}
name="Assign"
/>
</>
) : (
""
)}
</td>
</tr>
);
const getAllOrder = async () => {
const res = await axios.get("orders/officer/orders");
// console.log(res.data.orders);
setOrders(res.data.orders);
};
useEffect(() => {
getAllOrder();
}, []);
const permissionStatus = {
pending: "warning",
approved: "success",
rejected: "danger",
};
return (
<div>
<Sidebar />
<div id="main" className="layout__content">
<TopNav />
<div className="layout__content-main">
{orders && (
<Table
limit="10"
headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={orders}
renderBody={(item, index) => renderOrderBody(item, index)}
/>
)}
</div>
</div>
</div>
);
};
export default OfficerOrders;
import React, { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import Sidebar from "../components/sidebar/Sidebar";
import TopNav from "../components/topnav/TopNav";
import Table from "../components/table/Table";
import AdminGreeting from "../assets/images/admin-greeting.png";
import Badge from "../components/badge/Badge";
import "../components/badge/badge.css";
import Calendar from "react-calendar";
import "react-calendar/dist/Calendar.css";
import profilePicture from "../assets/images/user2.jpg";
import Spinner from "../components/loading/Spinner";
import axios from "axios";
const SiteManagerDashboard = () => {
const [value, onChange] = useState(new Date());
const fields = ["", "Required Date", "Item", "Quantity", "Delivery Status"];
const [OrderDetail, setOrderDetail] = useState([])
const [Loading, setLoading] = useState(false);
useEffect(() => {
const FetchData = async () => {
const res = await axios.get("/orders/approved");
setOrderDetail(res.data.orders);
console.log(res.data);
if(res.statusText === "OK" ){
setLoading(true)
}
};
FetchData();
}, []);
const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
const renderOrderBody = (item, index) => (
<tr key={index}>
<td>{index + 1}</td>
<td>{item.requiredDate}</td>
<td>{item.itemName}</td>
<td>{item.quantity}</td>
<td>
<div className="row-user" style={{ paddingTop: "0" }}>
{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} />
) : (
""
)}
</div>
</td>
</tr>
);
return (
<div>
<Sidebar />
<div id="main" className="layout__content">
<TopNav />
<div className="layout__content-main">
<div className="row">
<div className="col-8 full-width">
<div className="card greeting-card">
<div className="row">
<div className="col-8 flex-column">
<h1 className="page-header">Good Morning! </h1>
<h3>Today you have 9 new notifications</h3>
<h3>Also new booking appointments for approval</h3>
<Link className="read-more">
Read more <i className="bx bx-right-arrow-alt"></i>
</Link>
</div>
<div className="col-4">
<img
className="admin-greeting"
src={AdminGreeting}
alt=""
/>
</div>
</div>
</div>
</div>
<div className="col-4 full-width">
<div className="card">
<h2
className="request-title"
style={{ color: "transparent", marginBottom: "-.2rem" }}
>
Calender
</h2>
<Calendar
className="calender"
onChange={onChange}
value={value}
/>
</div>
</div>
</div>
<div className="row">
<div className="col-8">
<div className="card">
<div className="flex">
<h2 className="request-title">New Orders</h2>
<Link to={`/auth/sitemanager/requisitions`}>
<button className="view-btn">View All</button>
</Link>
</div>
{Loading ? <Table
limit="5"
headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={OrderDetail}
renderBody={(item, index) => renderOrderBody(item, index)}
/>:<Spinner/>}
</div>
</div>
<div className="col-4">
<div className="card">
<div className="row">
<div className="col-4 full-width-1496">
<img
src={profilePicture}
alt=""
className="profile-picture"
/>
</div>
<div className="col-8">
<h2>{localStorage.getItem("name")}</h2>
<h3 className="lighter">SITE MANAGER</h3>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
};
export default SiteManagerDashboard;
...@@ -2,61 +2,184 @@ import axios from "axios"; ...@@ -2,61 +2,184 @@ import axios from "axios";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import Sidebar from "../components/sidebar/Sidebar"; import Sidebar from "../components/sidebar/Sidebar";
import TopNav from "../components/topnav/TopNav"; import TopNav from "../components/topnav/TopNav";
import { useParams } from "react-router-dom"; 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 Popup from "./Popup";
const StudentSubjectAssingment = () => { const StudentSubjectAssingment = () => {
const { id } = useParams(); 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 [Loading, setLoading] = useState(false); const [Loading, setLoading] = useState(false);
const [Trigger, setTrigger] = useState(false); const [Trigger, setTrigger] = useState(false);
const [assignment, setAssignment] = useState([]); const [Name, setName] = useState("");
const [submission, setSubmission] = useState({ const [Id, setId] = useState("");
type: "", const [ItemName, setItemName] = useState("");
comment: "", const [Description, setDescription] = useState("");
id: 2,
file: {}, 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);
const fileHandler = (e) => { if (resOrders.statusText === "OK") {
console.log(e); setLoading(true);
setSubmission({ ...submission, file: e.target.files[0] }); }
console.log(submission);
}; };
const FetchData = async () => { useEffect(() => {
FetchData();
}, []);
const deleteHandler = async (id) => {
console.log(id);
try { try {
const res = await axios.get("assignments/" + id); const res = await axios.delete(`/orders/delete/${id}`);
setAssignment(res.data.assignment); if (res.statusText === "OK") {
setSubmission({ ...submission, id: id }); window.location.reload();
if (assignment.assignment_type === 1) {
setSubmission({ ...submission, type: "use case" });
} else if (assignment.assignment_type === 2) {
setSubmission({ ...submission, type: "class" });
} else {
setSubmission({ ...submission, type: "use case" });
} }
} catch (error) { } catch (Err) {
console.log(error.response); console.log(Err.response);
} }
}; };
const onSubmit = async (e) => { const orderHandler = async () => {
e.preventDefault();
try { try {
const res = await axios.post("submissions/upload/", submission, { console.log(Order);
headers: { token: localStorage.getItem("token") }, const res = await axios.post("/orders", Order);
}); if (res.statusText === "OK") {
window.alert("Assignment added successfully"); window.location.reload();
window.location.reload(); }
} catch (error) { } catch (Err) {
console.log(error.response); console.log(Err.response);
} }
}; };
useEffect(() => { const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
FetchData();
}, []); const renderOrderBody = (item, index) => (
<tr key={index}>
<td>{index + 1}</td>
<td>{item.requiredDate}</td>
<td>{item.itemName}</td>
<td>{item.quantity}</td>
<td>
<div className="row-user" style={{ paddingTop: "0" }}>
{item.isApprovedByOfficer === "rejected" ? (
<Badge type="danger" content={item.isApprovedByOfficer} />
) : item.isApprovedByManager === "rejected" ? (
<Badge type="danger" content={item.isApprovedByManager} />
) : item.isApprovedByManager === "pending" ? (
<Badge type="warning" content={item.isApprovedByManager} />
) : item.isApprovedByManager === "approved" ? (
<Badge type="success" content={item.isApprovedByManager} />
) : (
""
)}
</div>
</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} />
) : (
""
)
) : (
""
)}
</div>
</td>
<td className="">
{item.isApprovedByManager === "pending" &&
!(item.isApprovedByOfficer === "rejected") ? (
<>
<button className="action-btn x">
<MdDelete
onClick={() => {
if (window.confirm("Are you sure to delete this request?")) {
deleteHandler(item._id);
}
}}
/>
</button>
</>
) : item.isApprovedByManager === "rejected" ||
item.isApprovedByOfficer === "rejected" ? (
<>
<button className="action-btn W">
<VscReport
onClick={() => {
setName("Rejection");
setDescription(item.rejectMassage);
setTrigger(true);
}}
/>
</button>
<Popup
trigger={Trigger}
name={Name}
description={Description}
setTrigger={setTrigger}
id={Id}
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>
) : (
""
)}
</td>
</tr>
);
return ( return (
<div> <div>
...@@ -64,19 +187,57 @@ const StudentSubjectAssingment = () => { ...@@ -64,19 +187,57 @@ const StudentSubjectAssingment = () => {
<div id="main" className="layout__content"> <div id="main" className="layout__content">
<TopNav /> <TopNav />
<div className="layout__content-main"> <div className="layout__content-main">
<h1 className="page-header"> Assignments</h1> <h1 className="page-header">CTSE Module Assignments</h1>
<div className="row"> <div className="row">
<div className="col-12"> <div className="col-12">
<div className="card"> <div className="card">
<div className="flex"> <div className="flex">
<h2 className="request-title">{assignment.title}</h2> <h2 className="request-title">Asignment 01</h2>
</div> </div>
<br /> <br />
<h3> <h3>
Analyze the case study given below and draw a usecase diagram. Analyze the case study given below and draw a usecase diagram.
</h3> </h3>
<br /> <br />
<p>{assignment.content}</p> <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.
</p>
</div> </div>
</div> </div>
</div> </div>
...@@ -90,15 +251,15 @@ const StudentSubjectAssingment = () => { ...@@ -90,15 +251,15 @@ const StudentSubjectAssingment = () => {
style={{ float: "right" }} style={{ float: "right" }}
accept=".png, .jpg, .jpeg" accept=".png, .jpg, .jpeg"
type="file" type="file"
onChange={fileHandler} onChange={(e) =>
setOrder({ ...Order, quantity: e.target.value })
}
required required
/> />
</div> </div>
</div> </div>
<div className="row-user"> <div className="row-user">
<button type="submit" onClick={onSubmit}> <button type="submit">Submit</button>
Submit
</button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -2,8 +2,11 @@ import React, { useContext } from "react"; ...@@ -2,8 +2,11 @@ import React, { useContext } from "react";
import { Route, Switch } from "react-router-dom"; import { Route, Switch } from "react-router-dom";
import Assign from "../pages/Assign"; import Assign from "../pages/Assign";
import DeliveryReportSubmit from "../pages/DeliveryReportSubmit";
import Inventory from "../pages/Inventory"; import Inventory from "../pages/Inventory";
import Login from "../pages/Login"; import Login from "../pages/Login";
import ManageAllOrders from "../pages/ManageAllOrders";
import ManageDeliveryReports from "../pages/ManageDeliveryReports";
import ManageAssignments from "../pages/ManageAssignments"; import ManageAssignments from "../pages/ManageAssignments";
import SubjectsStudent from "../pages/SubjectsStudent"; import SubjectsStudent from "../pages/SubjectsStudent";
import ManagerApprovedOrders from "../pages/ManagerApprovedOrders"; import ManagerApprovedOrders from "../pages/ManagerApprovedOrders";
...@@ -11,7 +14,10 @@ import TeacherDashboard from "../pages/TeacherDashboard"; ...@@ -11,7 +14,10 @@ import TeacherDashboard from "../pages/TeacherDashboard";
import ManageServices from "../pages/ManageServices"; import ManageServices from "../pages/ManageServices";
import ManageStudents from "../pages/ManageStudents"; import ManageStudents from "../pages/ManageStudents";
import ManageModules from "../pages/ManageModules"; import ManageModules from "../pages/ManageModules";
import OfficerDashboard from "../pages/OfficerDashboard";
import OfficerOrders from "../pages/OfficerOrders";
import Register from "../pages/Register"; import Register from "../pages/Register";
import SiteManagerDashboard from "../pages/SiteManagerDashboard";
import StudentSubjectAssingment from "../pages/StudentSubjectAssingment"; import StudentSubjectAssingment from "../pages/StudentSubjectAssingment";
import ViewAssignment from "../pages/ViewAssignment"; import ViewAssignment from "../pages/ViewAssignment";
import StudentDashboard from "../pages/StudentDashboard"; import StudentDashboard from "../pages/StudentDashboard";
...@@ -30,42 +36,18 @@ const Routes = () => { ...@@ -30,42 +36,18 @@ const Routes = () => {
<Route exact path="/register" component={Register} /> <Route exact path="/register" component={Register} />
<Route exact path="/login" component={Login} /> <Route exact path="/login" component={Login} />
<Route <Route exact path="/auth/teacher/dashboard" component={TeacherDashboard} />
exact
path="/auth/teacher/dashboard"
component={TeacherDashboard}
/>
<Route exact path="/auth/teacher/students" component={ManageStudents} /> <Route exact path="/auth/teacher/students" component={ManageStudents} />
<Route exact path="/auth/teacher/modules" component={ManageModules} /> <Route exact path="/auth/teacher/modules" component={ManageModules} />
<Route <Route exact path="/auth/teacher/assignments" component={ManageAssignments} />
exact <Route exact path="/auth/teacher/assignments/:id" component={ViewAssignment} />
path="/auth/teacher/assignments" <Route exact path="/auth/teacher/assignments/:id/diagrams" component={GeneratedDiagrams} />
component={ManageAssignments}
/>
<Route
exact
path="/auth/teacher/assignments/:id"
component={ViewAssignment}
/>
<Route
exact
path="/auth/teacher/assignments/:id/diagrams"
component={GeneratedDiagrams}
/>
<Route <Route exact path="/auth/student/dashboard" component={StudentDashboard} />
exact
path="/auth/student/dashboard"
component={StudentDashboard}
/>
<Route exact path="/auth/student/modules" component={SubjectsStudent} /> <Route exact path="/auth/student/modules" component={SubjectsStudent} />
<Route exact path="/auth/student/services" component={ManageServices} /> <Route exact path="/auth/student/services" component={ManageServices} />
<Route <Route exact path="/auth/student/assignment" component={StudentSubjectAssingment} />
exact
path="/auth/student/assignment/:id"
component={StudentSubjectAssingment}
/>
</Switch> </Switch>
); );
}; };
......
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