Skip to content

Commit

Permalink
Merge pull request #2442 from objectcomputing/bugfix-pulse-report
Browse files Browse the repository at this point in the history
fixes in PulsePage.jsx
  • Loading branch information
mvolkmann authored May 24, 2024
2 parents 11fbc64 + c296b4c commit f2d92e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
13 changes: 4 additions & 9 deletions web-ui/src/pages/PulsePage.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { format } from 'date-fns';
import React, { useContext, useEffect, useState } from 'react';
import {useHistory} from 'react-router-dom';
import { useHistory } from 'react-router-dom';
import { Button, Typography } from '@mui/material';

import { resolve } from '../api/api.js';
Expand All @@ -14,6 +14,7 @@ const PulsePage = () => {
const { state } = useContext(AppContext);
const currentUser = selectCurrentUser(state);
const csrf = selectCsrfToken(state);
const history = useHistory();

const [externalComment, setExternalComment] = useState('');
const [externalScore, setExternalScore] = useState(2); // zero-based
Expand Down Expand Up @@ -66,8 +67,6 @@ const PulsePage = () => {
});
if (res.error) throw new Error(res.error.message);
const pulses = res.payload.data;
//TODO: Currently these objects only contain the comment text value,
// not scores, but story 2345 will add those.
setPulse(pulses.at(-1)); // last element is most recent
} catch (err) {
console.error('PulsePage.jsx loadTodayPulse:', err);
Expand Down Expand Up @@ -103,7 +102,7 @@ const PulsePage = () => {
if (res.error) throw new Error(res.error.message);

// Refresh browser to show that pulses where already submitted today.
history.push(location.pathname);
history.go(0);
} catch (err) {
console.error('PulsePage.jsx submit:', err);
}
Expand Down Expand Up @@ -135,11 +134,7 @@ const PulsePage = () => {
setScore={setExternalScore}
title="How you feeling about life outside of work?"
/>
<Button
disabled={!internalComment}
onClick={submit}
variant="contained"
>
<Button onClick={submit} variant="contained">
Submit
</Button>
</>
Expand Down
8 changes: 5 additions & 3 deletions web-ui/src/pages/__snapshots__/PulsePage.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,14 @@ exports[`renders correctly 1`] = `
</div>
</div>
<button
class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary Mui-disabled MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-sghohy-MuiButtonBase-root-MuiButton-root"
disabled=""
tabindex="-1"
class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-sghohy-MuiButtonBase-root-MuiButton-root"
tabindex="0"
type="button"
>
Submit
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</div>
</div>
Expand Down

0 comments on commit f2d92e1

Please sign in to comment.