Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate out queue and LIMS APIs from Redux #1293

Merged
merged 1 commit into from
Jul 8, 2024
Merged
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
34 changes: 11 additions & 23 deletions ui/src/actions/login.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable promise/catch-or-return */
/* eslint-disable promise/prefer-await-to-then */

import fetch from 'isomorphic-fetch';
import { fetchBeamInfo, fetchBeamlineSetup } from '../api/beamline';
import { fetchDiffractometerInfo } from '../api/diffractometer';
import { fetchLogMessages } from '../api/log';
Expand All @@ -16,6 +14,7 @@ import { fetchSampleChangerInitialState } from '../api/sampleChanger';
import { fetchHarvesterInitialState } from '../api/harvester';
import { fetchImageData, fetchShapes } from '../api/sampleview';
import { fetchRemoteAccessState } from '../api/remoteAccess';
import { sendSelectProposal } from '../api/lims';

export function setLoginInfo(loginInfo) {
return {
Expand Down Expand Up @@ -50,7 +49,7 @@ export function hideProposalsForm() {
};
}

export function selectProposal(prop) {
export function selectProposalAction(prop) {
return {
type: 'SELECT_PROPOSAL',
proposal: prop,
Expand All @@ -61,29 +60,18 @@ export function setInitialState(data) {
return { type: 'SET_INITIAL_STATE', data };
}

export function postProposal(number) {
return fetch('mxcube/api/v0.1/lims/proposal', {
method: 'POST',
credentials: 'include',
headers: {
Accept: 'application/json',
'Content-type': 'application/json',
},
body: JSON.stringify({ proposal_number: number }),
});
}

export function sendSelectProposal(number, navigate) {
return (dispatch) => {
postProposal(number).then((response) => {
if (response.status >= 400) {
export function selectProposal(number, navigate) {
return async (dispatch) => {
try {
await sendSelectProposal(number);
navigate('/');
dispatch(selectProposalAction(number));
} catch (error) {
if (error.status >= 400) {
dispatch(showErrorPanel(true, 'Server refused to select proposal'));
navigate('/login');
} else {
navigate('/');
dispatch(selectProposal(number));
}
});
}
};
}

Expand Down
Loading
Loading