add no member found error

This commit is contained in:
Spectralitree 2021-01-06 13:11:18 +01:00
parent 19b250eaff
commit cfd399863b
3 changed files with 31 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,11 +1,24 @@
import React from 'react'; import React, { useState, useEffect } from 'react';
import * as BS from 'react-bootstrap';
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import MemberPage from './MemberPage.js' import MemberPage from './MemberPage.js'
export default function MemberPages(props) { export default function MemberPages(props) {
const { memberID } = useParams(); const { memberID } = useParams();
const [ noMatch, setNoMatch ] = useState(false);
const memberpage = props.members.filter((member) => member.id === memberID).map((member) => <MemberPage key={member.id} member={member}/>) const memberpages = props.members.filter((member) => member.id === memberID)
const memberpage = memberpages.map((member) => <MemberPage key={member.id} member={member}/>)
useEffect (() => {
if (memberpages.length === 0) {
setNoMatch(true);
}
}, [memberpages])
if (noMatch) return (
<BS.Alert variant="danger">You do not have a member with the ID '{memberID}' in your system. Please check the ID again.</BS.Alert>
)
return ( return (
<> <>

View File

@ -1,11 +1,24 @@
import React from 'react'; import React, { useState, useEffect } from 'react';
import * as BS from 'react-bootstrap';
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import ProfilePage from './ProfilePage.js' import ProfilePage from './ProfilePage.js'
export default function MemberPages(props) { export default function MemberPages(props) {
const { memberID } = useParams(); const { memberID } = useParams();
const [ noMatch, setNoMatch ] = useState(false);
const memberpage = props.members.filter((member) => member.id === memberID).map((member) => <ProfilePage key={member.id} member={member}/>) const memberpages = props.members.filter((member) => member.id === memberID)
const memberpage = memberpages.map((member) => <ProfilePage key={member.id} member={member}/>)
useEffect (() => {
if (memberpages.length === 0) {
setNoMatch(true);
}
}, [memberpages])
if (noMatch) return (
<BS.Alert variant="danger">This system does not have a member with the ID '{memberID}', or the member's visibility is set to private.</BS.Alert>
)
return ( return (
<> <>