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

Develop #54

Merged
merged 11 commits into from
Oct 29, 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
3 changes: 2 additions & 1 deletion contract/tests/cip68.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ describe("Mint, Burn, Update, Remove Assets (NFT/TOKEN) CIP68", function () {
image: "ipfs://QmRzicpReutwCkM6aotuKjErFCUD213DpwPq6ByuzMJaua",
mediaType: "image/jpg",
},
txHash: "d3c92245ad396c3c05e2530be2e0d3a3adbf1871113fcb18a197c23e4fdfcd1a",
txHash:
"d3c92245ad396c3c05e2530be2e0d3a3adbf1871113fcb18a197c23e4fdfcd1a",
});
const signedTx = await wallet.signTx(unsignedTx, true);
const txHash = await wallet.submitTx(signedTx);
Expand Down
7 changes: 3 additions & 4 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ const nextConfig = {
images: {
remotePatterns: [
{
protocol: "http",
hostname: "18.143.169.117",
port: "8080",
protocol: "https",
hostname: "ipfs.io",
pathname: "/ipfs/**",
},
],
},

// output: "standalone",
reactStrictMode: true,
webpack: function (config, _) {
webpack: function (config) {
config.experiments = {
asyncWebAssembly: true,
layers: true,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"lucide-react": "^0.447.0",
"next": "^15.0.1",
"next-auth": "^5.0.0-beta.25",
"node-cache": "^5.1.2",
"react": "^19.0.0-rc-fb9a90fa48-20240614",
"react-countup": "^6.5.3",
"react-day-picker": "8.10.1",
Expand Down
89 changes: 0 additions & 89 deletions prisma/migrations/20241011081055_/migration.sql

This file was deleted.

62 changes: 62 additions & 0 deletions prisma/migrations/20241029152435_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
-- CreateTable
CREATE TABLE "user" (
"id" TEXT NOT NULL,
"address" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,

CONSTRAINT "user_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "collection" (
"id" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
"user_id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"thumbnail" TEXT,
"description" TEXT,

CONSTRAINT "collection_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "metadata" (
"id" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
"collection_id" TEXT NOT NULL,
"content" JSONB NOT NULL,
"nft_reference" TEXT[],

CONSTRAINT "metadata_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "media" (
"id" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
"user_id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"type" TEXT NOT NULL,
"url" TEXT NOT NULL,

CONSTRAINT "media_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "user_address_key" ON "user"("address");

-- CreateIndex
CREATE UNIQUE INDEX "media_url_key" ON "media"("url");

-- AddForeignKey
ALTER TABLE "collection" ADD CONSTRAINT "collection_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "metadata" ADD CONSTRAINT "metadata_collection_id_fkey" FOREIGN KEY ("collection_id") REFERENCES "collection"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "media" ADD CONSTRAINT "media_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
82 changes: 32 additions & 50 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -14,69 +14,51 @@ datasource db {
}

model User {
id String @id @default(cuid())
address String @unique @map(name: "address")
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")

@@map(name: "users")
Media Media[]
id String @id @default(cuid())
address String @unique @map(name: "address")
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
Media Media[]
Collection Collection[]
}

model WalletNonce {
id String @id @default(cuid())
address String @unique @map(name: "address")
nonce String @unique @default(uuid())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")

@@map(name: "wallet_nonces")
}

model Wallet {
id String @id @default(cuid())
address String @unique @map(name: "address")
balance String @map(name: "balance")
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")

@@map(name: "wallets")
@@map(name: "user")
}

model Collection {
id String @id @default(cuid())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
userId String @map(name: "user_id")
user User @relation(fields: [userId], references: [id])
thumbnail String @map(name: "thumbnail")
title String @map(name: "title")
description String @map(name: "description")
id String @id @default(cuid())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
userId String @map(name: "user_id")
name String @map(name: "name")
thumbnail String? @map(name: "thumbnail")
description String? @map(name: "description")
user User @relation(fields: [userId], references: [id])
Metadata Metadata[]

@@map(name: "collections")
Metadata Metadata[]
@@map(name: "collection")
}

model Metadata {
id String @id @default(cuid())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
content Json @map(name: "content")
collectionId String @map(name: "collection_id")
id String @id @default(cuid())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
collectionId String @map(name: "collection_id")
content Json @map(name: "content")
nftReference String[] @map(name: "nft_reference")
collection Collection @relation(fields: [collectionId], references: [id])

@@map(name: "metadata")
}

model Media {
id String @id @default(cuid())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
userId String @map(name: "user_id")
user User @relation(fields: [userId], references: [id])
name String @map(name: "name")
type String @map(name: "type")
url String @map(name: "url")
id String @id @default(cuid())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @updatedAt @map(name: "updated_at")
userId String @map(name: "user_id")
name String
type String
url String @unique
user User @relation(fields: [userId], references: [id])

@@map(name: "media")
}

1 change: 1 addition & 0 deletions public/images/common/placeholder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/common/text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion src/app/(app)/dashboard/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"use client";

import Loading from "@/app/loading";
import DesktopDashboardLayout from "@/components/layouts/desktop-dashboard";
import MobileDashboardLayout from "@/components/layouts/mobile-dashboard";
import useWindowSize from "@/hooks/use-window-size";
import { useSession } from "next-auth/react";
import { PropsWithChildren, useMemo } from "react";

import { redirect } from "next/navigation";
export default function DashboardLayout({
children,
}: Readonly<PropsWithChildren>) {
Expand All @@ -13,6 +15,15 @@ export default function DashboardLayout({
const Layout = useMemo(() => {
return isMobile ? MobileDashboardLayout : DesktopDashboardLayout;
}, [isMobile]);
const session = useSession();

if (session.status === "loading") {
return <Loading />;
}

if (session.status === "unauthenticated") {
redirect("/login");
}

return <Layout>{children}</Layout>;
}
10 changes: 6 additions & 4 deletions src/app/(app)/dashboard/utilities/_components/file-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ import {
ChevronRight,
ExternalLink,
} from "lucide-react";
import { Media } from "@prisma/client";
import { AspectRatio } from "@/components/ui/aspect-ratio";
import Image from "next/image";
import { ipfsConfig } from "@/constants";
import { IPFS_GATEWAY } from "@/constants";
import { useUploadContext } from "../storage/_context";

export default function TableData({ listMedia }: { listMedia: Media[] }) {
export default function TableData() {
const { loading, listMedia } = useUploadContext();
if (loading) return <div>Loading...</div>;
return (
<div className="w-full space-y-4 rounded-lg p-4">
<div className="overflow-x-auto">
Expand Down Expand Up @@ -50,7 +52,7 @@ export default function TableData({ listMedia }: { listMedia: Media[] }) {
<AspectRatio ratio={10 / 10} className="bg-muted">
<Image
src={
ipfsConfig.gateway + file.url.replace("ipfs://", "")
IPFS_GATEWAY + file.url.replace("ipfs://", "ipfs/")
}
alt={file.name}
fill
Expand Down
7 changes: 4 additions & 3 deletions src/app/(app)/dashboard/utilities/_components/list-file.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Button } from "@/components/ui/button";
import { ChevronLeft, ChevronRight, ExternalLink } from "lucide-react";
import FileCard from "./file-card";
import { Media } from "@prisma/client";
import FileCard from "../storage/_components/file-card";
import { useUploadContext } from "../storage/_context";

export default function ListFileCard({ listMedia }: { listMedia: Media[] }) {
export default function ListFileCard() {
const { listMedia } = useUploadContext();
return (
<div className="w-full space-y-4 rounded-lg p-4">
<div className="overflow-x-auto">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Icons } from "@/components/common/icons";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { DatePickerWithRange } from "./date-range-picker";
import { DatePickerWithRange } from "../../../../../components/common/date-range-picker";

export const SearchBar = () => {
return (
Expand Down
Loading
Loading