Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettier No Results #422

Merged
merged 22 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1409de8
added state variable for if there are results
Jackson-Williams-15 Mar 20, 2024
83afe0a
fixed logic
Jackson-Williams-15 Mar 20, 2024
49e2655
conditional statement for showing 'no results' and page numbers
Jackson-Williams-15 Mar 20, 2024
a340efd
ran formatter
Jackson-Williams-15 Mar 20, 2024
d76ff2b
Looks better when all caps
Jackson-Williams-15 Mar 20, 2024
40fcd9a
added icon to the no results display
Jackson-Williams-15 Mar 20, 2024
25a0bae
added state variable for results
Jackson-Williams-15 Mar 20, 2024
45d56a0
set results if there are more than 0
Jackson-Williams-15 Mar 21, 2024
fdb1cdf
added conidtional statement to social page
Jackson-Williams-15 Mar 21, 2024
c6966fc
moved results and pagination to own component
Jackson-Williams-15 Mar 21, 2024
34d91cc
use new component
Jackson-Williams-15 Mar 21, 2024
01e0584
Shrank size of text and icon
Jackson-Williams-15 Mar 21, 2024
e4160e8
removed unused imports
Jackson-Williams-15 Mar 21, 2024
649ce1e
removed unused import
Jackson-Williams-15 Mar 21, 2024
03fde3d
use total results
Jackson-Williams-15 Mar 21, 2024
49ace5f
Remove hasResults var, use total results
Jackson-Williams-15 Mar 21, 2024
ea56ed1
changed return stateement to if totalResults is equal to 0
Jackson-Williams-15 Mar 21, 2024
959ab83
removed boolean
Jackson-Williams-15 Mar 21, 2024
afb9a0c
removed boolean
Jackson-Williams-15 Mar 21, 2024
60ecdf2
page count
Jackson-Williams-15 Mar 21, 2024
bb20d71
added count
Jackson-Williams-15 Mar 21, 2024
c8345d7
ran formatter
Jackson-Williams-15 Mar 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions FU.SPA/src/components/SearchResults.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Stack, Typography, Pagination } from '@mui/material';
import SearchOffIcon from '@mui/icons-material/SearchOff';

const searchResults = ({ page, totalResults, queryLimit, setPage }) => {
return totalResults ? (
<Stack spacing={2}>
<Typography>Page: {page}</Typography>
<Pagination
count={Math.ceil(totalResults / queryLimit)}
page={page}
onChange={(_, value) => setPage(value)}
color="secondary"
/>
</Stack>
) : (
<div style={{ textAlign: 'center', color: 'violet', padding: '20px' }}>
<SearchOffIcon style={{ fontSize: '64px' }} />
<Typography variant="h5">No Results Found</Typography>
</div>
);
};

export default searchResults;
22 changes: 9 additions & 13 deletions FU.SPA/src/components/pages/Discover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import dayjs from 'dayjs';
import { useSearchParams } from 'react-router-dom';
import {
Typography,
Pagination,
MenuItem,
InputLabel,
FormControl,
Select,
} from '@mui/material';
import Stack from '@mui/material/Stack';
import { useEffect, useState } from 'react';
import { TagsSelector, GamesSelector, SortOptionsSelector } from '../Selectors';
import SearchService from '../../services/searchService';
Expand All @@ -25,6 +23,7 @@ import {
import './Discover.css';
import TextSearch from '../TextSearch';
import config from '../../config';
import SearchResults from '../SearchResults';

const paramKey = {
endDate: 'endDate',
Expand Down Expand Up @@ -214,7 +213,7 @@ export default function Discover() {

const response = await SearchService.searchPosts(query);
setPosts(response.data);
setTotalResults(response.totalCount);
setTotalResults(response.totalCount || response.data.length > 0);
evan-scales marked this conversation as resolved.
Show resolved Hide resolved
} else {
const query = {
keywords: searchText,
Expand All @@ -224,7 +223,7 @@ export default function Discover() {

const response = await SearchService.searchUsers(query);
setPlayers(response.data);
setTotalResults(response.totalCount);
setTotalResults(response.totalCount || response.data.length > 0);
}
};

Expand Down Expand Up @@ -428,15 +427,12 @@ export default function Discover() {
marginRight: '150px',
}}
>
<Stack spacing={2}>
<Typography>Page: {page}</Typography>
<Pagination
count={Math.ceil(totalResults / queryLimit)}
page={page}
onChange={(_, value) => setPage(value)}
color="secondary"
/>
</Stack>
<SearchResults
page={page}
totalResults={totalResults}
queryLimit={queryLimit}
setPage={setPage}
/>
</div>
</div>
</div>
Expand Down
30 changes: 10 additions & 20 deletions FU.SPA/src/components/pages/Social.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
Select,
Typography,
MenuItem,
InputLabel,
FormControl,
Pagination,
} from '@mui/material';
import Stack from '@mui/material/Stack';
import { Select, MenuItem, InputLabel, FormControl } from '@mui/material';
import { useEffect, useState, useContext } from 'react';
import UserService from '../../services/userService';
import RelationService from '../../services/relationService';
Expand All @@ -16,6 +8,7 @@ import './Social.css';
import { useSearchParams } from 'react-router-dom';
import UserContext from '../../context/userContext';
import TextSearch from '../TextSearch';
import SearchResults from '../SearchResults';

const paramKey = {
tabOption: 'o',
Expand Down Expand Up @@ -108,7 +101,7 @@ export default function Social() {
try {
const response = await UserService.getConnectedPosts(query);
setPosts(response.data);
setTotalResults(response.totalCount || 0);
setTotalResults(response.totalCount || response.data.length > 0);
evan-scales marked this conversation as resolved.
Show resolved Hide resolved
} catch (error) {
console.error('Error', error);
}
Expand All @@ -120,7 +113,7 @@ export default function Social() {
try {
const response = await RelationService.getRelations(user.id, query);
setUsers(response.data);
setTotalResults(response.totalCount || 0);
setTotalResults(response.totalCount || response.data.length > 0);
} catch (error) {
console.error('Error', error);
}
Expand Down Expand Up @@ -216,15 +209,12 @@ export default function Social() {
marginRight: '150px',
}}
>
<Stack spacing={2}>
<Typography>Page: {page}</Typography>
<Pagination
count={Math.ceil(totalResults / queryLimit)}
page={page}
onChange={(_, value) => setPage(value)}
color="secondary"
/>
</Stack>
<SearchResults
page={page}
totalResults={totalResults}
queryLimit={queryLimit}
setPage={setPage}
/>
</div>
</div>
</div>
Expand Down