Skip to content

Commit

Permalink
fixing lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ridz1208 committed Nov 26, 2024
1 parent 00a63be commit 6b85103
Show file tree
Hide file tree
Showing 15 changed files with 391 additions and 55 deletions.
15 changes: 8 additions & 7 deletions modules/biobank/jsx/Shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ class Shipment {
/**
* Constructor
*
* @param {string} id - shipment id
* @param {string} barcode - shipment barcode
* @param {string} type - shipment type
* @param {number} destinationCenterId - shipment destination
* @param {array} logs - logs for this shipment
* @param {array} containerIds - containers in this shipment
*/
* @param {Object} params - The shipment parameters
* @param {string} params.id - Shipment ID
* @param {string} params.barcode - Shipment barcode
* @param {string} params.type - Shipment type
* @param {number} params.destinationCenterId - Destination center ID
* @param {Array} params.logs - Logs for this shipment
* @param {Array} params.containerIds - Container IDs in this shipment
*/
constructor({
id = null,
barcode = null,
Expand Down
2 changes: 1 addition & 1 deletion modules/biobank/jsx/biobankIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ class BiobankIndex extends React.Component {
}

// biobankIndex.propTypes
biobankIndex.propTypes = {
BiobankIndex.propTypes = {
specimenAPI: PropTypes.object.isRequired,
containerAPI: PropTypes.object.isRequired,
poolAPI: PropTypes.object.isRequired,
Expand Down
1 change: 1 addition & 0 deletions modules/biobank/jsx/containerDisplay.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useEffect} from 'react';
import PropTypes from 'prop-types';
import Swal from 'sweetalert2';

import {
Expand Down
2 changes: 2 additions & 0 deletions modules/biobank/jsx/containerParentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {clone} from './helpers';
*
* Fetches data from Loris backend and displays a form allowing
* to specimen a biobank file attached to a specific instrument
*
* @param props The component's props
*/
function ContainerParentForm(props) {
const {data, current, options} = props;
Expand Down
2 changes: 2 additions & 0 deletions modules/biobank/jsx/customFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import PropTypes from 'prop-types';

/**
* Biobank Custom Attribute Fields
*
* @param props The component's props.
*/
function CustomFields(props) {
const {options, errors, fields, object} = props;
Expand Down
60 changes: 57 additions & 3 deletions modules/biobank/jsx/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import ContainerParentForm from './containerParentForm';

/**
* Biobank Globals Component
*
* @param props The component's props
*/
function Globals(props) {
const {current, data, editable, options, specimen, container} = props;
Expand Down Expand Up @@ -406,13 +408,16 @@ function Globals(props) {
}

// Globals.propTypes
// // Globals.propTypes
Globals.propTypes = {
current: PropTypes.shape({
container: PropTypes.shape({
parentContainerId: PropTypes.number,
typeId: PropTypes.number.isRequired,
coordinate: PropTypes.string,
statusId: PropTypes.number, // Added
temperature: PropTypes.number, // Added
lotNumber: PropTypes.string,
expirationDate: PropTypes.string,
}).isRequired,
specimen: PropTypes.shape({
poolId: PropTypes.number,
Expand All @@ -427,6 +432,7 @@ Globals.propTypes = {
parentSpecimenBarcodes: PropTypes.arrayOf(PropTypes.string),
}).isRequired,
}).isRequired,

data: PropTypes.shape({
pools: PropTypes.array.isRequired,
containers: PropTypes.arrayOf(
Expand All @@ -437,24 +443,51 @@ Globals.propTypes = {
shipmentBarcodes: PropTypes.arrayOf(PropTypes.string),
centerId: PropTypes.number,
parentContainerBarcode: PropTypes.string,
statusId: PropTypes.number, // Added
temperature: PropTypes.number, // Added
comments: PropTypes.string, // Added
})
).isRequired,
}).isRequired,

editable: PropTypes.shape({
containerType: PropTypes.func.isRequired,
fTCycle: PropTypes.func.isRequired,
project: PropTypes.func.isRequired,
quantity: PropTypes.func.isRequired,
containerParentForm: PropTypes.func.isRequired,
temperature: PropTypes.func.isRequired, // Added
status: PropTypes.func.isRequired, // Added
}).isRequired,

options: PropTypes.shape({
specimen: PropTypes.shape({
typeUnits: PropTypes.string,
types: PropTypes.arrayOf(PropTypes.string),
units: PropTypes.string, // Added
types: PropTypes.arrayOf(
PropTypes.shape({
label: PropTypes.string.isRequired,
})
),
attributes: PropTypes.arrayOf(
PropTypes.shape({
label: PropTypes.string.isRequired,
})
),
protocols: PropTypes.arrayOf(PropTypes.string),
protocolAttributes: PropTypes.arrayOf(
PropTypes.shape({
label: PropTypes.string.isRequired,
})
),
}).isRequired,
container: PropTypes.shape({
typesPrimary: PropTypes.arrayOf(PropTypes.string).isRequired,
types: PropTypes.arrayOf(PropTypes.string).isRequired,
types: PropTypes.arrayOf(
PropTypes.shape({
label: PropTypes.string.isRequired,
})
).isRequired,
typesNonPrimary: PropTypes.arrayOf(PropTypes.string).isRequired,
stati: PropTypes.arrayOf(
PropTypes.shape({
Expand All @@ -469,7 +502,14 @@ Globals.propTypes = {
sessionCenters: PropTypes.arrayOf(PropTypes.string),
candidates: PropTypes.arrayOf(PropTypes.string),
sessions: PropTypes.arrayOf(PropTypes.string),
candidateSessions: PropTypes.arrayOf(PropTypes.string), // Added
attributes: PropTypes.arrayOf(
PropTypes.shape({
label: PropTypes.string.isRequired,
})
), // Assuming based on errors
}).isRequired,

specimen: PropTypes.shape({
typeId: PropTypes.number.isRequired,
poolId: PropTypes.number,
Expand All @@ -482,14 +522,19 @@ Globals.propTypes = {
parentSpecimenIds: PropTypes.arrayOf(PropTypes.number),
parentSpecimenBarcodes: PropTypes.arrayOf(PropTypes.string),
}).isRequired,

container: PropTypes.shape({
centerId: PropTypes.number,
shipmentBarcodes: PropTypes.arrayOf(PropTypes.string),
parentContainerId: PropTypes.number,
coordinate: PropTypes.string,
typeId: PropTypes.number.isRequired,
parentContainerBarcode: PropTypes.string,
statusId: PropTypes.number, // Added
temperature: PropTypes.number, // Added
comments: PropTypes.string, // Added
}).isRequired,

updateContainer: PropTypes.func.isRequired,
editContainer: PropTypes.func.isRequired,
setContainer: PropTypes.func.isRequired,
Expand All @@ -507,9 +552,14 @@ Globals.propTypes = {
getParentContainerBarcodes: PropTypes.func.isRequired,
getBarcodePathDisplay: PropTypes.func.isRequired,
setSpecimen: PropTypes.func.isRequired,
uC: PropTypes.any.isRequired, // Added based on error

errors: PropTypes.shape({
container: PropTypes.shape({
typeId: PropTypes.string,
temperature: PropTypes.string, // Added
statusId: PropTypes.string, // Added
comments: PropTypes.string, // Added
}),
specimen: PropTypes.shape({
quantity: PropTypes.string,
Expand All @@ -532,6 +582,10 @@ function Item(props) {
return <div className="item">{props.children}</div>;
}

Item.propTypes = {
children: PropTypes.node.isRequired,
}

/**
* Inline Field
*
Expand Down
2 changes: 2 additions & 0 deletions modules/biobank/jsx/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ Header.propTypes = {
typeId: PropTypes.number.isRequired,
}).isRequired,
}).isRequired,
data: PropTypes.obj.isRequired,
setContainer: PropType.func.isRequired,
updateContainer: PropTypes.func.isRequired,
edit: PropTypes.func.isRequired,
increaseCoordinate: PropTypes.func.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion modules/biobank/jsx/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function mapFormOptions(object, attribute) {
* Check if an object is either null or an empty object
*
* @param {object} object - the variable to check
* @return {bool}
* @return {boolean}
*/
export function isEmpty(object) {
if (object == null) {
Expand Down
8 changes: 2 additions & 6 deletions modules/biobank/jsx/lifeCycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ class LifeCycle extends React.Component {
let preparationNode;
if ((this.props.specimen||{}).preparation) {
preparationNode = (
<div
className='lifecycle-node preparation'
>
<div className='letter'>
P
</div>
<div className='lifecycle-node preparation'>
<div className='letter'>P</div>
</div>
);
}
Expand Down
5 changes: 2 additions & 3 deletions modules/biobank/jsx/poolTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,8 @@ PoolTab.propTypes = {
}).isRequired,
options: PropTypes.shape({
specimen: PropTypes.shape({
units: PropTypes.string,
types: PropTypes.arrayOf(PropTypes.string),
'types[].label': PropTypes.string,
units: PropTypes.array,
types: PropTypes.array,
}).isRequired,
centers: PropTypes.arrayOf(PropTypes.string).isRequired,
candidates: PropTypes.arrayOf(PropTypes.string),
Expand Down
14 changes: 10 additions & 4 deletions modules/biobank/jsx/processForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ const SpecimenProcessForm = (props) => {
([id, protocol]) => {
// FIXME: I really don't like 'toLowerCase()' function, but it's the
// only way I can get it to work at the moment.
if (typeId == protocol.typeId
&& options.specimen.processes[protocol.processId].label.toLowerCase() ==processStage
const process = options.specimen.processes[protocol.processId].label
.toLowerCase();
if (typeId == protocol.typeId && process == processStage
) {
specimenProtocols[id] = protocol.label;
specimenProtocolAttributes[id] = options.specimen.protocolAttributes[id];
const attribute = options.specimen.protocolAttributes[id];
specimenProtocolAttributes[id] = attribute;
}
}
);
Expand Down Expand Up @@ -268,6 +270,7 @@ SpecimenProcessForm.propTypes = {
label: PropTypes.string.isRequired,
})
),
units: PropTypes.obj.isRequired,
protocols: PropTypes.arrayOf(PropTypes.string),
protocolAttributes: PropTypes.arrayOf(
PropTypes.shape({
Expand All @@ -279,8 +282,9 @@ SpecimenProcessForm.propTypes = {
candidates: PropTypes.arrayOf(PropTypes.string),
candidateSessions: PropTypes.arrayOf(PropTypes.string),
sessions: PropTypes.arrayOf(PropTypes.string),
examinaters: PropTypes.arrayOf(PropTypes.string),
examiners: PropTypes.arrayOf(PropTypes.string),
}).isRequired,
specimen: PropTypes.object.isRequired,
errors: PropTypes.shape({
quantity: PropTypes.string,
unitId: PropTypes.string,
Expand All @@ -299,6 +303,8 @@ SpecimenProcessForm.propTypes = {
printLabel: PropTypes.func.isRequired,
getParentContainerBarcodes: PropTypes.func.isRequired,
getBarcodePathDisplay: PropTypes.func.isRequired,
setParent: PropTypes.func.isRequired,
updateSpecimen: PropTypes.func.isRequired,
};

export default SpecimenProcessForm;
5 changes: 2 additions & 3 deletions modules/biobank/jsx/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ class Search extends PureComponent {
render() {
const onInput = (name, value) => {
this.setState({barcode: value});
if (Object.values(this.props.barcodes).find(
(barcode) => barcode == value
)
if (Object.values(this.props.barcodes)
.find((barcode) => barcode == value)
) {
this.props.history.push(`/barcode=${value}`);
this.props.onClose();
Expand Down
42 changes: 23 additions & 19 deletions modules/biobank/jsx/shipmentTab.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {useState, useEffect, useRef} from 'react';
import PropTypes from 'prop-types';
import {Link} from 'react-router-dom';

import FilterableDataTable from 'FilterableDataTable';
Expand Down Expand Up @@ -185,9 +186,9 @@ function ShipmentTab({
/**
* Returns some dom elements with information about a shipment
*
* @param {object} shipment - the shipment
* @param {object} containers - containers
* @param {object} centers - centers
* @param {object} props - The parameters
* @param {object} props.shipment - the shipment
* @param {object} props.centers - centers
* @return {JSX}
*/
function ShipmentInformation({
Expand Down Expand Up @@ -271,14 +272,15 @@ function ShipmentInformation({
/**
* Modal form to create a shipment
*
* @param {boolean} data.show
* @param {object} data - the default data
* @param {object} centers - the centers
* @param {object} types - the types of shipments
* @param {object} users - a list of selectable users
* @param {function} updateShipments - an update callback
* @param {function} setData - an update callback
* @param {function} data.setShow
* @param {object} props all the properties
* @param {boolean} props.show
* @param {object} props.data - the default data
* @param {object} props.centers - the centers
* @param {object} props.types - the types of shipments
* @param {object} props.users - a list of selectable users
* @param {function} props.updateShipments - an update callback
* @param {function} props.setData - an update callback
* @param {function} props.setShow
* @return {JSX}
*/
function CreateShipment({
Expand Down Expand Up @@ -389,10 +391,11 @@ function CreateShipment({
/**
* React Component for a received shipment
*
* @param {object} shipment - the shipment
* @param {object} users - the users for the dropdown
* @param {function} updateShipments - an update callback
* @param {function} setData - a callback for setting data
* @param {object} props - The parameters
* @param {object} props.shipment - the shipment
* @param {object} props.users - the users for the dropdown
* @param {function} props.updateShipments - an update callback
* @param {function} props.setData - a callback for setting data
* @return {JSX}
*/
function ReceiveShipment({
Expand Down Expand Up @@ -438,10 +441,11 @@ function ReceiveShipment({
/**
* Return a form for the shipment log
*
* @param {object} log - the log
* @param {callback} setLog - a callback for when the log is set
* @param {object} errors - a list of errors
* @param {object} users - a list of selectable users
* @param {object} props - the parameters
* @param {object} props.log - the log
* @param {callback} props.setLog - a callback for when the log is set
* @param {object} props.errors - a list of errors
* @param {object} props.users - a list of selectable users
* @return {JSX}
*/
function ShipmentLogForm({
Expand Down
Loading

0 comments on commit 6b85103

Please sign in to comment.