Skip to content

Commit

Permalink
feat: added description atribute in architect schema. Added descripti…
Browse files Browse the repository at this point in the history
…on view in forms, and profile view. Deleted unused models (Scale and Experience), handle by uynique id's
  • Loading branch information
dlv237 committed Jul 9, 2024
1 parent 1892898 commit cb4b55c
Show file tree
Hide file tree
Showing 17 changed files with 217 additions and 105 deletions.
64 changes: 60 additions & 4 deletions my-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion my-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@fortawesome/free-brands-svg-icons": "^6.5.2",
"@fortawesome/free-solid-svg-icons": "^6.5.2",
"@fortawesome/react-fontawesome": "^0.2.2",
"@prisma/client": "^5.14.0",
"@prisma/client": "^5.16.1",
"@radix-ui/colors": "^3.0.0",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
Expand All @@ -29,6 +29,7 @@
"chokidar": "^3.6.0",
"dotenv": "^16.4.5",
"next": "14.2.3",
"prisma": "^5.16.1",
"react": "^18",
"react-dom": "^18",
"react-router-dom": "^6.23.1",
Expand Down

This file was deleted.

This file was deleted.

23 changes: 0 additions & 23 deletions my-app/prisma/migrations/20240606013557_new_model/migration.sql

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ CREATE TABLE "Architect" (
"city" TEXT NOT NULL,
"address" TEXT,
"website" TEXT,
"social_media" TEXT,
"description" TEXT,
"experience_id" INTEGER NOT NULL,

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

-- CreateTable
CREATE TABLE "ArchitectNetworks" (
"id" SERIAL NOT NULL,
"architect_id" INTEGER NOT NULL,
"social_type" TEXT NOT NULL,
"social_media" TEXT NOT NULL,

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

-- CreateTable
CREATE TABLE "Experience" (
"id" SERIAL NOT NULL,
Expand Down Expand Up @@ -57,11 +67,20 @@ CREATE UNIQUE INDEX "Architect_phone_key" ON "Architect"("phone");
CREATE UNIQUE INDEX "Architect_name_key" ON "Architect"("name");

-- CreateIndex
CREATE UNIQUE INDEX "Architect_experience_id_key" ON "Architect"("experience_id");
CREATE UNIQUE INDEX "Experience_detail_key" ON "Experience"("detail");

-- CreateIndex
CREATE UNIQUE INDEX "Scale_scale_type_key" ON "Scale"("scale_type");

-- CreateIndex
CREATE UNIQUE INDEX "Scale_detail_key" ON "Scale"("detail");

-- AddForeignKey
ALTER TABLE "Architect" ADD CONSTRAINT "Architect_experience_id_fkey" FOREIGN KEY ("experience_id") REFERENCES "Experience"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ArchitectNetworks" ADD CONSTRAINT "ArchitectNetworks_architect_id_fkey" FOREIGN KEY ("architect_id") REFERENCES "Architect"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ArchitectScales" ADD CONSTRAINT "ArchitectScales_architect_id_fkey" FOREIGN KEY ("architect_id") REFERENCES "Architect"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:
- You are about to drop the `Experience` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "Architect" DROP CONSTRAINT "Architect_experience_id_fkey";

-- DropTable
DROP TABLE "Experience";
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:
- You are about to drop the `Scale` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "ArchitectScales" DROP CONSTRAINT "ArchitectScales_scale_id_fkey";

-- DropTable
DROP TABLE "Scale";
60 changes: 20 additions & 40 deletions my-app/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
provider = "prisma-client-js"
}
Expand All @@ -14,55 +8,41 @@ datasource db {
}

model Architect {
id Int @id @default(autoincrement())
email String @unique
phone String @unique
name String @unique
id Int @id @default(autoincrement())
email String @unique
phone String @unique
name String @unique
city String
address String?
description String?
address String?
website String?
experience_id Int
experience Experience @relation(fields: [experience_id], references: [id])
networks ArchitectNetworks[]
scales ArchitectScales[]
images Image[]
networks ArchitectNetworks[]
}

model ArchitectNetworks {
id Int @id @default(autoincrement())
architect_id Int
social_type String
social_media String
architect Architect @relation(fields: [architect_id], references: [id])
id Int @id @default(autoincrement())
architect_id Int
social_type String
social_media String
architect Architect @relation(fields: [architect_id], references: [id])
}

model Experience {
id Int @id @default(autoincrement())
detail String @unique
architect Architect[]
}

model Scale {
id Int @id @default(autoincrement())
scale_type String @unique
detail String @unique
architectScales ArchitectScales[]
}

model ArchitectScales {
architect_id Int
scale_id Int
architect Architect @relation(fields: [architect_id], references: [id])
scale Scale @relation(fields: [scale_id], references: [id])
architect_id Int
scale_id Int
architect Architect @relation(fields: [architect_id], references: [id])
@@id([architect_id, scale_id])
}

model Image {
id Int @id @default(autoincrement())
url String
architect_id Int
architect Architect @relation(fields: [architect_id], references: [id])
}
id Int @id @default(autoincrement())
url String
architect_id Int
architect Architect @relation(fields: [architect_id], references: [id])
}
8 changes: 8 additions & 0 deletions my-app/src/app/profile.css
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,11 @@
border-width: 1px;
border-color: grey;
}

.descriptionContainer{
max-width: 40vh;
max-height: 80%;
text-align: center;
font-style: italic;
font-size: 0.85rem;
}
24 changes: 23 additions & 1 deletion my-app/src/app/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,26 @@ height: 13vh;
height: 13vh;
object-fit: cover;
border-radius: 5px;
}
}



.descriptionInput{
height: 30rem;
width: 15rem;
text-align: center;
}

textarea:focus {
outline: none;
border: none
}

.descriptionInputEdit{
margin-left: auto;
width: clamp(200px, 30vw, 300px);
max-height: 7rem;
border-bottom: 1px solid gray;
text-align: center;
font-size: 0.8rem;
}
23 changes: 23 additions & 0 deletions my-app/src/components/form/description_form.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { useState } from "react";

export default function DescriptionForm({
description,
setDescription,}:
{ onNext: () => void, onBack: () => void, description: string, setDescription: (description: string) => void}) {

return(
<div className="formContainer">
<h1 style={{fontSize: "2.5vh", fontWeight: "bold"}}>Ingresa una breve descripción</h1>
<div style={{ display: "flex", justifyContent: "center", marginTop: "8vh"}}>
<textarea
value={description}
onChange={e => setDescription(e.target.value)}
className="descriptionInput"
placeholder="tu descripción aquí..."
maxLength={200}
style={{height: "30rem", width: "15rem", textAlign: "center"}}
/>
</div>
</div>
)
}
4 changes: 2 additions & 2 deletions my-app/src/pages/api/architect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
console.log('POST request received');
console.log('Request body:', req.body);

const { email, phone, name, city, address, website, experience_id} = req.body;
const { email, phone, name, city, address, website, experience_id, description} = req.body;
try {
const architect = await prisma.architect.create({data: {email, phone, name, city, address, website, experience_id}})
const architect = await prisma.architect.create({data: {email, phone, name, city, description, address, website, experience_id}})
res.status(201).json({ architect });
}
catch (error) {
Expand Down
Loading

0 comments on commit cb4b55c

Please sign in to comment.