From 61d006d6f979ffad0a1e463e43495bddec1b9608 Mon Sep 17 00:00:00 2001 From: Benji Date: Mon, 9 Dec 2024 14:18:35 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20Added=20Maintenance=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marta --- src/App.jsx | 1 + src/components/Maintenance.jsx | 38 ++++++++++++++++++++++++++ src/i18n/locale-ca.json | 4 ++- src/i18n/locale-es.json | 4 ++- src/i18n/locale-eu.json | 4 ++- src/i18n/locale-gl.json | 4 ++- src/images/tasques-manteniment-web.svg | 1 + 7 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 src/components/Maintenance.jsx create mode 100644 src/images/tasques-manteniment-web.svg diff --git a/src/App.jsx b/src/App.jsx index 1539ac94..b80a814e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -8,6 +8,7 @@ import SomEnergiaTheme from './components/SomenergiaTheme' import { Example as ComponentTest } from './components/ApiValidatedField.example' import Loading from './components/Loading' import ApiStatus from './components/ApiStatus' +import Maintenance from './components/Maintenance' import './i18n/i18n' import './App.css' diff --git a/src/components/Maintenance.jsx b/src/components/Maintenance.jsx new file mode 100644 index 00000000..72774704 --- /dev/null +++ b/src/components/Maintenance.jsx @@ -0,0 +1,38 @@ +import React from 'react' +import Container from '@mui/material/Container' + +import { useTranslation } from 'react-i18next' + +import manteniment from '../images/tasques-manteniment-web.svg' + +const Maintenance = () => { + const { t } = useTranslation() + + return +
+ Estem en mode manteniment +
+
{t("MAINTENANCE_TEXT1")}
+
{t("MAINTENANCE_TEXT2")}
+
+} + +export default Maintenance diff --git a/src/i18n/locale-ca.json b/src/i18n/locale-ca.json index 46bdd82f..5f675961 100644 --- a/src/i18n/locale-ca.json +++ b/src/i18n/locale-ca.json @@ -772,5 +772,7 @@ "ERROR_INVALID_FIELD": "Camp incorrecte", "ERROR_FIELD_TOO_SHORT": "Camp massa curt", "ERROR_FIELD_TOO_LONG": "Camp massa llarg", - "ERROR_REQUIRED_FIELD": "Camp requerit" + "ERROR_REQUIRED_FIELD": "Camp requerit", + "MAINTENANCE_TEXT1": "Estem realitzant tasques de manteniment", + "MAINTENANCE_TEXT2": "Tornem aviat" } \ No newline at end of file diff --git a/src/i18n/locale-es.json b/src/i18n/locale-es.json index 763b6570..3c0d46f2 100644 --- a/src/i18n/locale-es.json +++ b/src/i18n/locale-es.json @@ -721,5 +721,7 @@ "GENERATION_INFO_NOT_HAS_INVOICES": "

Ahora mismo no participas en el sistema de autoproducción colectiva Generation kWh. Si te interesa o quieres más información, puedes consultar la web: www.generationkwh.org

", "GENERATION_FORM_CONTRIBUTION_MEMBER_VAT": "Introduce tu DNI o NIF.", "EXIT": "Salir", - "AT_LEAST_ONE_CHANGE_REASON": "Cómo mínimo tienes que escoger un motivo del cambio" + "AT_LEAST_ONE_CHANGE_REASON": "Cómo mínimo tienes que escoger un motivo del cambio", + "MAINTENANCE_TEXT1": "Estamos realizando tareas de mantenimiento", + "MAINTENANCE_TEXT2": "Volvemos pronto" } diff --git a/src/i18n/locale-eu.json b/src/i18n/locale-eu.json index bc2e5869..72c14bcd 100644 --- a/src/i18n/locale-eu.json +++ b/src/i18n/locale-eu.json @@ -720,5 +720,7 @@ "HOLDER_CASE_TITLE": "Zein da zure egoera?", "HOLDERCHANGE_REVIEW_TEXT": "

Elektrizitate-hornidura Som Energiarekin kontratatzear zaude. Som Energia irabazi asmorik gabeko kooperatiba bat da, eta helburu du herritarren esku dagoen eta % 100 berriztagarria den eredu energetiko bat bultzatzea.

Eskuarki, Kooperatibaren zerbitzuak bazkideentzat bakarrik dira. Baina, denboraldi batez,elektrizitate-hornidura urtebetez kontratatzeko aukera eskainiko diegu, zu bezala, titular-aldaketa baten ondorioz gure proiektura heldu diren eta oraindik Kooperatibako bazkide izan nahi ez duten pertsonei.

