Skip to content

Commit

Permalink
Merge pull request #38 from code4livinglab/feat/terms-and-policy
Browse files Browse the repository at this point in the history
Feat/terms and policy
  • Loading branch information
yjn279 authored Dec 13, 2024
2 parents 3a4cf6d + 953a87d commit 19fa6d6
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 3 deletions.
31 changes: 31 additions & 0 deletions app/projects/[projectId]/_component/ProjectDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import {
Link as MUILink,
Paper,
Stack,
Typography,
} from '@mui/material'
// import { File } from '@/app/_types/file'
import { Project } from '@/app/_types/project'
import { DownloadButton } from './DownloadButton'
import { MarkdownViewer } from './MarkdownViewer'
import { CloseButton } from '../../_components/CloseButton'
import Link from 'next/link'

export const ProjectDetails = ({ project }: { project: Project }) => {
return (
Expand All @@ -30,6 +33,34 @@ export const ProjectDetails = ({ project }: { project: Project }) => {
))}
</>
)} */}
<Typography
variant="caption"
sx={{ width: '100%' }}
>
<MUILink
component={Link}
href="https://creativecommons.org/licenses/by-sa/4.0/deed.ja"
sx={{ color: 'info.main' }}
>
&nbsp;CC BY-SA 4.0&nbsp;
</MUILink>
のライセンスに基づいて公開
<img
className="inline-block h-4 mx-1"
src="https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1"
alt=""
/>
<img
className="inline-block h-4 mx-1"
src="https://mirrors.creativecommons.org/presskit/icons/by.svg?ref=chooser-v1"
alt=""
/>
<img
className="inline-block h-4 mx-1"
src="https://mirrors.creativecommons.org/presskit/icons/sa.svg?ref=chooser-v1"
alt=""
/>
</Typography>
<DownloadButton projectId={project.id} />
<CloseButton />
</Stack>
Expand Down
25 changes: 25 additions & 0 deletions app/users/sign-up/SignUpForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Link from "next/link";
import {
Alert,
Box,
Checkbox,
FormControlLabel,
Link as MUILink,
Paper,
TextField,
Expand Down Expand Up @@ -71,6 +73,29 @@ const SignUpForm = () => {
fullWidth
variant="outlined"
/>
<FormControlLabel
control={<Checkbox name="agreement" />}
label={
<>
<MUILink
component={Link}
href="https://ludicrous-flyingfish-cc4.notion.site/terms-of-use"
sx={{ color: 'info.main' }}
>
利用規約
</MUILink>
<MUILink
component={Link}
href="http://ludicrous-flyingfish-cc4.notion.site/privacy-policy"
sx={{ color: 'info.main' }}
>
プライバシーポリシー
</MUILink>
に同意する。
</>
}
/>
<SignUpFormButton />
</Box>
<Typography variant="body2" className="text-center mt-4">
Expand Down
3 changes: 2 additions & 1 deletion app/users/sign-up/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export async function signUpAction(prevState: any, formData: FormData) {
const email = formData.get("email")?.toString() ?? "";
const password = formData.get("password")?.toString() ?? "";
const password2 = formData.get("password2")?.toString() ?? "";
const agreement = formData.get("agreement")?.toString() ?? "";

// バリデーション
if (!id || !username || !email || !password || !password2) {
if (!id || !username || !email || !password || !password2 || !agreement) {
return { success: false, error: "全ての項目を入力してください。" };
}

Expand Down
25 changes: 25 additions & 0 deletions prisma/migrations/20241212180202_v0_2_0_notification/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- CreateTable
CREATE TABLE "Notification" (
"id" TEXT NOT NULL,
"message" TEXT NOT NULL,
"url" TEXT,
"created" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "NotificationUser" (
"userId" TEXT NOT NULL,
"notificationId" TEXT NOT NULL,
"isRead" BOOLEAN NOT NULL DEFAULT false,

CONSTRAINT "NotificationUser_pkey" PRIMARY KEY ("notificationId","userId")
);

-- AddForeignKey
ALTER TABLE "NotificationUser" ADD CONSTRAINT "NotificationUser_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "NotificationUser" ADD CONSTRAINT "NotificationUser_notificationId_fkey" FOREIGN KEY ("notificationId") REFERENCES "Notification"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "ProjectUser" ADD COLUMN "created" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Warnings:
- The primary key for the `Notification` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The `id` column on the `Notification` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- The primary key for the `NotificationUser` table will be changed. If it partially fails, the table could be left without primary key constraint.
- Changed the type of `notificationId` on the `NotificationUser` 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 "NotificationUser" DROP CONSTRAINT "NotificationUser_notificationId_fkey";

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

-- AlterTable
ALTER TABLE "NotificationUser" DROP CONSTRAINT "NotificationUser_pkey",
DROP COLUMN "notificationId",
ADD COLUMN "notificationId" INTEGER NOT NULL,
ADD CONSTRAINT "NotificationUser_pkey" PRIMARY KEY ("userId", "notificationId");

-- AddForeignKey
ALTER TABLE "NotificationUser" ADD CONSTRAINT "NotificationUser_notificationId_fkey" FOREIGN KEY ("notificationId") REFERENCES "Notification"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
25 changes: 23 additions & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ model User {
email String @unique
password String
projects ProjectUser[]
notifications NotificationUser[]
created DateTime @default(now())
updated DateTime @default(now()) @updatedAt
}
Expand All @@ -31,15 +32,35 @@ model Project {
}

model ProjectUser {
user User @relation(fields: [userId], references: [id])
user User @relation(fields: [userId], references: [id])
userId String
project Project @relation(fields: [projectId], references: [id])
project Project @relation(fields: [projectId], references: [id])
projectId String
role ProjectRole
created DateTime @default(now())
updated DateTime @default(now()) @updatedAt
@@id([userId, projectId])
}

model Notification {
id Int @id @default(autoincrement())
message String
url String?
users NotificationUser[]
created DateTime @default(now())
updated DateTime @default(now()) @updatedAt
}

model NotificationUser {
user User @relation(fields: [userId], references: [id])
userId String
notification Notification @relation(fields: [notificationId], references: [id])
notificationId Int
isRead Boolean @default(false)
@@id([userId, notificationId])
}

enum ProjectRole {
OWNER
EDITOR
Expand Down

0 comments on commit 19fa6d6

Please sign in to comment.