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