Hurrengo hilabeteetan informazio gehiago bidaliko dizugu guri buruz: zer asmo dugun eta zein den gure plana energia berriztagarriak sustatzeko.

Zergatik? Hobeto ezagutzen gaituzunean, zu bazkide gisa elkartzea nahiko genuke. Som Energia 85.000 bazkide baino gehiagok eraiki dugu modu kolektiboan eta askoz bazkide gehiago elkartu nahi ditugu!

", "CAU_INVALID_AFTER_ES_SHOULD_BE_NUMBERS": "'ES' ondoren 16 zenbaki idatzi behar dira", - "CAU_INVALID_REDUNDANCY_CONTROL_SHOULD_BE_LETTERS": "19. eta 20. karaktereetan 2 kontrol-letra idatzi behar dira" + "CAU_INVALID_REDUNDANCY_CONTROL_SHOULD_BE_LETTERS": "19. eta 20. karaktereetan 2 kontrol-letra idatzi behar dira", + "MAINTENANCE_TEXT1": "Mantentze lanak egiten ari gara", + "MAINTENANCE_TEXT2": "Laster itzuliko gara" } diff --git a/src/i18n/locale-gl.json b/src/i18n/locale-gl.json index f123aef0..24ba9779 100644 --- a/src/i18n/locale-gl.json +++ b/src/i18n/locale-gl.json @@ -720,5 +720,7 @@ "HOLDER_CASE_NO_LABEL": "Non coñezo a ningunha persoa socia que me poida convidar", "HOLDERCHANGE_REVIEW_TEXT": "

Estás a piques de contratar a túa subministración eléctrica con Som Energia, cooperativa sen ánimo de lucro que ten como misión impulsar un modelo enerxético 100 % renovábel e en mans da cidadanía.

Normalmente, os servizos da cooperativa están reservados ás persoas socias. Agora, e durante un tempo, ofrecémoslles a posibilidade de contrataren durante un ano a subministración eléctrica a persoas que, coma ti, chegaron ao noso proxecto por medio dun cambio de titular e prefiren non asociarse á cooperativa polo de agora .

Durante os vindeiros meses irémosche explicando máis sobre nós: que é o que nos move e que plan temos para fomentar as enerxías renovábeis.

Con que obxectivo? Gustaríanos que, cando nos coñezas un chisco máis, te unas a Som Energia asociándote. Xa somos máis de 85 000 as persoas que construímos a cooperativa de forma colectiva, e queremos ser moitas máis!

