Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ const CollectionCreateForm = Form.create({ name: "form_in_modal" })(
IDNumber: rows.s_id_number,
licenceNumber: rows.s_driver_licence_number,
status,
file: rows.s_image
file: rows.s_attachment
});
fetch(`/api/v1/image/${rows.s_image}`)
if (rows.s_attachment)
fetch(`/api/v1/image/${rows.s_attachment}`)
.then(res => res.arrayBuffer())
.then(response => {
let typeArray = new Uint8Array(response);
Expand Down
37 changes: 33 additions & 4 deletions client/src/Components/Layouts/SingleCaptains/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import View from "./Popups/viewPopUp";
import WrappedComponent from "../../HOC/WithNavSide";
import EditOrder from "./Popups/EditOrder";

import { notification, Icon } from "antd";
import { notification, Icon, Modal } from "antd";

class Viewcaptain extends Component {
state = {
Expand All @@ -22,6 +22,7 @@ class Viewcaptain extends Component {
address: "",
licience_number: "",
avatar: "",
attachment: null,
visible: false,
singleCaptain: {
editVisibilty: false,
Expand Down Expand Up @@ -61,7 +62,8 @@ class Viewcaptain extends Component {
s_mobile_number,
status,
s_address,
s_driver_licence_number
s_driver_licence_number,
s_attachment
} = rows;
let typeArray = new Uint8Array(response);
const stringChar = String.fromCharCode.apply(null, typeArray);
Expand All @@ -73,7 +75,8 @@ class Viewcaptain extends Component {
status,
address: s_address,
licience_number: s_driver_licence_number,
avatar: stringChar
avatar: stringChar,
attachment: s_attachment
});
});
} else {
Expand Down Expand Up @@ -165,10 +168,22 @@ class Viewcaptain extends Component {
}
return column;
});
return {columns}
return { columns };
});
};

handleAttatchment = e => {
fetch(`/api/v1/image/${this.state.attachment}`)
.then(res => res.arrayBuffer())
.then(response => {
let typeArray = new Uint8Array(response);
const stringChar = String.fromCharCode.apply(null, typeArray);
Modal.info({
title: <img src={stringChar} alt="ID" className="attatchment_image"/>
});
});
};

render() {
const {
columns,
Expand All @@ -180,6 +195,7 @@ class Viewcaptain extends Component {
licience_number,
phone_number,
status,
attachment,
singleCaptain
} = this.state;
return (
Expand Down Expand Up @@ -218,6 +234,19 @@ class Viewcaptain extends Component {
<p className="profile__box__title">رقم الهوية</p>
<p className="profile__value">{id_number}</p>
</div>
<div className="profile__box">
<p className="profile__box__title">صورة الهوية</p>
{attachment ? (
<p
className="profile__value-attatchement"
onClick={this.handleAttatchment}
>
الصورة
</p>
) : (
<p className="profile__value">لا يوجد صورة</p>
)}
</div>
</div>
</div>

Expand Down
13 changes: 13 additions & 0 deletions client/src/Components/Layouts/SingleCaptains/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,16 @@
.view-captain-orders .table-container {
width: 90%;
}

.profile__value-attatchement{
cursor: pointer;
background: #80808036;
padding: 0.5rem;
border: 1px solid #ababb53b;
margin-top: -0.5rem;
border-radius: 7px;
}
.attatchment_image{
width: 100%;
height: 100%;
}
4 changes: 2 additions & 2 deletions server/database/queries/captain/editCaptain.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const editCaptain = (captainInfo, id) => {
name, email, phone, address, IDNumber, licenceNumber, status, newName, pass,
} = captainInfo;
if (!pass) {
return connection.query('UPDATE TUser SET s_name = $1, s_email = $2, s_mobile_number = $3, s_address = $4, s_id_number = $5, s_driver_licence_number = $6, b_status = $7, s_image = $8, dt_modified_date = $9 WHERE pk_i_id = $10 RETURNING *', [name, email, phone, address, IDNumber, licenceNumber, status, newName, new Date(Date.now()), id]);
return connection.query('UPDATE TUser SET s_name = $1, s_email = $2, s_mobile_number = $3, s_address = $4, s_id_number = $5, s_driver_licence_number = $6, b_status = $7, s_attachment = $8, dt_modified_date = $9 WHERE pk_i_id = $10 RETURNING *', [name, email, phone, address, IDNumber, licenceNumber, status, newName, new Date(Date.now()), id]);
}
return connection.query('UPDATE TUser SET s_name = $1, s_email = $2, s_mobile_number = $3, s_address = $4, s_id_number = $5, s_driver_licence_number = $6, b_status = $7, s_image = $8, dt_modified_date = $9, s_password = $10 WHERE pk_i_id = $11 RETURNING *', [name, email, phone, address, IDNumber, licenceNumber, status, newName, new Date(Date.now()), pass, id]);
return connection.query('UPDATE TUser SET s_name = $1, s_email = $2, s_mobile_number = $3, s_address = $4, s_id_number = $5, s_driver_licence_number = $6, b_status = $7, s_attachment = $8, dt_modified_date = $9, s_password = $10 WHERE pk_i_id = $11 RETURNING *', [name, email, phone, address, IDNumber, licenceNumber, status, newName, new Date(Date.now()), pass, id]);
};

module.exports = { editCaptain };