diff --git a/frontend/components/Admin/Registries.js b/frontend/components/Admin/Registries.js index b7f0bfc9..5e40027d 100644 --- a/frontend/components/Admin/Registries.js +++ b/frontend/components/Admin/Registries.js @@ -32,6 +32,7 @@ export default function Registries() { return (
{getType(member)} | {member.description} | - handleIconClick(member)}>
- |
+ {!isPublicCollection && (
+ handleIconClick(member)}>
+ |
+ )}
);
}}
@@ -431,7 +457,13 @@ const createUrl = (query, options) => {
const useCount = (query, options, token, dispatch) => {
const url = createUrl(query, options, token);
- const { data, error } = useSWR([url, token, dispatch], fetcher);
+ let data, error;
+
+ if (typeof token === 'string') {
+ ({ data, error } = useSWR([url, token, dispatch], fetcher));
+ } else {
+ ({ data, error } = useSWR([url, dispatch], fetcher));
+ }
let processedData = data ? processResults(data)[0].count : undefined;
return {
@@ -441,10 +473,15 @@ const useCount = (query, options, token, dispatch) => {
const useMembers = (query, options, token, dispatch) => {
const url = createUrl(query, options);
- const { data, error, mutate } = useSWR([url, token, dispatch], fetcher);
+ let data, error, mutate;
- let processedData = data ? processResults(data) : undefined;
+ if (typeof token === 'string') {
+ ({ data, error, mutate } = useSWR([url, token, dispatch], fetcher));
+ } else {
+ ({ data, error, mutate } = useSWR([url, dispatch], fetcher));
+ }
+ let processedData = data ? processResults(data) : undefined;
return {
members: processedData,
mutate
@@ -453,12 +490,20 @@ const useMembers = (query, options, token, dispatch) => {
const useFilters = (query, options, token, dispatch) => {
const url = createUrl(query, options);
- const { data, error } = useSWR([url, token, dispatch], fetcher);
+
+ let data, error, mutate;
+
+ if (typeof token === 'string') {
+ ({ data, error, mutate } = useSWR([url, token, dispatch], fetcher));
+ } else {
+ ({ data, error, mutate } = useSWR([url, dispatch], fetcher));
+ }
let processedData = data ? processResults(data) : undefined;
return {
- filters: processedData
+ filters: processedData,
+ mutate
};
};
@@ -479,12 +524,13 @@ const fetcher = (url, token, dispatch) =>
// Check if the error is 401 Unauthorized or 400 Bad Request
if (error.response && (error.response.status === 401 || error.response.status === 400)) {
// Check if the user is logged in by looking for 'userToken' in local storage
- console.log(localStorage);
- console.log(error.response);
if (!localStorage.getItem('userToken')) {
console.log('Missing user token');
// User is not logged in, redirect to the login page
- // window.location.href = '/login';
+ dispatch(logoutUser());
+ window.location.href = '/login';
+ } else {
+ console.error(error);
}
}
diff --git a/frontend/components/Viewing/ViewHeader.js b/frontend/components/Viewing/ViewHeader.js
index 4fd82be7..fa6babeb 100644
--- a/frontend/components/Viewing/ViewHeader.js
+++ b/frontend/components/Viewing/ViewHeader.js
@@ -7,6 +7,9 @@ import React, { useRef } from 'react';
import { useSelector } from 'react-redux';
import { useState } from 'react';
+import SearchHeader from '../Search/SearchHeader/SearchHeader';
+import ResultTable from '../Search/StandardSearch/ResultTable/ResultTable';
+
import axios from 'axios';
import Link from 'next/link';
@@ -71,6 +74,12 @@ export default function ViewHeader(properties) {
})
.then(response => {
console.log(response.data);
+ return (
+