Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into issue-194-Create_events_carousel
  • Loading branch information
stamle committed May 6, 2024
2 parents d16da93 + 3f241ee commit ff2df9d
Show file tree
Hide file tree
Showing 54 changed files with 1,749 additions and 437 deletions.
5 changes: 4 additions & 1 deletion .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ DATABASE_URL_DIRECT="postgres://postgres:password@localhost:5432/db"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_BUCKET_NAME=repair-lab-images
AWS_REGION=ap-southeast-2
AWS_REGION=ap-southeast-2
AWS_SES_SOURCE_EMAIL="[email protected]"
AWS_SES_SWITCH=ON
AWS_SES_MOCK_ENDPOINT="http://localhost:8005"
4 changes: 4 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
const nextConfig = {
reactStrictMode: true,
images: {
domains: [
"repair-lab-images.s3.ap-southeast-2.amazonaws.com",
"via.placeholder.com"
],
remotePatterns: [
{
protocol: "https",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"prisma:migrate": "prisma migrate dev",
"prisma:reset": "prisma migrate reset --force && prisma db push",
"prisma:studio": "prisma studio",
"postinstall": "npm run prisma:generate"
"postinstall": "npm run prisma:generate",
"sesmock": "docker run -d -p 8005:8005 pensk/aws-ses-v2-local"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.449.0",
Expand Down
38 changes: 38 additions & 0 deletions prisma/migrations/20240210012417_issue_200/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Warnings:
- The primary key for the `RepairRequest` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The `id` column on the `RepairRequest` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- You are about to drop the column `organisationId` on the `Staff` table. All the data in the column will be lost.
- You are about to drop the `Brand` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `Organisation` table. If the table is not empty, all the data it contains will be lost.
- Changed the type of `repairRequestId` on the `RepairRequestImage` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
*/
-- DropForeignKey
ALTER TABLE "RepairRequestImage" DROP CONSTRAINT "RepairRequestImage_repairRequestId_fkey";

-- DropForeignKey
ALTER TABLE "Staff" DROP CONSTRAINT "Staff_organisationId_fkey";

-- AlterTable
ALTER TABLE "RepairRequest" DROP CONSTRAINT "RepairRequest_pkey",
DROP COLUMN "id",
ADD COLUMN "id" SERIAL NOT NULL,
ADD CONSTRAINT "RepairRequest_pkey" PRIMARY KEY ("id");

-- AlterTable
ALTER TABLE "RepairRequestImage" DROP COLUMN "repairRequestId",
ADD COLUMN "repairRequestId" INTEGER NOT NULL;

-- AlterTable
ALTER TABLE "Staff" DROP COLUMN "organisationId";

-- DropTable
DROP TABLE "Brand";

-- DropTable
DROP TABLE "Organisation";

-- AddForeignKey
ALTER TABLE "RepairRequestImage" ADD CONSTRAINT "RepairRequestImage_repairRequestId_fkey" FOREIGN KEY ("repairRequestId") REFERENCES "RepairRequest"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
24 changes: 6 additions & 18 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ enum UserRole {
}

model RepairRequest {
id String @id @default(uuid())
id Int @id @default(autoincrement())
createdBy String //User id
assignedTo String @default("") //volunteer id
assignedTo String @default("") //volugit adnteer id
event Event @relation(fields: [eventId], references: [id]) //relation field (many repair_requests to one event)
eventId String
Expand Down Expand Up @@ -89,16 +89,12 @@ model ItemType {
events Event[]
}

model Brand {
name String @id
}

model RepairRequestImage {
id String @id @default(uuid())
s3Key String //Potentially to be changed for privacy reasons
repairRequest RepairRequest @relation(fields: [repairRequestId], references: [id])
repairRequestId String
repairRequestId Int
}

model EventImage {
Expand All @@ -118,16 +114,8 @@ model EventRepairer {
@@unique([userId, eventId])
}

model Organisation {
id String @id @default(uuid())
name String @unique
Roles Staff[]
}

model Staff {
id String @id @default(uuid())
clerkId String
role UserRole
org Organisation @relation(fields: [organisationId], references: [id])
organisationId String
id String @id @default(uuid())
clerkId String
role UserRole
}
15 changes: 6 additions & 9 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/* eslint-disable no-console */
import { faker } from "@faker-js/faker";
import {
Brand,
Event,
EventRepairer,
ItemType,
Expand Down Expand Up @@ -46,14 +45,12 @@ async function createItemTypes(itemTypeNames: string[]) {
}

async function createBrands(brandNames: string[]) {
const brands: Brand[] = [];
const brands: string[] = [];

for (const name of brandNames) {
const brand = await prisma.brand.create({
data: { name }
});
const brand = name;

brands.push(brand);
brands.push(name);
console.log(brand);
}

Expand Down Expand Up @@ -97,7 +94,7 @@ async function createRandomRepairRequests(
count: number,
events: Event[],
itemTypes: ItemType[],
brands: Brand[]
brands: string[]
) {
const repairRequests: RepairRequest[] = [];

Expand All @@ -112,7 +109,7 @@ async function createRandomRepairRequests(
status: "PENDING",
description: faker.lorem.sentence(),
comment: faker.lorem.sentence(),
itemBrand: faker.helpers.arrayElement(brands).name,
itemBrand: faker.helpers.arrayElement(brands),
itemMaterial: faker.word.noun(),
requestDate: faker.date.past(),
updatedAt: faker.date.recent(),
Expand Down Expand Up @@ -169,7 +166,7 @@ async function main() {
faker.seed(fakerSeed);
await deleteAllData();
const itemTypes: ItemType[] = await createItemTypes(itemTypeNames);
const brands: Brand[] = await createBrands(brandNames);
const brands: string[] = await createBrands(brandNames);
const events: Event[] = await createRandomEvents(eventCount, itemTypes);
// const repairRequests: RepairRequest[] =
await createRandomRepairRequests(
Expand Down
106 changes: 0 additions & 106 deletions src/components/Cards/card.tsx

This file was deleted.

Loading

0 comments on commit ff2df9d

Please sign in to comment.