Skip to content
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
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';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added spaces inside braces.

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);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The push method doesn't refresh the browser, but the go method does.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize go was available in v5. Thanks!

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}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed requirement to supply 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