Commit 9fa8abcb authored by Jayasith H.B.C's avatar Jayasith H.B.C

fix

parent 768aeabf
No preview for this file type
...@@ -14,15 +14,16 @@ submission = Blueprint('submissions', __name__, url_prefix='/api/v1/submissions' ...@@ -14,15 +14,16 @@ submission = Blueprint('submissions', __name__, url_prefix='/api/v1/submissions'
@submission.post('/upload') @submission.post('/upload')
@jwt_required()
def upload_submission(): def upload_submission():
user_id = get_jwt_identity() user_id = 1
image = request.files['file'] # image = request.files['file']
json_data = json.loads(request.form['data']) a = request.get_json()
json_data = request.get_json()
submission_type = json_data['type'] submission_type = json_data['type']
assignment_id = json_data['id'] assignment_id = json_data['id']
comment = json_data['comment'] comment = json_data['comment']
image = json_data['file']
if submission_type is None or image is None or assignment_id is None: if submission_type is None or image is None or assignment_id is None:
return jsonify({'err': 'invalid request '}), HTTP_400_BAD_REQUEST return jsonify({'err': 'invalid request '}), HTTP_400_BAD_REQUEST
......
...@@ -29,6 +29,7 @@ const StudentSubjectAssingment = () => { ...@@ -29,6 +29,7 @@ const StudentSubjectAssingment = () => {
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 [data, setData] = useState({file:null,id:"1",comment:"comment",type:"use case"});
const [Order, setOrder] = useState({ const [Order, setOrder] = useState({
item: {}, item: {},
...@@ -55,24 +56,13 @@ const StudentSubjectAssingment = () => { ...@@ -55,24 +56,13 @@ const StudentSubjectAssingment = () => {
FetchData(); FetchData();
}, []); }, []);
const deleteHandler = async (id) => { const upload = async (e) => {
console.log(id);
try { try {
const res = await axios.delete(`/orders/delete/${id}`); console.log(data);
const res = await axios.post("/submissions/upload", data);
if (res.statusText === "OK") { if (res.statusText === "OK") {
window.location.reload(); console.log(res.data);
}
} 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) { } catch (Err) {
console.log(Err.response); console.log(Err.response);
...@@ -131,7 +121,7 @@ const StudentSubjectAssingment = () => { ...@@ -131,7 +121,7 @@ const StudentSubjectAssingment = () => {
<MdDelete <MdDelete
onClick={() => { onClick={() => {
if (window.confirm("Are you sure to delete this request?")) { if (window.confirm("Are you sure to delete this request?")) {
deleteHandler(item._id);
} }
}} }}
/> />
...@@ -252,14 +242,14 @@ const StudentSubjectAssingment = () => { ...@@ -252,14 +242,14 @@ const StudentSubjectAssingment = () => {
accept=".png, .jpg, .jpeg" accept=".png, .jpg, .jpeg"
type="file" type="file"
onChange={(e) => onChange={(e) =>
setOrder({ ...Order, quantity: e.target.value }) setData({...data, file:e.target.value})
} }
required required
/> />
</div> </div>
</div> </div>
<div className="row-user"> <div className="row-user">
<button type="submit">Submit</button> <button type="submit" onClick={upload}>Submit</button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -47,7 +47,7 @@ const Routes = () => { ...@@ -47,7 +47,7 @@ const Routes = () => {
<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 exact path="/auth/student/assignment" component={StudentSubjectAssingment} /> <Route 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