Skip to content

Commit

Permalink
Merge pull request #339 from UTDNebula/fix-loading-homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiramTadepalli authored Jan 6, 2025
2 parents dac5f04 + ddd8798 commit c9328bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/search/SearchBar/searchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ const SearchBar = ({
onClick={() => onSelect_internal(value)}
>
{resultsLoading === 'loading' ? (
<CircularProgress className="h-6 w-6 text-cornflower-50 dark:text-cornflower-800" />
<CircularProgress className="h-6 w-6 text-cornflower-50" />
) : (
'Search'
)}
Expand Down
11 changes: 10 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { NextPage } from 'next';
import Head from 'next/head';
import Image from 'next/image';
import { useRouter } from 'next/router';
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';

import Background from '@/../public/background.png';
import SearchBar from '@/components/search/SearchBar/searchBar';
Expand All @@ -11,6 +11,8 @@ import {
searchQueryLabel,
} from '@/modules/SearchQuery/SearchQuery';

import type { GenericFetchedData } from './dashboard';

/**
* Returns the home page with Nebula Branding, waved background, and SearchBar Components
*/
Expand All @@ -29,6 +31,11 @@ const Home: NextPage = () => {
}
}

const [results, setResults] = useState<GenericFetchedData<SearchQuery[]>>({
state: 'done',
data: [],
}); // essentially a dummy state. Used only for the loading animation to start in homescreen before navigation to the dashboard

useEffect(() => {
router.prefetch('/dashboard');
}, [router]);
Expand Down Expand Up @@ -73,6 +80,8 @@ const Home: NextPage = () => {
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus={true}
onSelect={searchOptionChosen}
resultsLoading={results.state}
setResultsLoading={() => setResults({ state: 'loading' })}
input_className="[&>.MuiInputBase-root]:bg-white [&>.MuiInputBase-root]:dark:bg-haiti"
/>
</div>
Expand Down

0 comments on commit c9328bf

Please sign in to comment.