mirror of
https://github.com/ThisIsBenny/wishlist-app.git
synced 2025-04-19 15:27:41 +00:00
Fix issue with deleting of a wishlist
Signed-off-by: Benny Samir Hierl <bennysamir@posteo.de>
This commit is contained in:
parent
b026132c32
commit
71ab2c14fd
5 changed files with 30 additions and 7 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "wishlist",
|
"name": "wishlist",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@prisma/client": "^3.9.2",
|
"@prisma/client": "^3.9.2",
|
||||||
"@tailwindcss/line-clamp": "^0.3.1",
|
"@tailwindcss/line-clamp": "^0.3.1",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently --kill-others \"npm run dev:frontend\" \"npm run dev:backend\"",
|
"dev": "concurrently --kill-others \"npm run dev:frontend\" \"npm run dev:backend\"",
|
||||||
"demo": "npm run build && prisma migrate deploy && prisma migrate reset -f && node dist/api/server.js",
|
"demo": "npm run build && prisma migrate deploy && prisma migrate reset -f && node dist/api/server.js",
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
-- RedefineTables
|
||||||
|
PRAGMA foreign_keys=OFF;
|
||||||
|
CREATE TABLE "new_Item" (
|
||||||
|
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"title" TEXT NOT NULL,
|
||||||
|
"url" TEXT NOT NULL DEFAULT '',
|
||||||
|
"imageSrc" TEXT NOT NULL DEFAULT '',
|
||||||
|
"description" TEXT NOT NULL,
|
||||||
|
"bought" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"wishlistId" TEXT NOT NULL,
|
||||||
|
CONSTRAINT "Item_wishlistId_fkey" FOREIGN KEY ("wishlistId") REFERENCES "Wishlist" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_Item" ("bought", "description", "id", "imageSrc", "title", "url", "wishlistId") SELECT "bought", "description", "id", "imageSrc", "title", "url", "wishlistId" FROM "Item";
|
||||||
|
DROP TABLE "Item";
|
||||||
|
ALTER TABLE "new_Item" RENAME TO "Item";
|
||||||
|
PRAGMA foreign_key_check;
|
||||||
|
PRAGMA foreign_keys=ON;
|
|
@ -27,6 +27,6 @@ model Item {
|
||||||
imageSrc String @default("")
|
imageSrc String @default("")
|
||||||
description String
|
description String
|
||||||
bought Boolean @default(false)
|
bought Boolean @default(false)
|
||||||
wishlist Wishlist @relation(fields: [wishlistId], references: [id])
|
wishlist Wishlist @relation(fields: [wishlistId], references: [id], onDelete: Cascade)
|
||||||
wishlistId String
|
wishlistId String
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,9 @@ const updateWishlist = async (updatedData: Wishlist): Promise<void> => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteWishlist = async (): Promise<void> => {
|
const deleteWishlist = async (): Promise<void> => {
|
||||||
const { error } = await useFetch(`/wishlist/${state!.value!.id}`).delete()
|
const { error } = await useFetch(`/wishlist/${state!.value!.id}`)
|
||||||
|
.delete()
|
||||||
|
.json()
|
||||||
if (error.value) {
|
if (error.value) {
|
||||||
throw error.value
|
throw error.value
|
||||||
}
|
}
|
||||||
|
@ -92,7 +94,9 @@ const updateItem = async (
|
||||||
const itemBought = async (item: WishlistItem): Promise<void> => {
|
const itemBought = async (item: WishlistItem): Promise<void> => {
|
||||||
const { error } = await useFetch(
|
const { error } = await useFetch(
|
||||||
`/wishlist/${item.wishlistId}/item/${item.id}/bought`
|
`/wishlist/${item.wishlistId}/item/${item.id}/bought`
|
||||||
).post()
|
)
|
||||||
|
.post()
|
||||||
|
.json()
|
||||||
if (error.value) {
|
if (error.value) {
|
||||||
throw error.value
|
throw error.value
|
||||||
}
|
}
|
||||||
|
@ -102,7 +106,9 @@ const itemBought = async (item: WishlistItem): Promise<void> => {
|
||||||
const itemDelete = async (item: WishlistItem): Promise<void> => {
|
const itemDelete = async (item: WishlistItem): Promise<void> => {
|
||||||
const { error } = await useFetch(
|
const { error } = await useFetch(
|
||||||
`/wishlist/${item.wishlistId}/item/${item.id}`
|
`/wishlist/${item.wishlistId}/item/${item.id}`
|
||||||
).delete()
|
)
|
||||||
|
.delete()
|
||||||
|
.json()
|
||||||
if (error.value) {
|
if (error.value) {
|
||||||
throw error.value
|
throw error.value
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue