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

Datasets #73

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
111 changes: 111 additions & 0 deletions frontend/components/DatasetsPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
"use client";
import { useState, useEffect } from "react";
import {
Box,
Button,
Container,
Flex,
Heading,
Icon,
Stack,
Text,
useColorModeValue,
} from "@chakra-ui/react";
import { ReactElement } from "react";
import {
FcAbout,
FcAssistant,
FcCollaboration,
FcDonate,
FcManager,
} from "react-icons/fc";

import Link from "next/link";

import { datasets } from "@/app/datasets/config";

import axios from "axios";
import { useQuery } from "react-query";
import { API_URL } from "@/app/config";

const fetchDatasets = async () => {
try {
const response = await axios.get(`${API_URL}/datasets/`, {});
return response.data;
} catch (error) {
console.error("Error fetching datasets:", error);
return [];
}
};

interface CardProps {
heading: string;
href: string;
}

function capitalizeFirstLetter(word: string) {
if (!word) return word;
return word.charAt(0).toUpperCase() + word.slice(1);
}

const Card = ({ heading, href }: CardProps) => {
return (
<Box
maxW={{ base: "full", md: "275px" }}
w={"full"}
borderWidth="1px"
borderRadius="lg"
overflow="hidden"
borderColor={"a4borange"}
p={5}
>
<Stack align={"start"} spacing={2}>
<Box mt={2}>
<Heading size="md">{heading}</Heading>
</Box>
<Link href={href}>
<Button variant={"link"} textColor={"a4borange"} size={"sm"}>
Learn more
</Button>
</Link>
</Stack>
</Box>
);
};

export default function DatasetsList() {
const [datasets, setDatasets] = useState([]);
const { isLoading, error, data } = useQuery("fetchDatasets", fetchDatasets);

useEffect(() => {
if (error || isLoading) {
setDatasets([]);
} else {
setDatasets(data);
}
}, [error, data, isLoading]);
return (
<Box p={4}>
<Stack spacing={4} as={Container} maxW={"3xl"} textAlign={"center"}>
<Heading fontSize={{ base: "2xl", sm: "4xl" }} fontWeight={"bold"}>
Datasets
</Heading>
<Text color={"gray.600"} fontSize={{ base: "sm", sm: "lg" }}>
Browse through the different datasets that we have built at AI4Bharat
</Text>
</Stack>

<Container maxW={"5xl"} mt={12}>
<Flex flexWrap="wrap" gridGap={6} justify="center">
{datasets.map((dataset: any) => (
<Card
key={dataset.title}
heading={capitalizeFirstLetter(dataset.title)}
href={dataset.website_link || ""}
/>
))}
</Flex>
</Container>
</Box>
);
}
6 changes: 5 additions & 1 deletion frontend/components/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export default function Hero() {
>
<Stack flex={1} spacing={{ base: 5, md: 10 }}>
<HStack>
<Image src={"/assets/logos/ai4baltlogo.webp"} />
<Image
height={150}
width={150}
src={"/assets/logos/ai4bclogo.png"}
/>
<Heading
ml={5}
lineHeight={1.1}
Expand Down
Binary file added frontend/public/assets/logos/ai4bclogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 3 additions & 12 deletions frontend/src/app/datasets/[title]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import { datasets } from "../config";

export async function generateStaticParams() {
let params: any[] = [
{ title: "svarah" },
{ title: "lahaja" },
{ title: "shrutilipi" },
{ title: "sangraha" },
{ title: "samanantar" },
{ title: "aksharantar" },
{ title: "IndicVoices-R" },
{ title: "IndicOOV" },
{ title: "FBI" },
{ title: "Bhasha-Abhijnaanam" },
];
let params: any[] = datasets;

return params;
}
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/app/datasets/config.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const datasets = [
{ title: "svarah" },
{ title: "lahaja" },
{ title: "shrutilipi" },
{ title: "sangraha" },
{ title: "samanantar" },
{ title: "aksharantar" },
{ title: "IndicVoices-R" },
{ title: "IndicOOV" },
{ title: "FBI" },
{ title: "Bhasha-Abhijnaanam" },
];
5 changes: 5 additions & 0 deletions frontend/src/app/datasets/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import DatasetsList from "../../../components/DatasetsPage";

export default function DatasetsPage() {
return <DatasetsList />;
}
3 changes: 3 additions & 0 deletions frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export const metadata: Metadata = {
title: "AI4Bharat",
description:
"AI4Bharat is a research lab at IIT Madras which works on developing open-source datasets, tools, models and applications for Indian languages.",
openGraph: {
images: "/assets/logos/ai4bclogo.png",
},
};

export default function RootLayout({
Expand Down
Loading