Skip to content

Commit

Permalink
Merge pull request #4175 from jedwardmook/WV-659
Browse files Browse the repository at this point in the history
WV-659 VoterPositionEntryAndDisplay: Open modal when you click "What's your opinion?" input
  • Loading branch information
DaleMcGrew authored Nov 22, 2024
2 parents ffc476c + b432377 commit 2e16d14
Show file tree
Hide file tree
Showing 4 changed files with 402 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { ThumbDownAltRounded } from '@mui/icons-material';
import DeleteOutlinedIcon from '@mui/icons-material/DeleteOutlined';
import { Popover } from '@mui/material';
import DesignTokenColors from '../Style/DesignTokenColors';
import VoterPositionEditModal from '../../../components/PositionItem/VoterPositionEditModal';

function VoterPositionEntryAndDisplay () {
const [voterOpinion, setVoterOpinion] = useState(null);
const [anchorEl, setAnchorEL] = useState(null);
const [showVoterEdit, setShowVoterEdit] = useState(false);

const voter = {
first_name: 'David',
Expand All @@ -18,21 +20,27 @@ function VoterPositionEntryAndDisplay () {
voter_photo_url_medium: '',
};

const candidateName = 'Holly Mitchell';

const opinion = {
opinion_body: 'Holly can get the job done',
opinion_time_created: new Date(),
opinion_likes: ['Blair H', 'Malena H', 'Anusha K', 'Ayobami B', 'Blair H', 'Blair H', 'Blair H', 'Blair H', 'Blair H', 'Blair H', 'Blair H', 'Blair H', 'Blair H', 'Blair H', 'Blair H', 'Blair H', 'Blair H', 'Blair H'],
opinion_dislikes: ['Enrique C'],
};

const handleVoterEditClick = () => {
console.log('Edit voter logic will go here');
// const handleVoterEditClick = () => {
// console.log('Edit voter logic will go here');
// };

const handleSetOpinonClick = () => {
setVoterOpinion(opinion);
};

const formatNewDate = (date) => new Intl.DateTimeFormat('en-US', { month: '2-digit', day: 'numeric', year: '2-digit' }).format(date);

const voterOpinionClick = () => {
setVoterOpinion(opinion);
setShowVoterEdit(!showVoterEdit);
};

const handleEditCommentClick = (e) => {
Expand Down Expand Up @@ -83,11 +91,17 @@ function VoterPositionEntryAndDisplay () {
</>
)}
</VoterAvatar>
<VoterEdit onClick={handleVoterEditClick}>
<VoterEdit onClick={handleSetOpinonClick}>
<EditIcon />
</VoterEdit>
</VoterAvatarDisplayContainer>
<VoterOpinionDisplayContainer>
<VoterPositionEditModal
showVoterEdit={showVoterEdit}
setShowVoterEdit={setShowVoterEdit}
candidateName={candidateName}
voter={voter}
/>
{voterOpinion ? (
<VoterOpinionContainer>
<VoterTitle>
Expand Down
10 changes: 9 additions & 1 deletion src/js/common/stories/VoterPositionEntryAndDisplay.stories.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import React from 'react';
import { ThemeProvider } from '@mui/material/styles';
import VoterPositionEntryAndDisplay from '../components/PositionItem/VoterPositionEntryAndDisplay';
import muiTheme from '../components/Style/muiTheme';



export default {
title: 'Components/PositionItem/VoterPositionEntryAndDisplay',
component: VoterPositionEntryAndDisplay,
};

export const Default = () => <VoterPositionEntryAndDisplay />;
export const Default = () => (
<ThemeProvider theme={muiTheme}>
<VoterPositionEntryAndDisplay />
</ThemeProvider>
);
7 changes: 4 additions & 3 deletions src/js/components/Activity/ActivityPostModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ const ActivityPostModal = (props) => {
}
}, [initialFocusSet]);

// onBlurInput = () => {
// };
const onBlurInput = () => {
restoreStylesAfterCordovaKeyboard('ActivityPostModal');
};


const onFocusInput = () => {
prepareForCordovaKeyboard('ActivityPostModal');
Expand All @@ -81,7 +83,6 @@ const ActivityPostModal = (props) => {
const visibilitySetting = visibilityIsPublic ? 'SHOW_PUBLIC' : 'FRIENDS_ONLY';
ActivityActions.activityPostSave(activityTidbitWeVoteId, statementText, visibilitySetting);
toggleModal();
restoreStylesAfterCordovaKeyboard('ActivityPostModal');
};

const updateStatementTextToBeSaved = (e) => {
Expand Down
Loading

0 comments on commit 2e16d14

Please sign in to comment.