", "CAU_INVALID_REDUNDANCY_CONTROL_SHOULD_BE_LETTERS": "Os caracteres 19 e 20 deben ser 2 letras de control", - "CAU_INVALID_AFTER_ES_SHOULD_BE_NUMBERS": "Despois de 'ES' van 16 números" + "CAU_INVALID_AFTER_ES_SHOULD_BE_NUMBERS": "Despois de 'ES' van 16 números", + "MAINTENANCE_TEXT1": "Estamos realizando tarefas de mantemento", + "MAINTENANCE_TEXT2": "Voltamos axiña" } diff --git a/src/images/tasques-manteniment-web.svg b/src/images/tasques-manteniment-web.svg new file mode 100644 index 00000000..17ebf3f3 --- /dev/null +++ b/src/images/tasques-manteniment-web.svg @@ -0,0 +1 @@ + \ No newline at end of file From 585e9159d5ac5210bfc473ac482bb9840c9e2605 Mon Sep 17 00:00:00 2001 From: Benji Date: Mon, 9 Dec 2024 14:50:57 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=A8=20Created=20AvailabilityContext?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marta --- src/App.jsx | 715 ++++++++++++++-------------- src/components/ApiStatus.jsx | 39 +- src/context/AvailabilityContext.jsx | 21 + 3 files changed, 395 insertions(+), 380 deletions(-) create mode 100644 src/context/AvailabilityContext.jsx diff --git a/src/App.jsx b/src/App.jsx index b80a814e..2cc1751b 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -17,6 +17,7 @@ import { PopUpContextProvider } from './context/PopUpContext' import { MatomoProvider } from './trackers/matomo/MatomoProvider' import { GurbErrorContextProvider } from './context/GurbErrorContext' import { GurbLoadingContextProvider } from './context/GurbLoadingContext' +import { AvailabilityContextProvider } from './context/AvailabilityContext' const App = (props) => { const { token = '', isIndexedPilotOngoing = undefined } = props @@ -100,363 +101,369 @@ const App = (props) => { return ( - - }> - - - } /> - - } - /> - - } - /> - } - /> - - } - /> - } - /> - - - - - } - /> - - - - - - } - /> - - - - } - /> - } - /> - } - /> - } - /> - - - - - } - /> - - - - - } - /> - - {[ - '/new-member', - '/:language/associat/', - '/:language/asociate/', // es, gl - '/:language/bazkidetu/' - ].map((path) => ( - } /> - ))} - - } - /> - } - /> - - - } - /> - - } - /> - - } - /> - } - /> - - - } - /> - - - } - /> - - - } - /> - - - } - /> - - } - /> - - - } - /> - - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - - } /> - } - /> - } - /> - } - /> - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - - - - - } - /> - - - - - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - } - /> - {props?.isGurbEnabled && ( - + + }> + + + + } /> + + } + /> + + } + /> + } + /> + + } + /> + } + /> + + + + + } + /> + + + + + + } + /> + + + + } + /> + } + /> + } + /> + } + /> + + + + + } + /> + + + + + } + /> + + {[ + '/new-member', + '/:language/associat/', + '/:language/asociate/', // es, gl + '/:language/bazkidetu/' + ].map((path) => ( + } /> + ))} + + } + /> + } + /> + + - - - - + } /> - )} - - - - - + + } + /> + + } + /> + } + /> + + + } + /> + + + } + /> + + + } + /> + + + } + /> + + } + /> + + + } + /> + + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + + } /> + } + /> + } + /> + } + /> + } + /> + + } + /> + + } + /> + + } + /> + + } + /> + + + + + + } + /> + + + + + + } + /> + + } + /> + + } + /> + + } + /> + + } + /> + + } + /> + } + /> + {props?.isGurbEnabled && ( + + + + + + } + /> + )} + + {/*} />*/} + + + + + + + ) } diff --git a/src/components/ApiStatus.jsx b/src/components/ApiStatus.jsx index ae214bc6..f83a0c9d 100644 --- a/src/components/ApiStatus.jsx +++ b/src/components/ApiStatus.jsx @@ -1,18 +1,21 @@ -import React, { useState, useEffect } from 'react' - -import { useTranslation } from 'react-i18next' - -import Fade from '@mui/material/Fade' -import Snackbar from '@mui/material/Snackbar' -import Alert from '@mui/material/Alert' -import AlertTitle from '@mui/material/AlertTitle' +import { useState, useEffect, useContext } from 'react' import { apiStatus } from '../services/api' +import AvailabilityContext from '../context/AvailabilityContext' const ApiStatus = () => { - const { t } = useTranslation() const [apiOffline, setApiOffline] = useState(false) const [noConnection, setNoConnection] = useState(false) + const { availability, setAvailability } = useContext(AvailabilityContext) + + useEffect(() => { + if (apiOffline || noConnection) { + setAvailability(false) + } + else if (availability) { + setAvailability(true) + } + },[apiOffline, noConnection]) const checkApiStatus = async () => { apiStatus() @@ -35,22 +38,6 @@ const ApiStatus = () => { return () => clearInterval(interval) }, []) - return ( - <> - { - - - - {noConnection ? t('API_SERVER_ERROR') : t('API_SERVER_OFFLINE')} - - {noConnection - ? t('API_SERVER_ERROR_DETAILS') - : t('API_SERVER_OFFLINE_DETAILS')} - - - } - - ) } -export default ApiStatus +export default ApiStatus \ No newline at end of file diff --git a/src/context/AvailabilityContext.jsx b/src/context/AvailabilityContext.jsx new file mode 100644 index 00000000..5e5db1ae --- /dev/null +++ b/src/context/AvailabilityContext.jsx @@ -0,0 +1,21 @@ +import React, { useState, createContext } from 'react' +import Maintenance from '../components/Maintenance' + +const AvailabilityContext = createContext() + +export const AvailabilityContextProvider = ({ children }) => { + const [availability, setAvailability] = useState(true) + + return ( + + {availability ? + children : + } + + ) +} + +export default AvailabilityContext \ No newline at end of file From 55f0fb0c259d354cd74d5984f88b1060abe8980a Mon Sep 17 00:00:00 2001 From: Benji Date: Tue, 10 Dec 2024 10:01:35 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=9D=20Updated=20Changes.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 224bfecb..4545a28d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Change Log +## Unreleased + +- Replace forms by Maintenance component if ping request fails + ## 2.4.2 2024-12-04 - Gurb: validation pages for non-members