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 @@ -89,7 +89,7 @@ class BasicInfoSection extends Component {
id="latitude"
label={t("BOARDING_PAGE.VIEW_BOARDING.LATITUDE")}
value={location[0]}
onChange={({ target: { value } }) => this.handleLocationChange('lat', value)}
onChange={({ target }) => this.handleLocationChange('lat', parseFloat(target.value))}
type="number"
/>
</div>
Expand All @@ -100,7 +100,7 @@ class BasicInfoSection extends Component {
id="longitude"
label={t("BOARDING_PAGE.VIEW_BOARDING.LONGITUDE")}
value={location[1]}
onChange={({ target: { value } }) => this.handleLocationChange('long', value)}
onChange={({ target }) => this.handleLocationChange('long', parseFloat(target.value))}
type="number"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class BoardingNewPage extends Component {
let formData = {
...this.state.dataToSave,
crew: this.state.dataToSave.crew.map(x => ({ name: x.name, license: x.license })),
timestamp: Date.now(),
inspection: {
...this.state.dataToSave.inspection,
actualCatch: this.state.dataToSave.inspection.actualCatch.map(x => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/boardings/boarding-new/catch/CatchItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const CatchItem = ({ catchItem, species, onChange, handleAdd, handleDelet
className="new-boarding__catch--weight"
name="weight"
value={catchItem.weight}
onChange={e => onChange({ ...catchItem, weight: e.target.value })}
onChange={e => onChange({ ...catchItem, weight: parseFloat(e.target.value) })}
/>
<FormControl className="new-boarding__catch--units">
<InputLabel id={`catch-units-${catchItem.id}`}>
Expand All @@ -72,7 +72,7 @@ export const CatchItem = ({ catchItem, species, onChange, handleAdd, handleDelet
className="new-boarding__catch--count"
name="number"
value={catchItem.number}
onChange={e => onChange({ ...catchItem, number: e.target.value })}
onChange={e => onChange({ ...catchItem, number: e.target.valueAsNumber })}
/>
</div>
<p onClick={handleDelete} style={{ textAlign: "right" }} className="blue-color font-16 pointer margin-top">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ class VesselSection extends Component {
required
disableToolbar
variant="inline"
format="yyyy/MM/DD"
format="YYYY/MM/DD"
margin="normal"
id="ldd-date-picker"
className="third-row-view last-date-delivery"
label={t("TABLE.DATE")}
value={date}
onChange={(date) =>
this.handleChange("lastDelivery", "date", date)
this.handleChange("lastDelivery", "date", date.toDate())
}
KeyboardButtonProps={{
"aria-label": "change date",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export const ViolationItem = ({
const values = e.target.value.split("@@@");
onChange({
...violation,
offence: {
code: values[0],
explanation: values[1],
crewMember: {
name: values[0],
license: values[1],
}
})
}}
Expand Down
77 changes: 77 additions & 0 deletions src/components/dashboards/draft-boarding.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React from 'react';
import BoardingService from "./../../services/boarding.service";
import withRouter from "../../helpers/withRouter";
import moment from 'moment';
import { useTranslation } from 'react-i18next';
import { EDIT_BOARDING_PAGE } from "../../root/root.constants.js";

const boardingService = BoardingService.getInstance();


const DraftBoardingList = ({ router }) => {
const [drafts, setDrafts] = React.useState([]);
React.useEffect(() => {
boardingService.getDraftBoardings().then(setDrafts);
}, []);
const { t } = useTranslation();

const goEdit = (id) => {
router.navigate(EDIT_BOARDING_PAGE.replace(":id", id));
}
return (
<div className="flex-column align-center white-bg box-shadow standard-view margin-top margin-bottom padding-bottom">
<div className="flex-row justify-between align-end full-view padding-top padding-bottom border-bottom">
<div className="main-info">
<div className="item-name">
{t("HOME_PAGE.MY_DRAFT_BOARDINGS")}
</div>
</div>
</div>
<div className="table-wrapper">
<table className="custom-table boardings-table">
<thead>
<tr className="table-row row-head border-bottom">
<td>{t("TABLE.DATE")}</td>
<td>{t("TABLE.TIME")}</td>
<td>{t("TABLE.VESSEL")}</td>
<td width={200}></td>
</tr>
</thead>
<tbody>
{drafts.map((draft, ind) => (
<tr
className="table-row row-body"
key={ind}
>
<td> {moment(draft.date).format("l LT")}</td>
<td> {moment(draft.date).format("LT")}</td>
<td> {draft.vessel ? draft.vessel.name : ""}</td>
<td>
<div className="flex-row align-items-center">
<div
className="pointer see-all"
onClick={() => goEdit(draft._id)}
style={{
marginRight: 10
}}
>
{t("BUTTONS.EDIT")}
</div>
<div
className="pointer see-all"
onClick={() => boardingService.deleteBoarding(draft._id)}
>
{t("BUTTONS.DELETE")}
</div>
</div>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
)
}

export default withRouter(DraftBoardingList);
2 changes: 2 additions & 0 deletions src/components/dashboards/field-dashboard.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getHighlightedText } from "./../../helpers/get-data";
import BoardingService from "./../../services/boarding.service";
import AuthService from "./../../services/auth.service";
import AgencyService from "./../../services/agency.service";
import DraftBoardingList from "./draft-boarding.component";

const authService = AuthService.getInstance();
const boardingService = BoardingService.getInstance();
Expand Down Expand Up @@ -158,6 +159,7 @@ class FieldDashboard extends Component {
<DatesRange onFilterChange={this.changeFilter} />
</div>
</div>
{!isFromActivities && <DraftBoardingList />}
<div className="white-bg box-shadow standard-view margin-bottom">
<div className="flex-row justify-between align-end full-view padding-top padding-bottom border-bottom">
<div className="main-info">
Expand Down
1 change: 1 addition & 0 deletions src/helpers/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"HOME_PAGE": {
"DASHBOARD": "Dashboard",
"MY_BOARDINGS": "My Boardings",
"MY_DRAFT_BOARDINGS": "My Draft Boardings",
"MY_ACTIVITY": "My Activity",
"OVERVIEW": "Overview for",
"COMPLIANCE_RATE": "Compliance Rate",
Expand Down
18 changes: 18 additions & 0 deletions src/services/boarding.service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { BSON } from "mongodb-stitch-browser-sdk";
import StitchService from "./stitch.service";
import AuthService from "./auth.service";

const authService = AuthService.getInstance();
const stitchService = StitchService.getInstance();

const sampleData = {
Expand Down Expand Up @@ -132,6 +134,22 @@ export default class BoardingService {
]);
}

getDraftBoardings() {
return stitchService.database
.collection("BoardingReports")
.find({ draft: true, "reportingOfficer.email": authService.user.email }).toArray();
}

deleteBoarding(id) {


const objectId = new BSON.ObjectId(id);

return stitchService.database
.collection("BoardingReports")
.deleteOne({ _id: objectId });
}

getBoardingsWithFacet(limit, offset, search, filter, agenciesToShareData) {
return stitchService.client.callFunction("searchFacetByBoardings", [
limit,
Expand Down