Skip to content

Commit

Permalink
Minor Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
R1c4rdCo5t4 committed Jul 8, 2024
1 parent db87aee commit 887db8d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion code/client/dev-dist/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ define(['./workbox-b5f7729d'], (function (workbox) { 'use strict';
"revision": "3ca0b8505b4bec776b69afdba2768812"
}, {
"url": "index.html",
"revision": "0.hcukrbetkmo"
"revision": "0.bh39c7754p"
}], {});
workbox.cleanupOutdatedCaches();
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
Expand Down
4 changes: 3 additions & 1 deletion code/client/src/ui/components/table/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ReactNode, useState } from 'react';
import { Checkbox } from '@mui/material';
import { GoSortAsc, GoSortDesc } from 'react-icons/go';
import './DataTable.scss';
import { useAuth } from '@/contexts/auth/useAuth';

type DataTableProps = {
columns: string[];
Expand All @@ -25,6 +26,7 @@ function DataTable({
const [selectedAll, setSelectedAll] = useState(false);
const [sortColumn, setSortColumn] = useState('');
const [ascending, setAscending] = useState(true);
const { isLoggedIn } = useAuth();

function onSelectAllRows() {
setSelectedAll(!selectedAll);
Expand All @@ -33,7 +35,7 @@ function DataTable({

return (
<div className="table">
{hasSelected ? deleteButton : createButton}
{isLoggedIn && (hasSelected ? deleteButton : createButton)}
<div className="table-content">
<div className="table-header">
<Checkbox checked={selectedAll} onChange={onSelectAllRows} />
Expand Down
37 changes: 25 additions & 12 deletions code/client/src/ui/pages/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,51 @@ import { WorkspaceMeta } from '@notespace/shared/src/workspace/types/workspace';
import { useEffect, useState } from 'react';
import { useQueryParams } from '@/utils/utils';
import useWorkspaceService from '@services/workspace/useWorkspaceService';
import './Search.scss';
import { FaArrowLeft, FaArrowRight } from 'react-icons/fa6';
import useLoading from '@ui/hooks/useLoading';
import './Search.scss';

const PAGE_SIZE = 10;

function Search() {
const [results, setResults] = useState<WorkspaceMeta[]>([]);
const [page, setPage] = useState(0);
const { query } = useQueryParams();
const { spinner, startLoading, stopLoading, loading } = useLoading();
const service = useWorkspaceService();

useEffect(() => {
async function searchWorkspaces() {
startLoading();
const results = await service.searchWorkspaces(query, page * PAGE_SIZE, PAGE_SIZE);
setResults(results);
stopLoading();
}
searchWorkspaces();
}, [page, query, service]);
}, [page, query, service, startLoading, stopLoading]);

return (
<div className="search">
<h2>Search results for "{query}"</h2>
{results.length > 0 ? (
results.map(workspace => (
<div className="workspace">
<Link key={workspace.id} to={`/workspace/${workspace.id}`}>
{workspace.name}
</Link>
</div>
))
{loading ? (
<>
<h2>Searching...</h2>
{spinner}
</>
) : (
<p>No results found</p>
<>
<h2>Search results for "{query}"</h2>
{results.length > 0 ? (
results.map(workspace => (
<div className="workspace">
<Link key={workspace.id} to={`/workspaces/${workspace.id}`}>
{workspace.name}
</Link>
</div>
))
) : (
<p>No results found</p>
)}
</>
)}
<div className="pagination">
<button onClick={() => setPage(page - 1)} disabled={page === 0}>
Expand Down

0 comments on commit 887db8d

Please sign in to comment.