From 97d29cb8849fb258fc0b799f2311743596dfe3a2 Mon Sep 17 00:00:00 2001
From: Gesine Wagner <80248709+Platura@users.noreply.github.com>
Date: Thu, 4 Jul 2024 12:31:19 +0200
Subject: [PATCH 1/8] removed contact button from the footer
---
src/components/Footer/Footer.tsx | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/components/Footer/Footer.tsx b/src/components/Footer/Footer.tsx
index 7fe3ac70..ccd821ff 100644
--- a/src/components/Footer/Footer.tsx
+++ b/src/components/Footer/Footer.tsx
@@ -1,7 +1,9 @@
-import { Fragment, memo } from 'react'
+import { Fragment, memo, useContext } from 'react'
import { useTranslation } from 'react-i18next'
import { useNavigate } from 'react-router-dom'
import { Box, Container, Divider, Grid, Link, Typography } from '@common/components'
+import { AuthContext } from '@services'
+import { useAuthProvider } from 'src/services/AuthProvider/AuthProvider.hooks'
/**
* Sticks to the bottom of the page and is always visible.
@@ -17,11 +19,13 @@ const Footer = () => {
const navigate = useNavigate()
const { t } = useTranslation()
+ const {isAuth}=useContext(AuthContext)
+
const footerComponents = [
- { name: [t('pages.home')], link: '/' },
- { name: [t('pages.contact')], link: '/contact' },
- { name: [t('pages.imprint')], link: '/imprint' },
- { name: [t('pages.privacypolicy')], link: '/privacypolicy' }
+ { name: [t('pages.home')], link: '/', showOnlyWhenLoggin: false},
+ { name: [t('pages.contact')], link: '/contact', showOnlyWhenLoggin: true },
+ { name: [t('pages.imprint')], link: '/imprint', showOnlyWhenLoggin: false },
+ { name: [t('pages.privacypolicy')], link: '/privacypolicy', showOnlyWhenLoggin: false }
]
return (
@@ -43,6 +47,8 @@ const Footer = () => {
{footerComponents.map((component) => (
+
+ ((!component.showOnlyWhenLoggin) || isAuth) &&
Date: Mon, 8 Jul 2024 09:54:48 +0200
Subject: [PATCH 2/8] name change and lint
---
src/components/Footer/Footer.test.tsx | 2 +-
src/components/Footer/Footer.tsx | 58 +++++++++++++--------------
src/pages/Course/Course.tsx | 2 +-
src/pages/Home/Home.tsx | 46 ++++++++++-----------
4 files changed, 54 insertions(+), 54 deletions(-)
diff --git a/src/components/Footer/Footer.test.tsx b/src/components/Footer/Footer.test.tsx
index 1d91dbd6..d5fa31e8 100644
--- a/src/components/Footer/Footer.test.tsx
+++ b/src/components/Footer/Footer.test.tsx
@@ -25,6 +25,6 @@ describe('Footer', () => {
fireEvent.click(button)
})
- expect(navigate).toHaveBeenCalledTimes(4)
+ expect(navigate).toHaveBeenCalledTimes(3)
})
})
diff --git a/src/components/Footer/Footer.tsx b/src/components/Footer/Footer.tsx
index ccd821ff..53e2cce1 100644
--- a/src/components/Footer/Footer.tsx
+++ b/src/components/Footer/Footer.tsx
@@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next'
import { useNavigate } from 'react-router-dom'
import { Box, Container, Divider, Grid, Link, Typography } from '@common/components'
import { AuthContext } from '@services'
-import { useAuthProvider } from 'src/services/AuthProvider/AuthProvider.hooks'
/**
* Sticks to the bottom of the page and is always visible.
@@ -19,13 +18,13 @@ const Footer = () => {
const navigate = useNavigate()
const { t } = useTranslation()
- const {isAuth}=useContext(AuthContext)
+ const { isAuth } = useContext(AuthContext)
const footerComponents = [
- { name: [t('pages.home')], link: '/', showOnlyWhenLoggin: false},
- { name: [t('pages.contact')], link: '/contact', showOnlyWhenLoggin: true },
- { name: [t('pages.imprint')], link: '/imprint', showOnlyWhenLoggin: false },
- { name: [t('pages.privacypolicy')], link: '/privacypolicy', showOnlyWhenLoggin: false }
+ { name: [t('pages.home')], link: '/', showOnlyWhenLogin: false },
+ { name: [t('pages.contact')], link: '/contact', showOnlyWhenLogin: true },
+ { name: [t('pages.imprint')], link: '/imprint', showOnlyWhenLogin: false },
+ { name: [t('pages.privacypolicy')], link: '/privacypolicy', showOnlyWhenLogin: false }
]
return (
@@ -46,29 +45,30 @@ const Footer = () => {
- {footerComponents.map((component) => (
-
- ((!component.showOnlyWhenLoggin) || isAuth) &&
-
- navigate(component.link)}>
- {component.name}
-
- {footerComponents.indexOf(component) !== footerComponents.length - 1 && (
-
- {' '}
- |{' '}
-
- )}
-
- ))}
+ {footerComponents.map(
+ (component) =>
+ (!component.showOnlyWhenLogin || isAuth) && (
+
+ navigate(component.link)}>
+ {component.name}
+
+ {footerComponents.indexOf(component) !== footerComponents.length - 1 && (
+
+ {' '}
+ |{' '}
+
+ )}
+
+ )
+ )}
diff --git a/src/pages/Course/Course.tsx b/src/pages/Course/Course.tsx
index e4e752dd..fd46934f 100644
--- a/src/pages/Course/Course.tsx
+++ b/src/pages/Course/Course.tsx
@@ -17,7 +17,7 @@ const Course = () => {
// Hooks
const theme = useTheme()
const isSmOrDown = useMediaQuery(theme.breakpoints.down('sm'))
- const { courseId } = useParams<{courseId: string}>()
+ const { courseId } = useParams<{ courseId: string }>()
const { topicProgress, isLoading, topics } = useLearningPathTopicProgress({ courseId })
return (
diff --git a/src/pages/Home/Home.tsx b/src/pages/Home/Home.tsx
index 7ffeea65..3eeae20b 100644
--- a/src/pages/Home/Home.tsx
+++ b/src/pages/Home/Home.tsx
@@ -28,32 +28,32 @@ export const Home = () => {
const getCourses = useStore((state) => state.getCourses)
useEffect(() => {
- if (isAuth) {
- getUser()
- .then((user) => {
- getCourses(user.settings.user_id, user.lms_user_id, user.id)
- .then((CourseResponse) => {
- setCourses(CourseResponse.courses)
- })
- .catch((error) => {
- addSnackbar({
- message: t('error.getCourses'),
- severity: 'error',
- autoHideDuration: 5000
- })
- log.error(t('error.getCourses') + ' ' + error)
+ if (isAuth) {
+ getUser()
+ .then((user) => {
+ getCourses(user.settings.user_id, user.lms_user_id, user.id)
+ .then((CourseResponse) => {
+ setCourses(CourseResponse.courses)
+ })
+ .catch((error) => {
+ addSnackbar({
+ message: t('error.getCourses'),
+ severity: 'error',
+ autoHideDuration: 5000
})
- })
- .catch((error) => {
- addSnackbar({
- message: t('error.getUser'),
- severity: 'error',
- autoHideDuration: 5000
+ log.error(t('error.getCourses') + ' ' + error)
})
- log.error(t('error.getUser') + ' ' + error)
+ })
+ .catch((error) => {
+ addSnackbar({
+ message: t('error.getUser'),
+ severity: 'error',
+ autoHideDuration: 5000
})
- setLoading(false)
- }
+ log.error(t('error.getUser') + ' ' + error)
+ })
+ setLoading(false)
+ }
}, [getUser, getCourses, setCourses, isAuth])
// Card cointaining the courses with a button to the specific course
From 2136fc5351703d48f8a20a5a1e01f4cdbee690e7 Mon Sep 17 00:00:00 2001
From: Gesine Wagner <80248709+Platura@users.noreply.github.com>
Date: Tue, 16 Jul 2024 10:14:03 +0200
Subject: [PATCH 3/8] added is Auth to contact
---
src/pages/Contact/Contact.tsx | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/pages/Contact/Contact.tsx b/src/pages/Contact/Contact.tsx
index 7df28ae8..c4c4cca6 100644
--- a/src/pages/Contact/Contact.tsx
+++ b/src/pages/Contact/Contact.tsx
@@ -1,5 +1,6 @@
-import { useState } from 'react'
+import { useState, useContext } from 'react'
import { ContactForm } from '@components'
+import { AuthContext } from '@services'
import { ContactHookProps, ContactHookReturn, useContact as _useContact } from './Contact.hooks'
export type ContactProps = {
@@ -16,10 +17,12 @@ export type ContactProps = {
* @param props - Dependency injects {@link useContact} to control the sumbit on the page. Also displays a lodaing indicator when submitting.
* @category Pages
*/
+
export const Contact = ({ useContact = _useContact }: ContactProps) => {
const [isLoading, setIsLoading] = useState(false)
-
+ const { isAuth } = useContext(AuthContext)
+
const { onSubmitHandler } = useContact({ setIsLoading })
- return
+ return isAuth &&
}
export default Contact
From b6027bb15405152aae055f7ca4032bba2cfc8cb6 Mon Sep 17 00:00:00 2001
From: Gesine Wagner <80248709+Platura@users.noreply.github.com>
Date: Tue, 16 Jul 2024 10:36:21 +0200
Subject: [PATCH 4/8] lint
---
src/pages/Contact/Contact.tsx | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/pages/Contact/Contact.tsx b/src/pages/Contact/Contact.tsx
index c4c4cca6..17bd8d3d 100644
--- a/src/pages/Contact/Contact.tsx
+++ b/src/pages/Contact/Contact.tsx
@@ -21,8 +21,12 @@ export type ContactProps = {
export const Contact = ({ useContact = _useContact }: ContactProps) => {
const [isLoading, setIsLoading] = useState(false)
const { isAuth } = useContext(AuthContext)
-
+
const { onSubmitHandler } = useContact({ setIsLoading })
- return isAuth &&
+ return (
+ <>
+ (isAuth) && ()
+ >
+ )
}
export default Contact
From b11dfcdf7c6061bdb6c6b63b91ced9042081c173 Mon Sep 17 00:00:00 2001
From: Gesine Wagner <80248709+Platura@users.noreply.github.com>
Date: Thu, 18 Jul 2024 10:43:29 +0200
Subject: [PATCH 5/8] lint
---
src/pages/Course/Course.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/pages/Course/Course.tsx b/src/pages/Course/Course.tsx
index fd46934f..e4e752dd 100644
--- a/src/pages/Course/Course.tsx
+++ b/src/pages/Course/Course.tsx
@@ -17,7 +17,7 @@ const Course = () => {
// Hooks
const theme = useTheme()
const isSmOrDown = useMediaQuery(theme.breakpoints.down('sm'))
- const { courseId } = useParams<{ courseId: string }>()
+ const { courseId } = useParams<{courseId: string}>()
const { topicProgress, isLoading, topics } = useLearningPathTopicProgress({ courseId })
return (
From 7f6f59357ea128d5e1785c80cabd4423b23f5d1d Mon Sep 17 00:00:00 2001
From: Gesine Wagner <80248709+Platura@users.noreply.github.com>
Date: Thu, 18 Jul 2024 10:47:10 +0200
Subject: [PATCH 6/8] lint
---
src/pages/Contact/Contact.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/pages/Contact/Contact.tsx b/src/pages/Contact/Contact.tsx
index 17bd8d3d..e2171963 100644
--- a/src/pages/Contact/Contact.tsx
+++ b/src/pages/Contact/Contact.tsx
@@ -25,7 +25,7 @@ export const Contact = ({ useContact = _useContact }: ContactProps) => {
const { onSubmitHandler } = useContact({ setIsLoading })
return (
<>
- (isAuth) && ()
+ {(isAuth) && ()}
>
)
}
From cd07124e1f6e0740d82569e03d5e08a065690ee7 Mon Sep 17 00:00:00 2001
From: Gesine Wagner <80248709+Platura@users.noreply.github.com>
Date: Thu, 8 Aug 2024 11:29:07 +0200
Subject: [PATCH 7/8] added requested changes
---
src/components/Footer/Footer.tsx | 10 +++++-----
src/pages/Contact/Contact.tsx | 6 +-----
src/pages/Course/Course.tsx | 2 +-
3 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/src/components/Footer/Footer.tsx b/src/components/Footer/Footer.tsx
index 53e2cce1..d40b7bf5 100644
--- a/src/components/Footer/Footer.tsx
+++ b/src/components/Footer/Footer.tsx
@@ -21,10 +21,10 @@ const Footer = () => {
const { isAuth } = useContext(AuthContext)
const footerComponents = [
- { name: [t('pages.home')], link: '/', showOnlyWhenLogin: false },
- { name: [t('pages.contact')], link: '/contact', showOnlyWhenLogin: true },
- { name: [t('pages.imprint')], link: '/imprint', showOnlyWhenLogin: false },
- { name: [t('pages.privacypolicy')], link: '/privacypolicy', showOnlyWhenLogin: false }
+ { name: [t('pages.home')], link: '/', isVisibleBeforeLogin: true },
+ { name: [t('pages.contact')], link: '/contact', isVisibleBeforeLogin: false },
+ { name: [t('pages.imprint')], link: '/imprint', isVisibleBeforeLogin: true },
+ { name: [t('pages.privacypolicy')], link: '/privacypolicy', isVisibleBeforeLogin: true }
]
return (
@@ -47,7 +47,7 @@ const Footer = () => {
{footerComponents.map(
(component) =>
- (!component.showOnlyWhenLogin || isAuth) && (
+ (component.isVisibleBeforeLogin || isAuth) && (
{
const { isAuth } = useContext(AuthContext)
const { onSubmitHandler } = useContact({ setIsLoading })
- return (
- <>
- {(isAuth) && ()}
- >
- )
+ return <>{isAuth && }>
}
export default Contact
diff --git a/src/pages/Course/Course.tsx b/src/pages/Course/Course.tsx
index e4e752dd..fd46934f 100644
--- a/src/pages/Course/Course.tsx
+++ b/src/pages/Course/Course.tsx
@@ -17,7 +17,7 @@ const Course = () => {
// Hooks
const theme = useTheme()
const isSmOrDown = useMediaQuery(theme.breakpoints.down('sm'))
- const { courseId } = useParams<{courseId: string}>()
+ const { courseId } = useParams<{ courseId: string }>()
const { topicProgress, isLoading, topics } = useLearningPathTopicProgress({ courseId })
return (
From c6f4e8ac8749a7f765a34431ed6244fc48761f85 Mon Sep 17 00:00:00 2001
From: Gesine Wagner <80248709+Platura@users.noreply.github.com>
Date: Thu, 8 Aug 2024 12:45:58 +0200
Subject: [PATCH 8/8] fixed test
---
src/pages/Contact/Contact.test.tsx | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/pages/Contact/Contact.test.tsx b/src/pages/Contact/Contact.test.tsx
index b57e52d7..1be4b34b 100644
--- a/src/pages/Contact/Contact.test.tsx
+++ b/src/pages/Contact/Contact.test.tsx
@@ -8,6 +8,8 @@ import { FormDataType, SnackbarContext, SnackbarContextType } from '@services'
import { getConfig } from '@shared'
import { useContact } from './Contact.hooks'
+const { AuthContext } = jest.requireActual('@services')
+
/*jest.mock('react', () => ({
...jest.requireActual('react'),
useCallback: (a: any) => a
@@ -54,12 +56,25 @@ describe('Test Contactpage', () => {
const useContact = jest.fn(() => {
return { onSubmitHandler: submit }
})
+ test('Contactform gets displayed and functions normally', () => {
+ render(
+
+
+
+
+
+
+
+ )
+ })
test('not sending', () => {
render(
-
+
+
+
)
@@ -86,7 +101,9 @@ describe('Test Contactpage', () => {
render(
-
+
+
+
)
})