Skip to content

Commit

Permalink
More language updates
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Sep 19, 2024
1 parent 304e40b commit 171e753
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 103 deletions.
12 changes: 6 additions & 6 deletions frontend/src/components/PollCard/PollAccessIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { designDecisions } from '../../constants/config'
export const PollAccessIndicator: FC<{
isOpen: boolean
isRestricted: boolean
hideClosedNoAccess?: boolean
hideRestrictedNoAccess?: boolean
isPending: boolean
isBroken: boolean
explanation: string | undefined
Expand All @@ -29,14 +29,14 @@ export const PollAccessIndicator: FC<{
isCompleted,
isMine,
retest,
hideClosedNoAccess,
hideRestrictedNoAccess,
}) => {
return (
<>
{isOpen && !designDecisions.hideOpenPollIndicator && (
<OpenPollIcon completed={isCompleted} height={20} />
)}
{isRestricted && !(!hasAccess && hideClosedNoAccess) && (
{isRestricted && !(!hasAccess && hideRestrictedNoAccess) && (
<RestrictedPollIcon
explanation={explanation ?? 'unknown restriction'}
completed={isCompleted}
Expand All @@ -57,16 +57,16 @@ export const PollAccessIndicatorWrapper: FC<{
isMine: boolean | undefined
permissions: PollPermissions
isActive: boolean
hideClosedNoAccess?: boolean
hideRestrictedNoAccess?: boolean
retest: () => void
}> = ({ isMine, permissions, isActive, hideClosedNoAccess, retest }) => {
}> = ({ isMine, permissions, isActive, hideRestrictedNoAccess, retest }) => {
const { explanation, error, canVote } = permissions
return (
<PollAccessIndicator
isOpen={explanation === ''}
isBroken={!!error}
isRestricted={!!explanation && !error}
hideClosedNoAccess={hideClosedNoAccess}
hideRestrictedNoAccess={hideRestrictedNoAccess}
explanation={explanation}
hasAccess={getVerdict(canVote, false)}
isCompleted={!isActive}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/PollCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const PollStatusIndicator: FC<{ active: boolean; isPastDue: boolean }> = ({ acti
Active {isPastDue && <HourGlassIcon size={'small'} />}
</div>
) : (
<div className={classes.pollStatusCompleted} title={'Poll is closed, results are available.'}>
<div className={classes.pollStatusCompleted} title={'Poll is completed, results are available.'}>
Completed
</div>
)
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/constants/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export {
VITE_IPFS_GATEWAY,
}

export const MIN_CLOSE_TIME_MINUTES = 3
export const MIN_COMPLETION_TIME_MINUTES = 3

export const demoPoll1 = {
id: 'demo',
Expand Down Expand Up @@ -180,8 +180,8 @@ export const getDemoPoll = (): ExtendedPoll => randomchoice([demoPoll1, demoPoll

export const demoSettings = {
timeForVoting: 610,
waitSecondsBeforeFormallyClosing: 5,
jumpToSecondsBeforeClosing: 5,
waitSecondsBeforeFormallyCompleting: 5,
jumpToSecondsBeforeCompletion: 5,
timeContractionSeconds: 5,
}

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/hooks/useExtendedPoll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ export const useExtendedPoll = (
return results
}, [poll, voteCounts, winningChoice, votes])

const closeDemoPoll = () => {
const completeDemoPoll = () => {
if (!poll) return
// Let's formally close the poll
// Let's formally complete the poll
setPoll({
...poll,
proposal: {
Expand Down Expand Up @@ -153,7 +153,7 @@ export const useExtendedPoll = (
pollResults,
deadline,
setDeadline,
closeDemoPoll,
completeDemoPoll,
gaslessEnabled,
gaslessPossible,
gvAddresses,
Expand Down
53 changes: 27 additions & 26 deletions frontend/src/pages/CreatePollPage/useCreatePollForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { useContracts } from '../../hooks/useContracts'
import classes from './index.module.css'
import { DateUtils } from '../../utils/date.utils'
import { useTime } from '../../hooks/useTime'
import { designDecisions, MIN_CLOSE_TIME_MINUTES } from '../../constants/config'
import { designDecisions, MIN_COMPLETION_TIME_MINUTES } from '../../constants/config'
import { AclOptions } from '../../types'
import { renderAddress } from '../../components/Addresses'
import { useNavigate } from 'react-router-dom'
Expand Down Expand Up @@ -383,7 +383,7 @@ export const useCreatePollForm = () => {
const gasFreeExplanation = useLabel({
name: 'gasFreeExplanation',
initialValue:
'We calculate and suggest the amount of ROSE needed for gas based on the amount of users that are expected to vote. Any remaining ROSE from the gas sponsoring wallet will be refunded to you once the poll is closed.',
'We calculate and suggest the amount of ROSE needed for gas based on the amount of users that are expected to vote. Any remaining ROSE from the gas sponsoring wallet will be refunded to you once the poll is completed.',
visible: gasFree.value,
classnames: classes.explanation,
})
Expand Down Expand Up @@ -472,51 +472,52 @@ export const useCreatePollForm = () => {
disableIfOnlyOneVisibleChoice: designDecisions.disableSelectsWithOnlyOneVisibleOption,
} as const)

const hasCloseDate = useBooleanField({
name: 'hasCloseDate',
label: 'Fixed close date',
const hasCompletionDate = useBooleanField({
name: 'hasCompletionDate',
label: 'Fixed completion date',
onValueChange: value => {
if (value) pollCloseDate.setValue(new Date(Date.now() + 1000 * 3600))
if (value) pollCompletionDate.setValue(new Date(Date.now() + 1000 * 3600))
},
})

const { now } = useTime()

const pollCloseDate = useDateField({
name: 'pollCloseDate',
label: `Poll close date (Time zone: ${Intl.DateTimeFormat().resolvedOptions().timeZone})`,
visible: hasCloseDate.value,
const pollCompletionDate = useDateField({
name: 'pollCompletionDate',
label: `Poll completion date (Time zone: ${Intl.DateTimeFormat().resolvedOptions().timeZone})`,
visible: hasCompletionDate.value,
validateOnChange: true,
showValidationStatus: false,
validators: value => {
const deadline = value.getTime() / 1000
const remaining = DateUtils.calculateRemainingTimeFrom(deadline, now)
const { isPastDue, totalSeconds } = remaining
if (isPastDue || totalSeconds < MIN_CLOSE_TIME_MINUTES * 60) {
return `Please set a time at least ${MIN_CLOSE_TIME_MINUTES} minutes in the future!`
if (isPastDue || totalSeconds < MIN_COMPLETION_TIME_MINUTES * 60) {
return `Please set a time at least ${MIN_COMPLETION_TIME_MINUTES} minutes in the future!`
}
},
})

const hasValidCloseDate = hasCloseDate.value && !!pollCloseDate.value && !pollCloseDate.hasProblems
const hasValidCompletionDate =
hasCompletionDate.value && !!pollCompletionDate.value && !pollCompletionDate.hasProblems

const pollCloseLabel = useLabel({
name: 'pollCloseLabel',
visible: hasValidCloseDate,
const pollCompletionLabel = useLabel({
name: 'pollCompletionLabel',
visible: hasValidCompletionDate,
initialValue: '??',
})

useEffect(() => {
void pollCloseDate.validate({ forceChange: true, reason: 'change' })
}, [hasCloseDate.value, now])
void pollCompletionDate.validate({ forceChange: true, reason: 'change' })
}, [hasCompletionDate.value, now])

useEffect(() => {
if (hasValidCloseDate) {
const deadline = pollCloseDate.value.getTime() / 1000
if (hasValidCompletionDate) {
const deadline = pollCompletionDate.value.getTime() / 1000
const remaining = DateUtils.calculateRemainingTimeFrom(deadline, now)
pollCloseLabel.setValue(DateUtils.getTextDescriptionOfTime(remaining) ?? '')
pollCompletionLabel.setValue(DateUtils.getTextDescriptionOfTime(remaining) ?? '')
}
}, [hasCloseDate.value, hasValidCloseDate, now])
}, [hasCompletionDate.value, hasValidCompletionDate, now])

const creationStatus = useLabel({
name: 'creationStatus',
Expand Down Expand Up @@ -545,9 +546,9 @@ export const useCreatePollForm = () => {
results: [
resultDisplayType,
authorResultDisplayType,
hasCloseDate,
pollCloseDate,
pollCloseLabel,
hasCompletionDate,
pollCompletionDate,
pollCompletionLabel,
creationStatus,
],
}
Expand Down Expand Up @@ -619,7 +620,7 @@ export const useCreatePollForm = () => {
aclOptions,
subsidizeAmount: gasFree.value ? parseEther(amountOfSubsidy.value) : undefined,
publishVotes: resultDisplayType.value === 'percentages_and_votes',
completionTime: hasCloseDate.value ? pollCloseDate.value : undefined,
completionTime: hasCompletionDate.value ? pollCompletionDate.value : undefined,
}

// console.log('Will create poll with props:', pollProps)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/DashboardPage/useDashboardData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type VisibilityInCircumstances = Record<Column, Set<string>>
* Explanation about filtering on the dashboard
*
* The poll cards on the dashboard are filtered according to three criteria:
* 1. Poll status: open or closed
* 1. Poll status: active or completed
* 2. Text search (in name and description)
* 3. Poll accessibility (i.e. permissions)
*
Expand Down
27 changes: 14 additions & 13 deletions frontend/src/pages/PollPage/ActivePoll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ export const ActivePoll: FC<PollData> = ({
isMine,
permissions,
checkPermissions,
canClose,
isClosing,
canComplete,
isCompleting,
completePoll,
topUp,
}) => {
// console.log("hasWallet?", hasWallet, "hasWalletOnWrongNetwork?",hasWalletOnWrongNetwork)
// console.log('isMine?', isMine, 'canClose?', canClose)
// console.log('isMine?', isMine, 'canComplete?', canComplete)

const {
name,
Expand All @@ -63,11 +63,11 @@ export const ActivePoll: FC<PollData> = ({
[canSelect, selectedChoice, setSelectedChoice],
)

const handleClose = useCallback(() => {
if (canClose && window.confirm("Are you sure you want to close this poll? This can't be undone.")) {
const handleComplete = useCallback(() => {
if (canComplete && window.confirm("Are you sure you want to complete this poll? This can't be undone.")) {
void completePoll()
}
}, [close])
}, [canComplete, completePoll])

const handleTopup = (address: string) => {
const amountString = window.prompt(
Expand Down Expand Up @@ -97,7 +97,7 @@ export const ActivePoll: FC<PollData> = ({
permissions={permissions}
isActive={true}
retest={checkPermissions}
hideClosedNoAccess={true}
hideRestrictedNoAccess={true}
/>
</div>
</h2>
Expand Down Expand Up @@ -140,10 +140,11 @@ export const ActivePoll: FC<PollData> = ({
</div>
))}
{remainingTimeString && <h4>{remainingTimeString}</h4>}
{publishVotes && <div>Votes will be made public when the poll is closed.</div>}
{publishVotes && <div>Votes will be made public when the poll is completed.</div>}
{isPastDue && (
<h4>
Voting results will be available when {isMine ? 'you close' : 'the owner formally closes'} the poll.
Voting results will be available when {isMine ? 'you compplete' : 'the owner formally completes'}{' '}
the poll.
</h4>
)}
{hasWallet && !hasWalletOnWrongNetwork && !getVerdict(canAclVote, false) ? (
Expand Down Expand Up @@ -179,12 +180,12 @@ export const ActivePoll: FC<PollData> = ({
{isMine && (
<Button
size={'small'}
disabled={!canClose}
disabled={!canComplete}
color={isMine && isPastDue ? 'primary' : 'secondary'}
onClick={handleClose}
pending={isClosing}
onClick={handleComplete}
pending={isCompleting}
>
{isClosing ? 'Completing poll' : 'Complete poll'}
{isCompleting ? 'Completing poll' : 'Complete poll'}
</Button>
)}
{!hasWallet && !isPastDue && <ConnectWallet mobileSticky={false} />}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/PollPage/CompletedPoll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const CompletedPoll: FC<
permissions={permissions}
isActive={false}
retest={checkPermissions}
hideClosedNoAccess={true}
hideRestrictedNoAccess={true}
/>
</div>
</h4>
Expand Down
36 changes: 18 additions & 18 deletions frontend/src/pages/PollPage/ThanksForVoting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ const StatusInfo: FC<{
remainingTime: RemainingTime | undefined
remainingTimeString: string | undefined
isMine: boolean | undefined
canClose: boolean
canComplete: boolean
complete: () => void
isClosing: boolean
}> = ({ remainingTime, remainingTimeString, isMine, canClose, complete, isClosing }) => {
const handleClose = () => {
if (canClose && window.confirm("Are you you you want to close this poll? This can't be undone.")) {
isCompleting: boolean
}> = ({ remainingTime, remainingTimeString, isMine, canComplete, complete, isCompleting }) => {
const handleComplete = () => {
if (canComplete && window.confirm("Are you you you want to complete this poll? This can't be undone.")) {
complete()
}
}
Expand All @@ -40,24 +40,24 @@ const StatusInfo: FC<{
return (
<>
<h4>{remainingTimeString}</h4>
<h4>Voting results will be available when you close the poll.</h4>
<Button size={'small'} disabled={!canClose} onClick={handleClose} pending={isClosing}>
{isClosing ? 'Completing poll' : 'Complete poll'}
<h4>Voting results will be available when you complete the poll.</h4>
<Button size={'small'} disabled={!canComplete} onClick={handleComplete} pending={isCompleting}>
{isCompleting ? 'Completing poll' : 'Complete poll'}
</Button>
</>
)
} else {
return (
<>
<h4>{remainingTimeString}</h4>
<h4>Voting results will be available when the owner formally closes the poll.</h4>
<h4>Voting results will be available when the owner formally completes the poll.</h4>
</>
)
}
} else {
return (
<>
<h4>Poll closes in:</h4>
<h4>Poll completes in:</h4>
<BigCountdown remainingTime={remainingTime} />
</>
)
Expand All @@ -66,14 +66,14 @@ const StatusInfo: FC<{
if (isMine) {
return (
<>
<h4>Voting results will be available when you close the poll.</h4>
<Button size={'small'} disabled={!canClose} onClick={handleClose} pending={isClosing}>
{isClosing ? 'Completing poll' : 'Complete poll'}
<h4>Voting results will be available when you complete the poll.</h4>
<Button size={'small'} disabled={!canComplete} onClick={handleComplete} pending={isCompleting}>
{isCompleting ? 'Completing poll' : 'Complete poll'}
</Button>
</>
)
} else {
return <h4>Voting results will be available when the owner closes the poll.</h4>
return <h4>Voting results will be available when the owner completes the poll.</h4>
}
}
}
Expand All @@ -86,9 +86,9 @@ export const ThanksForVote: FC<PollData> = ({
isMine,
permissions,
checkPermissions,
canClose,
canComplete,
completePoll,
isClosing,
isCompleting,
}) => {
const {
name,
Expand Down Expand Up @@ -124,9 +124,9 @@ export const ThanksForVote: FC<PollData> = ({
remainingTime={remainingTime}
remainingTimeString={remainingTimeString}
isMine={isMine}
canClose={canClose}
canComplete={canComplete}
complete={completePoll}
isClosing={isClosing}
isCompleting={isCompleting}
/>
</Card>
)
Expand Down
Loading

0 comments on commit 171e753

Please sign in to comment.