diff --git a/gatsby-config.js b/gatsby-config.js index be2acb86..34ade0e4 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -4,7 +4,16 @@ module.exports = { siteMetadata: { title: `medlem`, - siteUrl: `https://www.yourdomain.tld` + siteUrl: `https://medlem.d-sektionen.se`, }, - plugins: ["gatsby-plugin-sass"] -}; \ No newline at end of file + plugins: [ + { + resolve: 'gatsby-plugin-sass', + options: { + sassOptions: { + silenceDeprecations: ['legacy-js-api', 'import'], + }, + }, + }, + ], +} diff --git a/package.json b/package.json index f5b4fe56..80aa60a1 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "private": true, "description": "medlem", - "author": "Therese Selberg", + "author": "WebbU", "keywords": [ "gatsby" ], @@ -53,4 +53,4 @@ "devDependencies": { "gh-pages": "^6.1.1" } -} \ No newline at end of file +} diff --git a/src/components/ui/buttons.js b/src/components/ui/buttons.js index b507450b..356fadd7 100644 --- a/src/components/ui/buttons.js +++ b/src/components/ui/buttons.js @@ -18,23 +18,63 @@ const IconButton = ({ onClick, iconComponent: Icon, text, disabled }) => { ) } -const Button = ({ onClick, to, href, target, children, type = 'button' }) => { +const Button = ({ + onClick, + to, + href, + target, + children, + disabled, + type = 'button', +}) => { if (to) return ( - + { + e.preventDefault() + e.stopPropagation() + } + : onClick + } + aria-disabled={disabled} + tabIndex={disabled ? -1 : undefined} + > {children} ) if (href) return ( - + { + e.preventDefault() + e.stopPropagation() + } + : onClick + } + aria-disabled={disabled} + tabIndex={disabled ? -1 : undefined} + > {children} ) return ( - ) diff --git a/src/components/ui/titleChooser.js b/src/components/ui/titleChooser.js index 2da624c7..d791b2b1 100644 --- a/src/components/ui/titleChooser.js +++ b/src/components/ui/titleChooser.js @@ -15,6 +15,7 @@ const TitleChooser = ({ choice = null, setChoice = () => {}, label = '', + hintLabel = 'Välj ett objekt', action = null, actionLabel = '', noChoicesLabel = '', @@ -91,7 +92,7 @@ const TitleChooser = ({ ))} - {choice === null &&
Välj ett objekt
} + {choice === null &&
{hintLabel}
} ) : ( {noChoicesLabel} @@ -110,6 +111,7 @@ TitleChooser.propTypes = { choice: PropTypes.object, setChoice: PropTypes.func, label: PropTypes.string, + hintLabel: PropTypes.string, action: PropTypes.func, actionLabel: PropTypes.string, noChoicesLabel: PropTypes.string, diff --git a/src/components/vote/meetingInfoPanel.js b/src/components/vote/meetingInfoPanel.js index f851495b..70baa6c4 100644 --- a/src/components/vote/meetingInfoPanel.js +++ b/src/components/vote/meetingInfoPanel.js @@ -1,6 +1,7 @@ import React from 'react' import { Button } from '../ui/buttons' import { post, del } from '../request' +import { FiLogOut, FiLogIn } from 'react-icons/fi' export default function MeetingInfoPanel({ currentMeeting, @@ -34,6 +35,7 @@ export default function MeetingInfoPanel({ } }} > + Lämna röstlängden ) : ( @@ -49,6 +51,7 @@ export default function MeetingInfoPanel({ } }} > + Gå med i röstlängden )} diff --git a/src/components/vote/page.js b/src/components/vote/page.js index 2d910896..5878a303 100644 --- a/src/components/vote/page.js +++ b/src/components/vote/page.js @@ -7,6 +7,11 @@ import TitleChooser from '../ui/titleChooser' import SpeakerPanel from './speakerPanel' import MeetingInfoPanel from './meetingInfoPanel' import VotePanel from './votePanel' +import { + currentMeetingContainer, + votePanelContainer, + othersContainer, +} from '../../scss/votePage.module.scss' export default function VotePage({ pageContext: { title } }) { const [currentMeeting, setCurrentMeeting] = useState(null) @@ -27,24 +32,23 @@ export default function VotePage({ pageContext: { title } }) { setChoice={setCurrentMeeting} choices={meetings} label="name" + hintLabel="Välj ett möte" noChoicesLabel="Det finns inga möten just nu." /> {currentMeeting && ( - <> - +
+
+ +
+
- - - - - - - +
+
)} diff --git a/src/components/vote/speakerPanel.js b/src/components/vote/speakerPanel.js index d5e333f9..c2c24397 100644 --- a/src/components/vote/speakerPanel.js +++ b/src/components/vote/speakerPanel.js @@ -1,10 +1,12 @@ import React, { useState, useEffect, useContext } from 'react' +import { MdOutlineFrontHand } from 'react-icons/md' +import { RiMegaphoneLine } from 'react-icons/ri' import { FiTrash2 } from 'react-icons/fi' import { List, ListButton, ListItem } from '../ui/list' import { Button, ButtonGroup } from '../ui/buttons' import { UserContext } from '../layout/layout' -import { speakerPanelList } from '../../scss/vote.module.scss' +import { speakerPanelList } from '../../scss/voteSpeakerPanel.module.scss' import socket, { joinRoom, leaveRoom } from '../request/socket' import backendService from '../request/backendService' @@ -80,6 +82,7 @@ const SpeakerPanel = ({ meeting }) => { }) }} > + Jag vill tala! @@ -101,7 +105,7 @@ const SpeakerPanel = ({ meeting }) => { speakers.map((s) => ( { const [checkedId, setCheckedId] = useState(-1) @@ -17,42 +27,52 @@ const VoteForm = ({ vote, setErrors }) => { } await post('/voting/made_votes/', voteData) - .then(() => setSuccessfullyVoted(true)) - .catch(err => { - setSentVote(false) - setErrors({ voteError: err.response.data.error }) - }) + .then(() => setSuccessfullyVoted(true)) + .catch((err) => { + setSentVote(false) + setErrors({ + voteError: + err.response?.data?.error ?? 'Ett fel uppstod vid röstningen.', + }) + }) } const votingDisabled = checkedId === -1 - const buttonText = votingDisabled ? 'Välj ett alternativ' : 'Rösta' + const placeVoteButtonText = votingDisabled ? 'Välj ett alternativ' : 'Rösta' const alreadyVotedText = successfullyVoted ? 'Tack för din röst!' : 'Du har röstat i omröstningen.' return (
- {vote.question} +

+ {vote.question} +

{vote.has_voted || successfullyVoted ? ( -

{alreadyVotedText}

+

{alreadyVotedText}

) : ( <> -
    +
    {vote.alternatives.map(({ text, id }) => ( -
  • - -
  • + ))} -
- +
+
+ +
)} diff --git a/src/components/vote/votePanel.js b/src/components/vote/votePanel.js index 11887f5e..17345f4f 100644 --- a/src/components/vote/votePanel.js +++ b/src/components/vote/votePanel.js @@ -1,8 +1,12 @@ import React, { useEffect, useState } from 'react' import VoteForm from './voteForm' -import { formError } from '../../scss/vote.module.scss' import backendService from '../request/backendService' import socket, { joinRoom, leaveRoom } from '../request/socket' +import { + formError, + votePanelHeader, + noActiveVoting, +} from '../../scss/votePanel.module.scss' const VotePanel = ({ meeting }) => { const [votes, setVotes] = useState([]) @@ -116,11 +120,13 @@ const VotePanel = ({ meeting }) => { return (
-

Rösta

- {errors &&
{errors.voteError}
} +

Rösta

+ {errors.voteError &&
{errors.voteError}
} {votes && ( <> - {votes.length === 0 &&

Det finns ingen aktiv omröstning

} + {votes.length === 0 && ( +

Det finns ingen aktiv omröstning

+ )} {votes.map((vote) => ( ))} diff --git a/src/components/votingAdmin/addVote.js b/src/components/votingAdmin/addVote.js index dd1724f8..a408f626 100644 --- a/src/components/votingAdmin/addVote.js +++ b/src/components/votingAdmin/addVote.js @@ -14,8 +14,11 @@ const AddVote = ({ currentMeeting, create, updateData, update }) => { ) const [alternatives, setAlternatives] = useState( updateData - ? updateData.alternatives.map(alt => createAlternative(alt)) - : [createAlternative({text: 'Vakant'}), createAlternative({text: 'Blankt'})] + ? updateData.alternatives.map((alt) => createAlternative(alt)) + : [ + createAlternative({ text: 'Vakant' }), + createAlternative({ text: 'Blankt' }), + ] ) const [currentQuestion, setCurrentQuestion] = useState( updateData ? updateData.open : true @@ -27,7 +30,7 @@ const AddVote = ({ currentMeeting, create, updateData, update }) => { Fråga { + onChange={(e) => { setQuestion(e.target.value) }} /> @@ -38,9 +41,9 @@ const AddVote = ({ currentMeeting, create, updateData, update }) => {
  • { + onChange={(e) => { const newVal = e.target.value - setAlternatives(prev => [ + setAlternatives((prev) => [ ...prev.slice(0, i), { ...prev[i], text: newVal }, ...prev.slice(i + 1), @@ -50,7 +53,7 @@ const AddVote = ({ currentMeeting, create, updateData, update }) => {