From f4b409ca3ae25194a6f26df06f6cdc3fbf2d1495 Mon Sep 17 00:00:00 2001 From: Stephen Fraser Date: Mon, 31 Jul 2023 16:57:04 +0100 Subject: [PATCH] Fixed a few bugs --- .../frontend/shared/components/TermsPopup.tsx | 41 ++++++++++++++++++- .../src/frontend/shared/navigation/Button.tsx | 8 ++++ .../site/blocks/ProjectStatistics.tsx | 2 +- .../frontend/site/pages/user/login-page.tsx | 4 +- .../src/frontend/site/pages/user/register.tsx | 6 +-- .../src/frontend/site/pages/view-project.tsx | 17 ++++---- .../tailwind/components/slot-tabs.tsx | 2 +- .../src/repository/site-user-repository.ts | 3 +- 8 files changed, 65 insertions(+), 18 deletions(-) diff --git a/services/madoc-ts/src/frontend/shared/components/TermsPopup.tsx b/services/madoc-ts/src/frontend/shared/components/TermsPopup.tsx index 8046f2e4e..567e74ab4 100644 --- a/services/madoc-ts/src/frontend/shared/components/TermsPopup.tsx +++ b/services/madoc-ts/src/frontend/shared/components/TermsPopup.tsx @@ -2,11 +2,14 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { useSite, useUser } from '../hooks/use-site'; import { HrefLink } from '../utility/href-link'; +import { useLocation } from 'react-router-dom'; export function TermsPopup() { const user = useUser(); const site = useSite(); const { t } = useTranslation(); + const location = useLocation(); + const [closed, setClosed] = React.useState(false); if (!user || !site.latestTerms) { return null; @@ -34,6 +37,14 @@ export function TermsPopup() { return null; } + if (location.pathname === '/terms') { + return null; + } + + if (closed) { + return null; + } + return (
+
+ +
{newTerms ? (

{t('You have not yet accepted the terms of use for this site.')}

) : (

{t('The terms of use for this site have changed since you last accepted them.')}

)} - + {termsMessage}
diff --git a/services/madoc-ts/src/frontend/shared/navigation/Button.tsx b/services/madoc-ts/src/frontend/shared/navigation/Button.tsx index c2a69794c..12be27b0f 100644 --- a/services/madoc-ts/src/frontend/shared/navigation/Button.tsx +++ b/services/madoc-ts/src/frontend/shared/navigation/Button.tsx @@ -44,6 +44,10 @@ export const Button = styled.button<{ background: linear-gradient(180deg, #fafbfc 0%, #eff3f6 90%); border: 1px solid rgba(27, 31, 35, 0.15); color: #333; + + &[type="submit"] { + background: linear-gradient(180deg, #fafbfc 0%, #eff3f6 90%); + } ${props => @@ -97,6 +101,10 @@ export const Button = styled.button<{ background: #4265e9; color: #fff; border: 1px solid #4265e9; + + &[type='submit'] { + background: #4265e9; + } &:active { box-shadow: inset 0 2px 8px 0 rgba(39, 75, 155, 0.8); } diff --git a/services/madoc-ts/src/frontend/site/blocks/ProjectStatistics.tsx b/services/madoc-ts/src/frontend/site/blocks/ProjectStatistics.tsx index bd7691c8c..9cc366d51 100644 --- a/services/madoc-ts/src/frontend/site/blocks/ProjectStatistics.tsx +++ b/services/madoc-ts/src/frontend/site/blocks/ProjectStatistics.tsx @@ -46,7 +46,7 @@ export const ProjectStatistics: React.FC = () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - const total = Object.values(project?.statistics).reduce((a, b) => Math.max(a, 0) + Math.max(b, 0)); + const total = Object.values(project?.statistics || {}).reduce((a, b) => Math.max(a, 0) + Math.max(b, 0), 0); if (hideStatistics || !project) { return null; diff --git a/services/madoc-ts/src/frontend/site/pages/user/login-page.tsx b/services/madoc-ts/src/frontend/site/pages/user/login-page.tsx index 8e1e9357d..c6bb80bad 100644 --- a/services/madoc-ts/src/frontend/site/pages/user/login-page.tsx +++ b/services/madoc-ts/src/frontend/site/pages/user/login-page.tsx @@ -49,9 +49,9 @@ export const LoginPage: React.FC = () => {
) : null} - +
{t('Forgot password?')} - +
diff --git a/services/madoc-ts/src/frontend/site/pages/user/register.tsx b/services/madoc-ts/src/frontend/site/pages/user/register.tsx index 8e7654fe8..6c3dfe359 100644 --- a/services/madoc-ts/src/frontend/site/pages/user/register.tsx +++ b/services/madoc-ts/src/frontend/site/pages/user/register.tsx @@ -69,7 +69,7 @@ export const Register: React.FC = () => { } const acceptTerms = site.latestTerms ? ( -
+

{t('By registering you agree to the ')} @@ -139,9 +139,9 @@ export const Register: React.FC = () => { ) : null} - +

diff --git a/services/madoc-ts/src/frontend/site/pages/view-project.tsx b/services/madoc-ts/src/frontend/site/pages/view-project.tsx index 98e18c191..91811c4dc 100644 --- a/services/madoc-ts/src/frontend/site/pages/view-project.tsx +++ b/services/madoc-ts/src/frontend/site/pages/view-project.tsx @@ -28,6 +28,7 @@ import { useProject } from '../hooks/use-project'; export const ViewProject: React.FC = () => { const { t } = useTranslation(); const user = useUser(); + const isAdmin = (user?.scope || []).includes('site.admin'); const { data: project } = useProject(); const available = ( @@ -56,24 +57,24 @@ export const ViewProject: React.FC = () => { {available} - + - {available} + - + -