-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
237 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export default function Home() { | ||
return ( | ||
<main> | ||
<h1>main content</h1> | ||
<h1>hello</h1> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { FormField } from '@/components/formField'; | ||
import { Button } from '@/components/ui/button'; | ||
|
||
export default function NewSpace() { | ||
return ( | ||
<div> | ||
<h1>ADD NEW SPACE</h1> | ||
|
||
<form> | ||
<FormField type="text" label="Name" name="name" /> | ||
<FormField type="number" label="Price" name="price" /> | ||
<FormField | ||
type="date" | ||
label="Date" | ||
name="date" | ||
defaultValue={new Date().toLocaleDateString('en-CA')} | ||
/> | ||
<Button className="w-full mt-3">Submit</Button> | ||
</form> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function NewSpace() { | ||
return ( | ||
<div> | ||
<h1>EDIT</h1> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { redirect } from 'next/navigation'; | ||
|
||
import { auth } from '@/lib/auth'; | ||
import { prisma } from '@/lib/prisma'; | ||
|
||
export default async function Groups() { | ||
const session = await auth(); | ||
|
||
const email = session?.user?.email; | ||
|
||
if (!email) { | ||
redirect('/'); | ||
} | ||
|
||
const user = await prisma.user.findUnique({ | ||
where: { | ||
}, | ||
include: { | ||
spaces: true | ||
} | ||
}); | ||
|
||
if (!user) { | ||
// TODO handle it - either redirect it to sign it page or show not sign in view | ||
throw new Error('handle it'); | ||
} | ||
|
||
return ( | ||
<main> | ||
<header> | ||
<h2>Your Space Management</h2> | ||
</header> | ||
{user.spaces.length ? ( | ||
<div>your spaces</div> | ||
) : ( | ||
<div>no space was found</div> | ||
)} | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use client'; | ||
|
||
import { Anchor } from './Anchor'; | ||
import { Button } from './ui/button'; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuTrigger, | ||
DropdownMenuContent, | ||
DropdownMenuGroup, | ||
DropdownMenuItem | ||
} from './ui/dropdown-menu'; | ||
|
||
export function SpacesNav() { | ||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="outline" size="default"> | ||
Spaces | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuGroup> | ||
<DropdownMenuItem> | ||
<Anchor href="/spaces/add">Add New Space</Anchor> | ||
</DropdownMenuItem> | ||
</DropdownMenuGroup> | ||
|
||
<DropdownMenuGroup> | ||
<DropdownMenuItem> | ||
<Anchor href="/spaces">Go To Main Spaces Page</Anchor> | ||
</DropdownMenuItem> | ||
</DropdownMenuGroup> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
|
||
// export const prisma = new PrismaClient({ | ||
// log: ['query'] | ||
// }); | ||
|
||
export const prisma = new PrismaClient(); | ||
export const prisma = new PrismaClient({ | ||
log: ['query'] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the `UserGroup` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `_UserToUserGroup` table. If the table is not empty, all the data it contains will be lost. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "_UserToUserGroup" DROP CONSTRAINT "_UserToUserGroup_A_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "_UserToUserGroup" DROP CONSTRAINT "_UserToUserGroup_B_fkey"; | ||
|
||
-- DropTable | ||
DROP TABLE "UserGroup"; | ||
|
||
-- DropTable | ||
DROP TABLE "_UserToUserGroup"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "Spaces" ( | ||
"id" SERIAL NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"userId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Spaces_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "_SpacesToUser" ( | ||
"A" INTEGER NOT NULL, | ||
"B" TEXT NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "_SpacesToUser_AB_unique" ON "_SpacesToUser"("A", "B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "_SpacesToUser_B_index" ON "_SpacesToUser"("B"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Spaces" ADD CONSTRAINT "Spaces_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_SpacesToUser" ADD CONSTRAINT "_SpacesToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Spaces"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_SpacesToUser" ADD CONSTRAINT "_SpacesToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
16 changes: 16 additions & 0 deletions
16
prisma/migrations/20231126110936_change_field_to_admin_id/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `userId` on the `Spaces` table. All the data in the column will be lost. | ||
- Added the required column `adminId` to the `Spaces` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "Spaces" DROP CONSTRAINT "Spaces_userId_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Spaces" DROP COLUMN "userId", | ||
ADD COLUMN "adminId" TEXT NOT NULL; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Spaces" ADD CONSTRAINT "Spaces_adminId_fkey" FOREIGN KEY ("adminId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
11 changes: 11 additions & 0 deletions
11
prisma/migrations/20231126111343_remove_admin/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `adminId` on the `Spaces` table. All the data in the column will be lost. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "Spaces" DROP CONSTRAINT "Spaces_adminId_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Spaces" DROP COLUMN "adminId"; |
44 changes: 44 additions & 0 deletions
44
prisma/migrations/20231126112121_spaces_typo/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the `Spaces` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `_SpacesToUser` table. If the table is not empty, all the data it contains will be lost. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "_SpacesToUser" DROP CONSTRAINT "_SpacesToUser_A_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "_SpacesToUser" DROP CONSTRAINT "_SpacesToUser_B_fkey"; | ||
|
||
-- DropTable | ||
DROP TABLE "Spaces"; | ||
|
||
-- DropTable | ||
DROP TABLE "_SpacesToUser"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "Space" ( | ||
"id" SERIAL NOT NULL, | ||
"name" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Space_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "_SpaceToUser" ( | ||
"A" INTEGER NOT NULL, | ||
"B" TEXT NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "_SpaceToUser_AB_unique" ON "_SpaceToUser"("A", "B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "_SpaceToUser_B_index" ON "_SpaceToUser"("B"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_SpaceToUser" ADD CONSTRAINT "_SpaceToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Space"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_SpaceToUser" ADD CONSTRAINT "_SpaceToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters