Skip to content

Commit faaf206

Browse files
committed
✨ Implement appartment edit approvals!
1 parent 571b826 commit faaf206

File tree

24 files changed

+774
-305
lines changed

24 files changed

+774
-305
lines changed

Diff for: .prettierrc

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
"singleQuote": true,
44
"trailingComma": "none",
55
"printWidth": 100,
6-
"plugins": [
7-
"prettier-plugin-svelte",
8-
"prettier-plugin-prisma",
9-
"prettier-plugin-organize-imports"
10-
],
6+
"plugins": ["prettier-plugin-svelte", "prettier-plugin-prisma"],
117
"pluginSearchDirs": ["."],
128
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
139
}

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"eslint-config-prettier": "^8.7.0",
3838
"eslint-plugin-svelte3": "^4.0.0",
3939
"prettier": "^2.8.4",
40-
"prettier-plugin-organize-imports": "^3.2.2",
4140
"prettier-plugin-prisma": "^4.10.0",
4241
"prettier-plugin-svelte": "^2.9.0",
4342
"prisma": "^4.11.0",
@@ -73,6 +72,7 @@
7372
"md5": "^2.3.0",
7473
"mime-types": "^2.1.35",
7574
"mjml": "^4.13.0",
75+
"node-htmldiff": "^0.9.4",
7676
"nodemailer": "^6.9.1",
7777
"sharp": "^0.31.3",
7878
"slugify": "^1.6.5",

Diff for: pnpm-lock.yaml

+7-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `locationId` on the `Appartment` table. All the data in the column will be lost.
5+
- The primary key for the `Photo` table will be changed. If it partially fails, the table could be left without primary key constraint.
6+
- A unique constraint covering the columns `[id]` on the table `Photo` will be added. If there are existing duplicate values, this will fail.
7+
- The required column `id` was added to the `Photo` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required.
8+
9+
*/
10+
-- DropForeignKey
11+
ALTER TABLE "Photo" DROP CONSTRAINT "Photo_appartmentId_fkey";
12+
13+
-- DropIndex
14+
DROP INDEX "Photo_filename_appartmentId_key";
15+
16+
-- AlterTable
17+
ALTER TABLE "Appartment" DROP COLUMN "locationId";
18+
19+
-- AlterTable
20+
ALTER TABLE "Photo" DROP CONSTRAINT "Photo_pkey",
21+
ADD COLUMN "appartmentEditId" TEXT,
22+
ADD COLUMN "hash" TEXT,
23+
ADD COLUMN "id" TEXT NOT NULL,
24+
ALTER COLUMN "appartmentId" DROP NOT NULL,
25+
ADD CONSTRAINT "Photo_pkey" PRIMARY KEY ("id");
26+
27+
-- CreateTable
28+
CREATE TABLE "AppartmentEdit" (
29+
"id" TEXT NOT NULL,
30+
"rent" INTEGER NOT NULL,
31+
"charges" INTEGER NOT NULL,
32+
"deposit" INTEGER NOT NULL,
33+
"surface" INTEGER NOT NULL,
34+
"kind" "AppartmentKind" NOT NULL,
35+
"roomsCount" INTEGER NOT NULL,
36+
"availableAt" TIMESTAMP(3) NOT NULL,
37+
"address" TEXT NOT NULL,
38+
"latitude" DOUBLE PRECISION,
39+
"longitude" DOUBLE PRECISION,
40+
"hasFurniture" BOOLEAN,
41+
"hasParking" BOOLEAN,
42+
"description" TEXT NOT NULL,
43+
"applied" BOOLEAN NOT NULL DEFAULT false,
44+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
45+
"appliedAt" TIMESTAMP(3),
46+
"appartmentId" TEXT NOT NULL,
47+
48+
CONSTRAINT "AppartmentEdit_pkey" PRIMARY KEY ("id")
49+
);
50+
51+
-- CreateIndex
52+
CREATE UNIQUE INDEX "AppartmentEdit_id_key" ON "AppartmentEdit"("id");
53+
54+
-- CreateIndex
55+
CREATE UNIQUE INDEX "Photo_id_key" ON "Photo"("id");
56+
57+
-- AddForeignKey
58+
ALTER TABLE "Photo" ADD CONSTRAINT "Photo_appartmentId_fkey" FOREIGN KEY ("appartmentId") REFERENCES "Appartment"("id") ON DELETE SET NULL ON UPDATE CASCADE;
59+
60+
-- AddForeignKey
61+
ALTER TABLE "Photo" ADD CONSTRAINT "Photo_appartmentEditId_fkey" FOREIGN KEY ("appartmentEditId") REFERENCES "AppartmentEdit"("id") ON DELETE SET NULL ON UPDATE CASCADE;
62+
63+
-- AddForeignKey
64+
ALTER TABLE "AppartmentEdit" ADD CONSTRAINT "AppartmentEdit_appartmentId_fkey" FOREIGN KEY ("appartmentId") REFERENCES "Appartment"("id") ON DELETE CASCADE ON UPDATE CASCADE;

