Skip to content

Commit

Permalink
chore: format & remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
clostao committed Nov 6, 2024
1 parent bd0affe commit a417a6e
Show file tree
Hide file tree
Showing 91 changed files with 1,896 additions and 2,042 deletions.
Binary file modified frontend/.yarn/install-state.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ cd auto-drive/frontend

Once the repository is cloned, you need to setup your enviroment.


Execute this command for creating the enviroment file and then fulfill every missing entry.

```
cp .env.sample .env.local
```
Expand Down
10 changes: 5 additions & 5 deletions frontend/next-auth.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type * as nextAuth from "next-auth";
import type * as nextAuth from 'next-auth';

declare module "next-auth" {
declare module 'next-auth' {
interface Session {
error?: "RefreshTokenError";
error?: 'RefreshTokenError';
accessToken?: string;
provider?: string;
}
Expand All @@ -12,12 +12,12 @@ declare module "next-auth" {
}
}

declare module "next-auth/jwt" {
declare module 'next-auth/jwt' {
interface JWT {
accessToken?: string;
expires_at: number;
refresh_token?: string;
error?: "RefreshTokenError";
error?: 'RefreshTokenError';
provider?: string;
}
}
5 changes: 5 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,16 @@
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/streamsaver": "^2",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",
"eslint": "^8",
"eslint-config-next": "14.2.9",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.2",
"postcss": "^8",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.8",
"tailwindcss": "^3.4.1",
"typescript": "^5"
},
Expand Down
6 changes: 2 additions & 4 deletions frontend/prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"semi": false,
"tabWidth": 2,

"printWidth": 10,
"singleQuote": true,
"trailingComma": "all",
"jsxSingleQuote": true,
"bracketSpacing": true,
"plugins": ["prettier-plugin-tailwindcss"],
"extends": [
"eslint:recommended",
"plugin:prettier/recommended"
]
"extends": ["eslint:recommended", "plugin:prettier/recommended"]
}
10 changes: 5 additions & 5 deletions frontend/src/app/api/auth/[...nextauth]/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AuthOptions } from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import DiscordProvider from "next-auth/providers/discord";
import { AuthOptions } from 'next-auth';
import GoogleProvider from 'next-auth/providers/google';
import DiscordProvider from 'next-auth/providers/discord';
export const authOptions: AuthOptions = {
providers: [
GoogleProvider({
Expand All @@ -19,7 +19,7 @@ export const authOptions: AuthOptions = {
token.accessToken = account?.access_token;
token.provider = account?.provider;
} else {
console.warn("No account found");
console.warn('No account found');
}
return token;
},
Expand All @@ -30,7 +30,7 @@ export const authOptions: AuthOptions = {
},
async redirect({ url: _url, baseUrl: _baseUrl }) {
const baseUrl = process.env.URL || _baseUrl;
const url = _url.startsWith("/")
const url = _url.startsWith('/')
? `${baseUrl}${_url}`
: _url.replace(_baseUrl, baseUrl);

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NextAuth from "next-auth";
import { authOptions } from "./config";
import NextAuth from 'next-auth';
import { authOptions } from './config';

const handler = NextAuth(authOptions);

Expand Down
14 changes: 7 additions & 7 deletions frontend/src/app/drive/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";
'use client';

import { useEffect, useState } from "react";
import { ApiService } from "../../../services/api";
import { UserSubscriptionsTable } from "../../../components/UserTable";
import { SubscriptionWithUser } from "../../../models/Subscriptions";
import { useEffect, useState } from 'react';
import { ApiService } from '../../../services/api';
import { UserSubscriptionsTable } from '../../../components/UserTable';
import { SubscriptionWithUser } from '../../../models/Subscriptions';

export default function Page() {
const [users, setUsers] = useState<SubscriptionWithUser[] | undefined>();
Expand All @@ -14,8 +14,8 @@ export default function Page() {

return (
<div>
<h1 className="text-2xl font-bold mb-4">Users</h1>
<div className="flex flex-col gap-2">
<h1 className='mb-4 text-2xl font-bold'>Users</h1>
<div className='flex flex-col gap-2'>
<UserSubscriptionsTable users={users} />
</div>
</div>
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/app/drive/fs/[cid]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { ApiService } from "@/services/api";
import { FileCard } from "../../../../components/common/FileCard";
import { ApiService } from '@/services/api';
import { FileCard } from '../../../../components/common/FileCard';

export default async function Page({ params }: { params: { cid: string } }) {
const { cid } = params;

const objMetadata = await ApiService.fetchUploadedObjectMetadata(cid);

if (objMetadata.metadata.type === "file") {
throw new Error("File type not supported");
if (objMetadata.metadata.type === 'file') {
throw new Error('File type not supported');
}

const childrenMetadata = await Promise.all(
objMetadata.metadata.children.map((e) =>
ApiService.fetchUploadedObjectMetadata(e.cid)
)
ApiService.fetchUploadedObjectMetadata(e.cid),
),
);

return (
<div className="grid grid-cols-4 gap-4">
<div className='grid grid-cols-4 gap-4'>
{childrenMetadata.map(({ metadata }) => {
return <FileCard key={metadata.dataCid} metadata={metadata} />;
})}
Expand Down
40 changes: 20 additions & 20 deletions frontend/src/app/drive/global/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"use client";
'use client';

import { FileActionButtons, FileTable } from "@/components/common/FileTable";
import { FileDropZone } from "@/components/Files/FileDropZone";
import { NoUploadsPlaceholder } from "@/components/Files/NoUploadsPlaceholder";
import { ApiService } from "@/services/api";
import { useCallback, useEffect, useState } from "react";
import { UploadingObjects } from "../../../components/Files/UploadingObjects";
import { ObjectSummary } from "../../../models/UploadedObjectMetadata";
import { LoaderCircle } from "lucide-react";
import { PaginatedResult } from "../../../models/common";
import { SearchBar } from "../../../components/SearchBar";
import { FileActionButtons, FileTable } from '@/components/common/FileTable';
import { FileDropZone } from '@/components/Files/FileDropZone';
import { NoUploadsPlaceholder } from '@/components/Files/NoUploadsPlaceholder';
import { ApiService } from '@/services/api';
import { useCallback, useEffect, useState } from 'react';
import { UploadingObjects } from '../../../components/Files/UploadingObjects';
import { ObjectSummary } from '../../../models/UploadedObjectMetadata';
import { LoaderCircle } from 'lucide-react';
import { PaginatedResult } from '../../../models/common';
import { SearchBar } from '../../../components/SearchBar';

export default function Page() {
const [pageSize, setPageSize] = useState(5);
Expand All @@ -28,7 +28,7 @@ export default function Page() {
useEffect(() => {
const offset = currentPage * pageSize;
setRootObjectMetadata(null);
ApiService.getRootObjects("global", offset, pageSize).then(updateResult);
ApiService.getRootObjects('global', offset, pageSize).then(updateResult);
}, [currentPage, pageSize, updateResult]);

const updateCurrentPage = useCallback((newPage: number) => {
Expand All @@ -40,19 +40,19 @@ export default function Page() {
}, []);

return (
<div className="flex w-full">
<div className="w-full flex flex-col gap-4">
<div className="flex justify-between items-center gap-4">
<div className="flex-1">
<div className='flex w-full'>
<div className='flex w-full flex-col gap-4'>
<div className='flex items-center justify-between gap-4'>
<div className='flex-1'>
<FileDropZone />
</div>
<SearchBar scope="global" />
<SearchBar scope='global' />
</div>
<div className="">
<div className=''>
<UploadingObjects />
{rootObjectMetadata === null && (
<div className="flex min-h-[50vh] justify-center items-center">
<LoaderCircle className="w-10 h-10 animate-spin" />
<div className='flex min-h-[50vh] items-center justify-center'>
<LoaderCircle className='h-10 w-10 animate-spin' />
</div>
)}
{rootObjectMetadata && rootObjectMetadata.length > 0 && (
Expand Down
112 changes: 55 additions & 57 deletions frontend/src/app/drive/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
"use client";
'use client';

import { ScopeSwitch } from "@/components/common/ScopeSwitch";
import { SearchBar } from "@/components/SearchBar";
import {
HomeIcon,
SettingsIcon,
TrashIcon,
UserIcon,
UsersIcon,
Earth,
} from "lucide-react";
import { InternalLink } from "../../components/common/InternalLink";
import "../globals.css";
import { UserEnsurer } from "../../components/UserEnsurer";
import { RoleProtected } from "../../components/RoleProtected";
import { UserRole } from "../../models/User";
import { RemainingCreditTracker } from "../../components/RemainingCreditTracker";
import { useMemo } from "react";
import { useUserStore } from "../../states/user";
} from 'lucide-react';
import { InternalLink } from '../../components/common/InternalLink';
import '../globals.css';
import { UserEnsurer } from '../../components/UserEnsurer';
import { RoleProtected } from '../../components/RoleProtected';
import { UserRole } from '../../models/User';
import { RemainingCreditTracker } from '../../components/RemainingCreditTracker';
import { useMemo } from 'react';
import { useUserStore } from '../../states/user';

export default function AppLayout({
children,
Expand All @@ -29,12 +27,12 @@ export default function AppLayout({
const startDate = useMemo(() => {
const date = new Date();
return new Date(date.getFullYear(), date.getMonth(), 1).toLocaleDateString(
"en-US",
'en-US',
{
month: "short",
day: "numeric",
year: "numeric",
}
month: 'short',
day: 'numeric',
year: 'numeric',
},
);
}, []);

Expand All @@ -43,65 +41,65 @@ export default function AppLayout({
return new Date(
date.getFullYear(),
date.getMonth() + 1,
0
).toLocaleDateString("en-US", {
month: "short",
day: "numeric",
year: "numeric",
0,
).toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric',
});
}, []);

return (
<div className="min-h-screen bg-white">
<div className="flex h-screen flex-col bg-white rounded-lg">
<header className="flex flex-col w-full md:flex-row gap-4 md:gap-0 items-center justify-between mb-8 px-16 py-2 border-b-[0.2px] border-[#000000]">
<div className="flex items-center space-x-2">
<div className='min-h-screen bg-white'>
<div className='flex h-screen flex-col rounded-lg bg-white'>
<header className='mb-8 flex w-full flex-col items-center justify-between gap-4 border-b-[0.2px] border-[#000000] px-16 py-2 md:flex-row md:gap-0'>
<div className='flex items-center space-x-2'>
<img
src="/autonomys.png"
alt="Auto Drive"
className="w-[1rem] h-[1rem] rounded-full"
src='/autonomys.png'
alt='Auto Drive'
className='h-[1rem] w-[1rem] rounded-full'
/>
<span className="text-md font-medium">Auto Drive</span>
<span className='text-md font-medium'>Auto Drive</span>
</div>
</header>
<div className="flex flex-1 overflow-hidden px-10">
<div className='flex flex-1 overflow-hidden px-10'>
<UserEnsurer>
<aside className="w-12 md:w-48">
<InternalLink className="contents" href="/drive">
<button className="flex items-center space-x-2 text-black hover:text-blue-600 mb-2">
<HomeIcon className="w-5 h-5" />
<span className="hidden md:block">Files</span>
<aside className='w-12 md:w-48'>
<InternalLink className='contents' href='/drive'>
<button className='mb-2 flex items-center space-x-2 text-black hover:text-blue-600'>
<HomeIcon className='h-5 w-5' />
<span className='hidden md:block'>Files</span>
</button>
</InternalLink>
<InternalLink className="contents" href="/drive/global">
<button className="flex items-center space-x-2 text-black hover:text-blue-600 mb-2">
<Earth className="w-5 h-5" />
<span className="hidden md:block">Global Feed</span>
<InternalLink className='contents' href='/drive/global'>
<button className='mb-2 flex items-center space-x-2 text-black hover:text-blue-600'>
<Earth className='h-5 w-5' />
<span className='hidden md:block'>Global Feed</span>
</button>
</InternalLink>
<InternalLink className="contents" href="/drive/shared">
<button className="flex items-center space-x-2 text-black hover:text-blue-600 mb-2">
<UsersIcon className="w-5 h-5" />
<span className="hidden md:block">Shared with me</span>
<InternalLink className='contents' href='/drive/shared'>
<button className='mb-2 flex items-center space-x-2 text-black hover:text-blue-600'>
<UsersIcon className='h-5 w-5' />
<span className='hidden md:block'>Shared with me</span>
</button>
</InternalLink>
<InternalLink className="contents" href="/drive/trash">
<button className="flex items-center space-x-2 text-black hover:text-blue-600 mb-2">
<TrashIcon className="w-5 h-5" />
<span className="hidden md:block">Trash</span>
<InternalLink className='contents' href='/drive/trash'>
<button className='mb-2 flex items-center space-x-2 text-black hover:text-blue-600'>
<TrashIcon className='h-5 w-5' />
<span className='hidden md:block'>Trash</span>
</button>
</InternalLink>
<InternalLink className="contents" href="/drive/profile">
<button className="flex items-center space-x-2 text-black hover:text-blue-600 mb-2">
<UserIcon className="w-5 h-5" />
<span className="hidden md:block">Profile</span>
<InternalLink className='contents' href='/drive/profile'>
<button className='mb-2 flex items-center space-x-2 text-black hover:text-blue-600'>
<UserIcon className='h-5 w-5' />
<span className='hidden md:block'>Profile</span>
</button>
</InternalLink>
<RoleProtected roles={[UserRole.Admin]}>
<InternalLink className="contents" href="/drive/admin">
<button className="flex items-center space-x-2 text-black hover:text-blue-600 mb-2">
<SettingsIcon className="w-5 h-5" />
<span className="hidden md:block">Admin</span>
<InternalLink className='contents' href='/drive/admin'>
<button className='mb-2 flex items-center space-x-2 text-black hover:text-blue-600'>
<SettingsIcon className='h-5 w-5' />
<span className='hidden md:block'>Admin</span>
</button>
</InternalLink>
</RoleProtected>
Expand All @@ -116,7 +114,7 @@ export default function AppLayout({
/>
)}
</aside>
<main className="flex-1 overflow-auto p-6">{children}</main>
<main className='flex-1 overflow-auto p-6'>{children}</main>
</UserEnsurer>
</div>
</div>
Expand Down
Loading

0 comments on commit a417a6e

Please sign in to comment.