diff --git a/api/functions/graphql/nexus-typegen.ts b/api/functions/graphql/nexus-typegen.ts index c46012e..24001c7 100644 --- a/api/functions/graphql/nexus-typegen.ts +++ b/api/functions/graphql/nexus-typegen.ts @@ -28,6 +28,11 @@ declare global { } export interface NexusGenInputs { + ImageInput: { // input type + id?: string | null; // String + name?: string | null; // String + url: string; // String! + } MakerRoleInput: { // input type id: number; // Int! level: NexusGenEnums['RoleLevelEnum']; // RoleLevelEnum! @@ -35,11 +40,6 @@ export interface NexusGenInputs { MakerSkillInput: { // input type id: number; // Int! } - ImageInput: { // input type - id?: string | null; // String - name?: string | null; // String - url: string; // String! - } ProfileDetailsInput: { // input type avatar?: NexusGenInputs['ImageInput'] | null; // ImageInput bio?: string | null; // String @@ -265,6 +265,7 @@ export interface NexusGenObjects { payment_request: string; // String! } WalletKey: { // root type + createdAt: NexusGenScalars['Date']; // Date! is_current: boolean; // Boolean! key: string; // String! name: string; // String! @@ -540,6 +541,7 @@ export interface NexusGenFieldTypes { payment_request: string; // String! } WalletKey: { // field return type + createdAt: NexusGenScalars['Date']; // Date! is_current: boolean; // Boolean! key: string; // String! name: string; // String! @@ -833,6 +835,7 @@ export interface NexusGenFieldTypeNames { payment_request: 'String' } WalletKey: { // field return type name + createdAt: 'Date' is_current: 'Boolean' key: 'String' name: 'String' diff --git a/api/functions/graphql/schema.graphql b/api/functions/graphql/schema.graphql index 9d7ca5a..9fde969 100644 --- a/api/functions/graphql/schema.graphql +++ b/api/functions/graphql/schema.graphql @@ -389,6 +389,7 @@ type Vote { } type WalletKey { + createdAt: Date! is_current: Boolean! key: String! name: String! diff --git a/package-lock.json b/package-lock.json index e6bf34d..7be6add 100644 --- a/package-lock.json +++ b/package-lock.json @@ -82656,8 +82656,7 @@ "version": "0.4.2", "resolved": "https://registry.npmjs.org/@tailwindcss/line-clamp/-/line-clamp-0.4.2.tgz", "integrity": "sha512-HFzAQuqYCjyy/SX9sLGB1lroPzmcnWv1FHkIpmypte10hptf4oPUfucryMKovZh2u0uiS9U5Ty3GghWfEJGwVw==", - "dev": true, - "requires": {} + "dev": true }, "@tailwindcss/typography": { "version": "0.5.7", diff --git a/prisma/migrations/20220909120239_update_hosted_image_rel_table/migration.sql b/prisma/migrations/20220912140653_update_hosted_image_rel_table/migration.sql similarity index 51% rename from prisma/migrations/20220909120239_update_hosted_image_rel_table/migration.sql rename to prisma/migrations/20220912140653_update_hosted_image_rel_table/migration.sql index 9d4b64b..4e5eb9a 100644 --- a/prisma/migrations/20220909120239_update_hosted_image_rel_table/migration.sql +++ b/prisma/migrations/20220912140653_update_hosted_image_rel_table/migration.sql @@ -1,3 +1,15 @@ +/* + Warnings: + + - A unique constraint covering the columns `[image_id]` on the table `Award` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[cover_image_id]` on the table `Category` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[cover_image_id]` on the table `Hackathon` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[thumbnail_image_id]` on the table `Project` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[cover_image_id]` on the table `Project` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[cover_image_id]` on the table `Story` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[avatar_id]` on the table `User` will be added. If there are existing duplicate values, this will fail. + +*/ -- AlterTable ALTER TABLE "Award" ADD COLUMN "image_id" INTEGER; @@ -19,6 +31,27 @@ ADD COLUMN "cover_image_id" INTEGER; -- AlterTable ALTER TABLE "User" ADD COLUMN "avatar_id" INTEGER; +-- CreateIndex +CREATE UNIQUE INDEX "Award_image_id_key" ON "Award"("image_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "Category_cover_image_id_key" ON "Category"("cover_image_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "Hackathon_cover_image_id_key" ON "Hackathon"("cover_image_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "Project_thumbnail_image_id_key" ON "Project"("thumbnail_image_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "Project_cover_image_id_key" ON "Project"("cover_image_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "Story_cover_image_id_key" ON "Story"("cover_image_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "User_avatar_id_key" ON "User"("avatar_id"); + -- AddForeignKey ALTER TABLE "User" ADD CONSTRAINT "User_avatar_id_fkey" FOREIGN KEY ("avatar_id") REFERENCES "HostedImage"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 4967320..cad516d 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -44,8 +44,8 @@ model User { pubKey String? @unique name String? avatar String? - avatar_id Int? - avatar_rel HostedImage? @relation("UserAvatar", fields: [avatar_id], references: [id]) + avatar_id Int? @unique + avatar_rel HostedImage? @relation("User_Avatar", fields: [avatar_id], references: [id]) role String @default("user") email String? @@ -117,8 +117,8 @@ model Category { id Int @id @default(autoincrement()) title String cover_image String? - cover_image_id Int? - cover_image_rel HostedImage? @relation("CategoryCoverImage", fields: [cover_image_id], references: [id]) + cover_image_id Int? @unique + cover_image_rel HostedImage? @relation("Category_CoverImage", fields: [cover_image_id], references: [id]) icon String? project Project[] @@ -132,11 +132,11 @@ model Project { screenshots_ids Int[] website String thumbnail_image String? - thumbnail_image_id Int? - thumbnail_image_rel HostedImage? @relation("ProjectThumbnail", fields: [thumbnail_image_id], references: [id]) + thumbnail_image_id Int? @unique + thumbnail_image_rel HostedImage? @relation("Project_Thumbnail", fields: [thumbnail_image_id], references: [id]) cover_image String? - cover_image_id Int? - cover_image_rel HostedImage? @relation("ProjectCoverImage", fields: [cover_image_id], references: [id]) + cover_image_id Int? @unique + cover_image_rel HostedImage? @relation("Project_CoverImage", fields: [cover_image_id], references: [id]) lightning_address String? lnurl_callback_url String? @@ -167,8 +167,8 @@ model Award { id Int @id @default(autoincrement()) title String image String - image_id Int? - image_rel HostedImage? @relation("AwardImage", fields: [image_id], references: [id]) + image_id Int? @unique + image_rel HostedImage? @relation("Award_Image", fields: [image_id], references: [id]) url String project Project @relation(fields: [project_id], references: [id]) @@ -188,8 +188,8 @@ model Story { body_image_ids Int[] excerpt String cover_image String? - cover_image_id Int? - cover_image_rel HostedImage? @relation("StoryCoverImage", fields: [cover_image_id], references: [id]) + cover_image_id Int? @unique + cover_image_rel HostedImage? @relation("Story_CoverImage", fields: [cover_image_id], references: [id]) votes_count Int @default(0) is_published Boolean @default(true) @@ -249,8 +249,8 @@ model Hackathon { start_date DateTime @db.Date end_date DateTime @db.Date cover_image String - cover_image_id Int? - cover_image_rel HostedImage? @relation("HackathonCoverImage", fields: [cover_image_id], references: [id]) + cover_image_id Int? @unique + cover_image_rel HostedImage? @relation("Hackathon_CoverImage", fields: [cover_image_id], references: [id]) description String location String website String @@ -296,13 +296,13 @@ model HostedImage { createdAt DateTime @default(now()) is_used Boolean @default(false) - ProjectThumbnail Project[] @relation("ProjectThumbnail") - ProjectCoverImage Project[] @relation("ProjectCoverImage") - CategoryCoverImage Category[] @relation("CategoryCoverImage") - AwardImage Award[] @relation("AwardImage") - HackathonCoverImage Hackathon[] @relation("HackathonCoverImage") - StoryCoverImage Story[] @relation("StoryCoverImage") - User User[] @relation("UserAvatar") + ProjectThumbnail Project? @relation("Project_Thumbnail") + ProjectCoverImage Project? @relation("Project_CoverImage") + CategoryCoverImage Category? @relation("Category_CoverImage") + AwardImage Award? @relation("Award_Image") + HackathonCoverImage Hackathon? @relation("Hackathon_CoverImage") + StoryCoverImage Story? @relation("Story_CoverImage") + User User? @relation("User_Avatar") } // ----------------- diff --git a/src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/BasicProfileInfoTab.tsx b/src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/BasicProfileInfoTab.tsx index b6b652d..c224aac 100644 --- a/src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/BasicProfileInfoTab.tsx +++ b/src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/BasicProfileInfoTab.tsx @@ -109,7 +109,7 @@ export default function BasicProfileInfoTab() { onCompleted: ({ updateProfileDetails: data }) => { if (data) { dispatch(setUser(data)) - reset(data); + reset({ ...data, avatar: { url: data.avatar } }); apolloClient.writeFragment({ id: `User:${data?.id}`, data,