diff --git a/frontend/CommitHash.js b/frontend/CommitHash.js new file mode 100644 index 00000000..22713eb1 --- /dev/null +++ b/frontend/CommitHash.js @@ -0,0 +1,8 @@ +const { execSync } = require('child_process'); +const fs = require('fs'); +const path = require('path'); + +const commitHash = execSync('git rev-parse HEAD').toString().trim(); +const outputPath = path.join(__dirname, 'public', 'commitHash.txt'); + +fs.writeFileSync(outputPath, commitHash); \ No newline at end of file diff --git a/frontend/CustomDev.js b/frontend/CustomDev.js new file mode 100644 index 00000000..13c17e4e --- /dev/null +++ b/frontend/CustomDev.js @@ -0,0 +1,7 @@ +const { execSync } = require('child_process'); + +// Run setCommitHash.js script +execSync('node CommitHash.js', { stdio: 'inherit' }); + +// Start the Next.js development server +execSync('next dev -p 3333', { stdio: 'inherit' }); diff --git a/frontend/components/Admin/Registries.js b/frontend/components/Admin/Registries.js index 9b89e3cd..b7f0bfc9 100644 --- a/frontend/components/Admin/Registries.js +++ b/frontend/components/Admin/Registries.js @@ -283,14 +283,37 @@ const fetcher = (url, token, dispatch) => export async function processUrl(inputUrl, token, dispatch) { const data = await fetcher(`${publicRuntimeConfig.backend}/admin/registries`, token, dispatch); - const registries = data.registries; - for (const registry of registries) { - if (inputUrl.startsWith(registry.uri)) { - const urlRemovedForLink = inputUrl.replace(registry.uri, ""); - const urlReplacedForBackend = inputUrl.replace(registry.uri, registry.url); - return { urlRemovedForLink, urlReplacedForBackend }; + if (data) { + const registries = data.registries; + + for (const registry of registries) { + if (inputUrl.startsWith(registry.uri)) { + const urlRemovedForLink = inputUrl.replace(registry.uri, ""); + const urlReplacedForBackend = inputUrl.replace(registry.uri, registry.url); + return { urlRemovedForLink, urlReplacedForBackend }; + } + } + return { original: inputUrl }; // if you don't match any uri + } + return { original: inputUrl }; // if you don't match any uri +} + +export async function processUrlReverse(inputUrl, token, dispatch) { + + const data = await fetcher(`${publicRuntimeConfig.backend}/admin/registries`, token, dispatch); + + if (data) { + const registries = data.registries; + + for (const registry of registries) { + if (inputUrl.startsWith(registry.url)) { + const uriRemovedForLink = inputUrl.replace(registry.url, ""); + const uriReplacedForBackend = inputUrl.replace(registry.url, registry.uri); + return { uriRemovedForLink, uriReplacedForBackend }; + } } + return { original: inputUrl }; // if you don't match any uri } return { original: inputUrl }; // if you don't match any uri } \ No newline at end of file diff --git a/frontend/components/Admin/Theme.js b/frontend/components/Admin/Theme.js index 2accb9c3..8266b75a 100644 --- a/frontend/components/Admin/Theme.js +++ b/frontend/components/Admin/Theme.js @@ -171,7 +171,15 @@ const fetcher = (url, dispatch) => }) .then(response => response.data) .catch(error => { - error.customMessage = 'Request failed for GET /admin/theme'; - error.fullUrl = url; - dispatch(addError(error)); + if (error.message === 'Network Error') { + // Change the error message or handle it differently + console.error('Unable to connect to the server. Please check your network connection.'); + dispatch(addError(error)); + } else { + // Handle other errors + error.customMessage = 'Request failed for GET /admin/theme31278931739137131'; + error.fullUrl = url; + dispatch(addError(error)); + } + }); diff --git a/frontend/components/Error/ErrorClearer.js b/frontend/components/Error/ErrorClearer.js index a8826649..fccd3d00 100644 --- a/frontend/components/Error/ErrorClearer.js +++ b/frontend/components/Error/ErrorClearer.js @@ -1,9 +1,40 @@ import { useDispatch } from 'react-redux'; import styles from '../../styles/error.module.css'; -import { clearErrors, removeErrorByIndex } from '../../redux/actions'; +import { useRouter } from 'next/router'; +import { clearErrors, removeErrorByIndex, logoutUser } from '../../redux/actions'; -export default function ErrorClearer({ index, setIndex }) { +export default function ErrorClearer({ index, setIndex, size }) { const dispatch = useDispatch(); + const router = useRouter(); + if (size === 'relog') { + return ( +