Diff for: prisma/schema.prisma

+34-8
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ model Appartment {
7676
address String
7777
latitude Float?
7878
longitude Float?
79-
locationId String?
8079
hasFurniture Boolean?
8180
hasParking Boolean?
8281
description String
@@ -88,16 +87,20 @@ model Appartment {
8887
reports Report[]
8988
approved Boolean @default(false)
9089
archived Boolean @default(false)
90+
history AppartmentEdit[]
9191
}
9292

9393
model Photo {
94-
filename String @id
95-
contentType String
96-
appartment Appartment @relation(fields: [appartmentId], references: [id], onDelete: Cascade)
97-
appartmentId String
98-
position Int // Order of this photo in the list, 0-based.
99-
100-
@@unique([filename, appartmentId])
94+
id String @id @unique @default(cuid())
95+
filename String
96+
contentType String
97+
position Int // Order of this photo in the list, 0-based.
98+
hash String?
99+
100+
Appartment Appartment? @relation(fields: [appartmentId], references: [id])
101+
appartmentId String?
102+
AppartmentEdit AppartmentEdit? @relation(fields: [appartmentEditId], references: [id])
103+
appartmentEditId String?
101104
}
102105

103106
enum AppartmentKind {
@@ -110,6 +113,29 @@ enum AppartmentKind {
110113
colocation
111114
}
112115

116+
model AppartmentEdit {
117+
id String @id @unique @default(cuid())
118+
photos Photo[]
119+
rent Int
120+
charges Int
121+
deposit Int
122+
surface Int
123+
kind AppartmentKind
124+
roomsCount Int
125+
availableAt DateTime
126+
address String
127+
latitude Float?
128+
longitude Float?
129+
hasFurniture Boolean?
130+
hasParking Boolean?
131+
description String
132+
applied Boolean @default(false)
133+
createdAt DateTime @default(now())
134+
appliedAt DateTime?
135+
appartment Appartment @relation(fields: [appartmentId], references: [id], onDelete: Cascade)
136+
appartmentId String
137+
}
138+
113139
model Report {
114140
id String @id @unique @default(cuid())
115141
reason ReportReason

Diff for: public/global.css

+21-11
Original file line numberDiff line numberDiff line change
@@ -174,27 +174,37 @@ body {
174174
background-color: var(--bg);
175175
}
176176

177-
178177
[data-tippy-root] .tippy-box {
179-
background-color: var(--ice);
178+
background-color: var(--ice);
180179
}
181180

182-
[data-tippy-root] .tippy-box[data-placement^=top] .tippy-arrow::before {
183-
border-top-color: var(--ice);
181+
[data-tippy-root] .tippy-box[data-placement^='top'] .tippy-arrow::before {
182+
border-top-color: var(--ice);
184183
}
185184

186-
[data-tippy-root] .tippy-box[data-placement^=bottom] .tippy-arrow::before {
187-
border-bottom-color: var(--ice);
185+
[data-tippy-root] .tippy-box[data-placement^='bottom'] .tippy-arrow::before {
186+
border-bottom-color: var(--ice);
188187
}
189188

190-
[data-tippy-root] .tippy-box[data-placement^=left] .tippy-arrow::before {
191-
border-left-color: var(--ice);
189+
[data-tippy-root] .tippy-box[data-placement^='left'] .tippy-arrow::before {
190+
border-left-color: var(--ice);
192191
}
193192

194-
[data-tippy-root] .tippy-box[data-placement^=right] .tippy-arrow::before {
195-
border-right-color: var(--ice);
193+
[data-tippy-root] .tippy-box[data-placement^='right'] .tippy-arrow::before {
194+
border-right-color: var(--ice);
196195
}
197196

198197
[data-tippy-root] .tippy-content {
199-
color: var(--cobalt);
198+
color: var(--cobalt);
199+
}
200+
201+
ins {
202+
background-color: var(--moss);
203+
color: var(--cactus);
204+
text-decoration: none;
205+
}
206+
207+
del {
208+
background-color: var(--rose);
209+
color: var(--blood);
200210
}

Diff for: src/lib/AppartmentAdminItem.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import ButtonSecondary from './ButtonSecondary.svelte';
55
import Icon from './Icon.svelte';
66
import { addToast } from './toasts';
7-
import { appartmentPhotoURL } from './types';
7+
import { photoURL } from './photos';
88
const emit = createEventDispatcher();
99
1010
export let id: string;
@@ -32,7 +32,7 @@
3232
</script>
3333

3434
<li class:reported={reports.length > 0} class:approved>
35-
<img src={photos.length ? appartmentPhotoURL(photos[0]) : ''} class="photo" />
35+
<img src={photos.length ? photoURL(photos[0]) : ''} class="photo" />
3636
<div
3737
class="row-1"
3838
on:click={() => {

0 commit comments

Comments
 (0)