Skip to content

Commit

Permalink
Merge pull request #320 from codefordenver/queueStatusChanges
Browse files Browse the repository at this point in the history
Issue #296
  • Loading branch information
ethoreson authored Dec 31, 2019
2 parents 7a5c7fc + 4098d5f commit 97c0dfb
Show file tree
Hide file tree
Showing 9 changed files with 3,077 additions and 3,440 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.node
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM node:12-alpine

COPY ./Frontend /srv

WORKDIR /srv

COPY ./Frontend /srv
RUN npm install

VOLUME /srv/node_modules
5,141 changes: 3,026 additions & 2,115 deletions Frontend/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ const ChangePasswordModal = props => {
const payload = {
username: props.username,
newPassword: newPassword,
confirmNewPassword: confirmNewPassword
confirmNewPassword: confirmNewPassword,
};

if (newPassword === confirmNewPassword) {
return RequestService.changePassword(payload, onSuccess, onFailure)
return RequestService.changePassword(payload, onSuccess, onFailure);
} else {
setError(
'The new password and confirm new password do not match. Please re-enter these values.'
'The new password and confirm new password do not match. Please re-enter these values.',
);
e.target.elements.newPassword.value = '';
e.target.elements.confirmNewPassword.value = '';
Expand All @@ -43,10 +43,7 @@ const ChangePasswordModal = props => {
};

const formBody = (
<form
className="form"
onSubmit={onSubmit}
>
<form className="form" onSubmit={onSubmit}>
<div className="form__item">
<label htmlFor="newPassword">New Password:</label>
<input
Expand All @@ -67,25 +64,25 @@ const ChangePasswordModal = props => {
type="password"
/>
</div>
<br/>
<br />
<div className="form__action">
<button type="submit">Submit</button>
<button onClick={onCancel}>Cancel</button>
</div>
<br/>
<br />
</form>
);

const onAccept = () => {
setResponse(false)
setResponse(false);
setSuccess(false);
props.triggerPasswordChange();
};

const successBody = (
<div className="success">
<h6>Password changed succesfully</h6>
<br/>
<br />
<button onClick={onAccept}>Ok</button>
</div>
);
Expand All @@ -98,15 +95,15 @@ const ChangePasswordModal = props => {
const failBody = (
<div className="fail">
<h6>An error has occurred. Please try again.</h6>
<br/>
<br />
<button onClick={onAcceptErr}>Ok</button>
</div>
);

const loadingBody = (
<div className="loading">
<Loader />
</div>
</div>
);

const onSuccess = response => {
Expand All @@ -122,36 +119,38 @@ const ChangePasswordModal = props => {
};

let errorMessage;
error ? errorMessage = (<span>{ error }</span>) : errorMessage = null;
error ? (errorMessage = <span>{error}</span>) : (errorMessage = null);

const resetError = () => {
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
wait(8000).then(() => {
setError('');
});
wait(8000).then(() => {
setError('');
});
};

let divBody;
if (loading) {
divBody = loadingBody
divBody = loadingBody;
} else if (!response) {
divBody = formBody
divBody = formBody;
} else if (response && success) {
divBody = successBody
divBody = successBody;
} else if (response && fail) {
divBody = failBody
};
divBody = failBody;
}

return (
<div
<div
className="form__container"
style={{
opacity: props.passwordChange ? '1' : '0',
transform: props.passwordChange ? 'translateY(0)' : 'translateY(-100vh)'
transform: props.passwordChange
? 'translateY(0)'
: 'translateY(-100vh)',
}}
>
<h4>Change Password</h4>
<br/>
<br />
{divBody}
{errorMessage}
</div>
Expand Down
17 changes: 14 additions & 3 deletions Frontend/src/components/Queue/QueueContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ const QueueContainer = () => {
}, [statusView]);

const returnCardStatus = cardStatus => {
const failedStatuses = ['FAILED', 'REJECTED', 'COMPLETED', 'ARCHIVED'];
const failedStatuses = ['REJECTED', 'COMPLETED', 'ARCHIVED'];
const waitingStatuses = ['PENDING_CUSTOMER_RESPONSE', 'PENDING_REVIEW'];
if (failedStatuses.indexOf(cardStatus) !== -1) {
if (cardStatus === 'FAILED') {
return 'FAILED';
} else if (failedStatuses.indexOf(cardStatus) !== -1) {
return 'DONE';
} else if (waitingStatuses.indexOf(cardStatus) !== -1) {
return 'PENDING_REVIEW';
Expand All @@ -56,6 +58,7 @@ const QueueContainer = () => {

const onSaveCardSuccess = response => {
const cardStatus = response.data.data[0].status;

if (cardStatus !== statusView) {
setStatusView(returnCardStatus(cardStatus));
}
Expand Down Expand Up @@ -119,7 +122,15 @@ const QueueContainer = () => {
returnCardStatus(card.status) === 'PENDING_REVIEW'
) {
return card;
} else if (statusView === 'PRINTING' && card.status === 'PRINTING') {
} else if (
statusView === 'PRINTING' &&
returnCardStatus(card.status) === 'PRINTING'
) {
return card;
} else if (
statusView === 'FAILED' &&
returnCardStatus(card.status) === 'FAILED'
) {
return card;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ const PrintCardContainer = props => {
card.colorType.color !== updatedData.colorType.color
) {
updatedSavedCard[key] = updatedData[key];
} else if (key === 'status') {
updatedSavedCard.status = updatedData.status;
} else if (
key !== 'colorType' &&
(card[key] && card[key] !== updatedData[key])
key === 'comments' &&
card.comments &&
card.comments !== updatedData.comments
) {
updatedSavedCard[key] = updatedData[key];
updatedSavedCard.comments = updatedData.comments;
}
}
saveCard(updatedSavedCard);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const StatusDropdown = ({ currentStatus, statusChanged, id }) => {
<select name="status" defaultValue={currentStatus}>
<option value="PENDING_REVIEW">Queueing</option>
<option value="PRINTING">Printing</option>
<option value="FAILED">Failed</option>
<option value="COMPLETED">Complete</option>
<option value="FAILED">Failed</option>
</select>
</form>
);
Expand Down
2 changes: 1 addition & 1 deletion Frontend/src/components/globalStyles/Backdrop/Backdrop.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
display: flex;
justify-content: center;
transition: all 0.3s ease-in-out;
}
}
4 changes: 4 additions & 0 deletions Frontend/src/components/globalStyles/MenuTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
name: 'DONE',
label: 'Recently Completed',
},
{
name: 'FAILED',
label: 'Print Failed',
},
];
ManageAccountTabs = [
{
Expand Down
Loading

0 comments on commit 97c0dfb

Please sign in to comment.