Skip to content

Commit

Permalink
fixing lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ridz1208 committed Dec 2, 2024
1 parent 8aa0218 commit 0e295ae
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
3 changes: 3 additions & 0 deletions modules/biobank/jsx/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ Header.propTypes = {
coordinate: PropTypes.string,
}).isRequired,
specimen: PropTypes.shape({
barcode: PropTypes.string,
candidatePSCID: PropTypes.string,
sampleNumber: PropTypes.string,
quantity: PropTypes.number,
poolId: PropTypes.number,
typeId: PropTypes.number.isRequired,
Expand Down
33 changes: 18 additions & 15 deletions modules/biobank/jsx/poolSpecimenForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const initialState = {
candidateId: null,
sessionid: null,
typeId: null,
centerId: null
centerId: null,
},
poolId: null,
count: 0,
Expand All @@ -40,7 +40,7 @@ class PoolSpecimenForm extends React.Component {
super();
this.state = initialState;
this.setPool = this.setPool.bind(this);
this.setFilter = this.setFilter.bind(this);
this.setFilter = this.setFilter.bind(this);
this.validateListItem = this.validateListItem.bind(this);
this.setPoolList = this.setPoolList.bind(this);
}
Expand All @@ -64,7 +64,6 @@ class PoolSpecimenForm extends React.Component {
* @param {string} value - the filter values
*/
setFilter(name, value) {
console.log(name+': '+value);
const {filter} = clone(this.state);

if (name == 'candidateId') {
Expand All @@ -73,15 +72,15 @@ class PoolSpecimenForm extends React.Component {

filter[name] = value;
this.setState({filter});
}
}

/**
* Sets the current pool list
*
* @param {number} containerId - specimen to be added to pool via containerId
*/
setPoolList(containerId) {
let {current, list, pool, count} = clone(this.state);
let {filter, list, pool, count} = clone(this.state);

// Increase count
count++;
Expand All @@ -95,7 +94,7 @@ class PoolSpecimenForm extends React.Component {
filter.candidateId = specimen.candidateId;
filter.sessionId = specimen.sessionId;
filter.typeId = specimen.typeId;
filter.centerId = container.centerId;
filter.centerId = container.centerId;
}

// Set list values
Expand Down Expand Up @@ -147,7 +146,7 @@ class PoolSpecimenForm extends React.Component {
const specimen = this.props.data.specimens[container.specimenId];

// Throw error if new list item does not meet requirements.
if (!isEmpty(list)
if (!isEmpty(list)
&& (specimen.candidateId != filter.candidateId
|| specimen.sessionId != filter.sessionId
|| specimen.typeId != filter.typeId
Expand Down Expand Up @@ -236,7 +235,10 @@ class PoolSpecimenForm extends React.Component {
onUserInput={this.setFilter}
disabled={!isEmpty(list) || !filter.candidateId}
value={filter.sessionId}
options={mapFormOptions((options?.candidateSessions?.[filter.candidateId] || {}), 'label')}
options={mapFormOptions(
(options?.candidateSessions?.[filter.candidateId] || {}),
'label'
)}
/>
<div className='row'>
<div className='col-xs-6'>
Expand Down Expand Up @@ -348,12 +350,8 @@ PoolSpecimenForm.propTypes = {
})
).isRequired,
}).isRequired,
filter: PropTypes.shape({
candidateId: PropTypes.string,
sessionId: PropTypes.string,
typeId: PropTypes.string,
}).isRequired,
options: PropTypes.shape({
candidateSessions: PropTypes.obj,
specimen: PropTypes.shape({
units: PropTypes.string,
types: PropTypes.arrayOf(PropTypes.string),
Expand Down Expand Up @@ -395,7 +393,7 @@ class BarcodeInput extends PureComponent {
const sessionMatch = !filter.sessionId
|| specimen.sessionId == filter.sessionId;
const typeMatch = !filter.typeId
|| specimen.typeId == filter.typeId;
|| specimen.typeId == filter.typeId;

if (specimen.quantity > 0
&& container.statusId == availableId
Expand All @@ -404,7 +402,7 @@ class BarcodeInput extends PureComponent {
&& candidateMatch
&& sessionMatch
&& typeMatch
) {
) {
result[container.id] = container.barcode;
}
}
Expand Down Expand Up @@ -444,6 +442,11 @@ BarcodeInput.propTypes = {
})
).isRequired,
}).isRequired,
filter: PropTypes.shape({
candidateId: PropTypes.string,
sessionId: PropTypes.string,
typeId: PropTypes.string,
}).isRequired,
options: PropTypes.shape({
container: PropTypes.shape({
types: PropTypes.arrayOf(
Expand Down
8 changes: 4 additions & 4 deletions modules/biobank/jsx/specimenForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ class SpecimenForm extends React.Component {
*/
async fetchBarcodes(limit) {
try {
const response = await fetch(`${loris.BaseURL}/biobank/barcodes?limit=${limit}`);
const response = await fetch(
`${loris.BaseURL}/biobank/barcodes?limit=${limit}`
);
const data = await response.json();
return data.barcodes;
} catch (error) {
Expand All @@ -177,12 +179,10 @@ class SpecimenForm extends React.Component {
* Generate barcodes and store in the component state.
*/
async generateBarcodes() {
const {options} = this.props;
let {list, current} = this.state;
let {list} = this.state;
const limit = Object.keys(list).length;

const barcodes = await this.fetchBarcodes(limit);
console.log(barcodes);

list = Object.keys(list).reduce((result, key, index) => {
const specimen = list[key];
Expand Down

0 comments on commit 0e295ae

Please sign in to comment.