Skip to content

Commit

Permalink
fix: minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
vantage-ola committed Aug 21, 2024
1 parent 97f07db commit 682285a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 53 deletions.
4 changes: 2 additions & 2 deletions tracknow/web/src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const NavbarWelcome = () => (
<Box><Link as={ReactRouterLink} to="#" variant={'navbarLink'}><Text fontSize="xl" as="b">tracknow</Text></Link></Box>
<Flex alignItems={'center'}>
<Stack direction={'row'} spacing={4}>
<Text color={'GrayText'}>v-alpha2.2</Text> {/* TODO write function to get from github directly */}

<Link variant={'navbarLink'} as={ReactRouterLink} to={'/create-user'}>signup</Link>
<Link variant={'navbarLink'} as={ReactRouterLink} to={'/login'}>login</Link>

Expand Down Expand Up @@ -60,7 +60,7 @@ const Navbar = () => (

<Flex alignItems={'center'}>
<Stack direction={'row'} spacing={7}>
<Text color={'GrayText'}>v-alpha2.2</Text> {/* TODO write function to get from github directly */}


</Stack>
</Flex>
Expand Down
8 changes: 2 additions & 6 deletions tracknow/web/src/components/User/UserLaptimes.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//import { useNavigate } from "react-router-dom";
//import { LoadingSpinner } from "../Loading/LoadingSpinner";
import { useUsers } from "../../hooks/useUsers";
import { LoadingSpinner } from "../Loading/LoadingSpinner";
//import { LoadingSpinner } from "../Loading/LoadingSpinner";
import { UserProfile } from "./UserProfile";

const UserLaptimes = () => {
Expand Down Expand Up @@ -32,11 +32,7 @@ const UserLaptimes = () => {

return (
<>
{loading ? (
<LoadingSpinner />
) : (
<UserProfile id={userId} />
)}
<UserProfile id={userId} />
</>
);

Expand Down
73 changes: 28 additions & 45 deletions tracknow/web/src/components/User/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import {
Center, Avatar, Stack, Text,
CardHeader, Heading,
} from "@chakra-ui/react";
import { LoadingSpinner } from "../Loading/LoadingSpinner";
//import { LoadingSpinner } from "../Loading/LoadingSpinner";
import { GetUserLaptimesResponse, OneUser } from "../../Types";
import { useLaptimes } from "../../hooks/useLaptimes";
import { HomePost } from "../Post/Post";
import { BeatLoader } from "react-spinners";

export const UserProfile = ({ id }: { id: number }) => {

const { loading } = useUsers();
//const { loading } = useUsers();
const [userData, setUserData] = React.useState<OneUser | null>(null);
const [laptimes, setUserLaptimes] = React.useState<GetUserLaptimesResponse[]>([]);
const [hasMore, setHasMore] = React.useState(true);
Expand Down Expand Up @@ -65,12 +65,6 @@ export const UserProfile = ({ id }: { id: number }) => {

}, [page]);

if (loading && laptime_loading) {
return (
<LoadingSpinner />
);
};

if (!laptime_loading && laptimes.length === 0) {
return (
<>
Expand All @@ -85,53 +79,42 @@ export const UserProfile = ({ id }: { id: number }) => {


return (

<>
{laptime_loading ? (
<LoadingSpinner />
{/* Main Section */}

) : (
<>
{/* Main Section */}
<Card size={'lg'} width={{ base: '100vw', md: 'auto' }}>

<Card size={'lg'} width={{ base: '100vw', md: 'auto' }}>
<CardHeader>
<Heading size={'md'} ml={{ base: 2 }} >{userData ? userData.username : "Loading..."}'s Profile</Heading>
</CardHeader>
<Center>

<CardHeader>
<Heading size='md'>{userData ? userData.username : "Loading..."}'s Profile</Heading>
</CardHeader>
<Stack>
<Avatar
size={"2xl"}
src={userData ? userData.profile_picture : ""}
/>
<Center>
<Text>{userData ? userData.nationality : "Loading..."}</Text>

<Stack>
<Avatar
size={"2xl"}
src={userData ? userData.profile_picture : ""}
/>
<Center>
<Text>{userData ? userData.nationality : "Loading..."}</Text>
</Center>
</Stack>

</Center>
</Stack>

</Center>
<CardBody >
<HomePost
laptimes={laptimes}
fetchMoreData={fetchMoreData}
hasMore={hasMore}
/>

</Center>
<CardBody >
<HomePost
laptimes={laptimes}
fetchMoreData={fetchMoreData}
hasMore={hasMore}
/>
{hasMore && (
<Center>
<BeatLoader size={8} color='red' />
</Center>
)}
</CardBody>

</Card>
</>

)}
</CardBody>

</Card>
</>


);

};

0 comments on commit 682285a

Please sign in to comment.