Skip to content

Commit

Permalink
idk what happened
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFJcurve committed Nov 14, 2024
1 parent 8aed704 commit 2e13ee8
Show file tree
Hide file tree
Showing 17 changed files with 10,158 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
}
36 changes: 36 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
20 changes: 20 additions & 0 deletions frontend/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "app/globals.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
}
}
57 changes: 57 additions & 0 deletions frontend/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"

import { cn } from "@/lib/utils"

const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
{
variants: {
variant: {
default:
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
destructive:
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
outline:
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
secondary:
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button"
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
)
}
)
Button.displayName = "Button"

export { Button, buttonVariants }
76 changes: 76 additions & 0 deletions frontend/components/ui/card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import * as React from "react"

import { cn } from "@/lib/utils"

const Card = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
"rounded-xl border bg-card text-card-foreground shadow",
className
)}
{...props}
/>
))
Card.displayName = "Card"

const CardHeader = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex flex-col space-y-1.5 p-6", className)}
{...props}
/>
))
CardHeader.displayName = "CardHeader"

const CardTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h3
ref={ref}
className={cn("font-semibold leading-none tracking-tight", className)}
{...props}
/>
))
CardTitle.displayName = "CardTitle"

const CardDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<p
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
))
CardDescription.displayName = "CardDescription"

const CardContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
))
CardContent.displayName = "CardContent"

const CardFooter = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex items-center p-6 pt-0", className)}
{...props}
/>
))
CardFooter.displayName = "CardFooter"

export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
123 changes: 123 additions & 0 deletions frontend/components/ui/home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"use client";
import { useCallback, useEffect, useState } from "react";
import { useDropzone } from "react-dropzone";
import Sidenav from "./sidenav";

import {Card, CardHeader, CardBody, CardFooter, Divider, Link, Image} from "@nextui-org/react";

import website_data from '../../../backend/website_data.json'

export default function Home() {
interface FileProps {
path?: string;
lastModified: number;
lastModifiedDate?: Date;
name: string;
size: number;
type: string;
webkitRelativePath: string;
}
const [fileData, setFileData] = useState<Array<object>>(website_data);

// Function to upload files to the API
const uploadFile = async (file: FileProps) => {
const formData = new FormData();
formData.append("file", file as Blob); // Append the file to formData

try {
const response = await fetch("http://127.0.0.1:5000/receive-file", {
method: "POST",
body: formData,
});

if (response.ok) {
const data = await response.json();
setFileData(data.data);
} else {
console.error("Failed to upload file");
}
} catch (error) {
console.error("Error uploading file:", error);
}
};

useEffect(() => {
console.log(fileData);
}, [fileData]);

// Handle file drop
const onDrop = useCallback((acceptedFiles: FileProps[]) => {
// Handle file upload here and display the files
console.log(acceptedFiles);

// Loop through each file and send to the API
acceptedFiles.forEach((file) => {
uploadFile(file);
});
}, []);

const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop });

return (
<div className="flex min-h-screen bg-gray-100">
{/* Sidebar */}
<Sidenav />

{/* Main Content */}
<main className="flex-1 p-6">
<header className="mb-8">
<h1 className="text-3xl font-bold">Hello there! 👋</h1>
<p className="text-gray-600">
Looking to share files? We can help you with that, please select
your file below!
</p>
</header>

<section className="mb-12">
<h2 className="text-xl font-semibold mb-4">
Choose a starting point you like
</h2>
<div
{...getRootProps()}
className={`border-2 border-dashed p-6 rounded-lg cursor-pointer ${
isDragActive ? "border-blue-500" : "border-gray-300"
}`}
>
<input {...getInputProps()} />
{isDragActive ? (
<p>Drop the files here ...</p>
) : (
<p>Drag 'n' drop some files here, or click to select files</p>
)}
</div>
</section>

<section>
<h2 className="text-xl font-semibold mb-4">Current ID:</h2>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
{Object.entries(fileData).map(([key, value]) => (
<Card
className="max-w-[800px] w-full p-4 my-4 border border-gray-200 rounded-lg shadow-md bg-white"
key={key}
>
<CardHeader className="flex items-center gap-3 pb-2">
<div className="flex flex-col">
<p className="text-lg font-semibold text-gray-800">
{value.path.slice("upload/".length+1)}
</p>
</div>
</CardHeader>
<Divider />
<CardBody className="py-4">
<b>Hash-key:</b>
<p className="text-sm text-gray-500 font-medium break-words w-full">{key}</p>
</CardBody>
<Divider />
</Card>
))}
</div>
</section>
</main>
</div>
);
}
9 changes: 9 additions & 0 deletions frontend/components/ui/input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'

const input = () => {
return (
<div></div>
)
}

export default input
Loading

0 comments on commit 2e13ee8

Please sign in to comment.