From 83585efc45e6ac6d8249bb27ef8c0265a848bb3a Mon Sep 17 00:00:00 2001 From: OKAMOTO Shigehiro Date: Sun, 7 Apr 2024 01:24:23 +0900 Subject: [PATCH 01/61] refactor submit status --- src/app/forms/FormsList.tsx | 6 +++--- src/app/forms/[form_id]/page.tsx | 4 ++-- src/lib/formHelpers.ts | 10 +++++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/app/forms/FormsList.tsx b/src/app/forms/FormsList.tsx index 6d0d7827..7cada0f3 100644 --- a/src/app/forms/FormsList.tsx +++ b/src/app/forms/FormsList.tsx @@ -48,11 +48,11 @@ export const FormsList: FC<{ const answer = answers.find((ans) => { ans.id === form.id; }); - const endsAt = dayjs(form.ends_at); - const status = getSubmitStatus(endsAt, answer); + const status = getSubmitStatus(form.ends_at, answer); if (filterUnsubmitted && status !== "未提出") { return; } + const endsAt = dayjs(form.ends_at); return ( 読み込み中です……

} ); -}; +}; \ No newline at end of file diff --git a/src/app/forms/[form_id]/page.tsx b/src/app/forms/[form_id]/page.tsx index 6469ff1b..5405d684 100644 --- a/src/app/forms/[form_id]/page.tsx +++ b/src/app/forms/[form_id]/page.tsx @@ -7,7 +7,7 @@ import { css } from "@styled-system/css"; import { FormItems } from "./FormItems"; import dayjs from "dayjs"; -import { getTimeLeftText } from "@/lib/formHelpers"; +import { getTimeLeftText, getSubmitStatusFromDate } from "@/lib/formHelpers"; import { SubmitStatus, submitStatus } from "@/components/SubmitStatus"; export const runtime = "edge"; @@ -26,7 +26,7 @@ const FormDetailPage = ({ params }: { params: { form_id: string } }) => { const { data: answersRes } = useSWR(`/form-answers?project_id=${projectId}`, fetcherWithToken); const _answers = answersRes ? assignType("/form-answers", answersRes) : undefined; - const status: submitStatus = "未提出"; + const status: submitStatus = getSubmitStatusFromDate(form?.ends_at, form?.answered_at); return ( <> diff --git a/src/lib/formHelpers.ts b/src/lib/formHelpers.ts index fb0000ab..3b88ef2d 100644 --- a/src/lib/formHelpers.ts +++ b/src/lib/formHelpers.ts @@ -20,12 +20,16 @@ export const getFormStatus = (now: dayjs.Dayjs, startsAt: dayjs.Dayjs, endsAt: d return "不明"; }; -export const getSubmitStatus = (deadline: dayjs.Dayjs, answer: Answer | undefined): submitStatus => { - if (!answer) { +export const getSubmitStatus = (deadline: string | undefined, answer: Answer | undefined): submitStatus => { + return getSubmitStatusFromDate(deadline, answer?.updated_at); +}; + +export const getSubmitStatusFromDate = (deadline: string | null | undefined, answer: string | null | undefined) => { + if (!answer || !deadline) { return "未提出"; } - if (dayjs(answer.updated_at).isBefore(deadline)) { + if (dayjs(answer).isBefore(dayjs(deadline))) { return "提出済み"; } else { return "遅延提出"; From 9c0eaf6f8d3781f1e6281f26faf3ba53f843a74d Mon Sep 17 00:00:00 2001 From: WhatACotton Date: Thu, 11 Apr 2024 02:32:47 +0900 Subject: [PATCH 02/61] fix: impl --- src/app/committee/projects/[project_id]/page.tsx | 2 +- src/app/dashboard/ProjectView.tsx | 16 ++++++++++------ src/components/header/SwitchModeButton.tsx | 5 ++++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/app/committee/projects/[project_id]/page.tsx b/src/app/committee/projects/[project_id]/page.tsx index 8b54a87a..3b8bd491 100644 --- a/src/app/committee/projects/[project_id]/page.tsx +++ b/src/app/committee/projects/[project_id]/page.tsx @@ -56,7 +56,7 @@ const NewsDetailsPage = ({ params }: { params: { project_id: string } }) => { 企画詳細 - + ); diff --git a/src/app/dashboard/ProjectView.tsx b/src/app/dashboard/ProjectView.tsx index 8336ca17..f984dda0 100644 --- a/src/app/dashboard/ProjectView.tsx +++ b/src/app/dashboard/ProjectView.tsx @@ -12,14 +12,17 @@ import React from "react"; import { ProjectCategoryFormatter } from "@/components/ProjectCategoryFormatter"; import { components } from "@/schema"; import { TableRow } from "./TableRow"; -export const handleCopyInviteLink = async (project_id: string, position: "owner" | "sub_owner") => { +export const handleCopyInviteLink = async ( + project_id: string, + position: "owner" | "sub_owner", + isCommittee: boolean, +) => { const inviteId = localStorage.getItem("invitation_id"); const { data: dataFromAPI, error } = await client.GET("/invitations/{invitation_id}", { params: { path: { invitation_id: inviteId ?? "" } }, }); - let idIsValid = false; - if (inviteId && !error) { + if (inviteId && !error && !isCommittee) { const invitation = assignType("/invitations/{invitation_id}", dataFromAPI); if (!invitation.used_by) { idIsValid = true; @@ -34,7 +37,7 @@ export const handleCopyInviteLink = async (project_id: string, position: "owner" }); return; } - if (!idIsValid || !inviteId) { + if (!idIsValid || !inviteId || isCommittee) { client .POST("/invitations", { body: { @@ -65,7 +68,8 @@ export const ProjectTableView: React.FC<{ onSubmit?: () => unknown; hideSubOwner?: boolean; projectData: components["schemas"]["Project"]; -}> = ({ isEditMode = false, onSubmit = () => {}, hideSubOwner = false, projectData }) => { + isCommittee?: boolean; +}> = ({ isEditMode = false, onSubmit = () => {}, hideSubOwner = false, projectData, isCommittee }) => { const { register, formState: { errors }, @@ -196,7 +200,7 @@ export const ProjectTableView: React.FC<{ {projectData.sub_owner_name ?? ( diff --git a/src/components/header/SwitchModeButton.tsx b/src/components/header/SwitchModeButton.tsx index ffe26a44..6d4c930a 100644 --- a/src/components/header/SwitchModeButton.tsx +++ b/src/components/header/SwitchModeButton.tsx @@ -24,7 +24,10 @@ export const SwitchModeButton: FC<{ isCommitteeMode: boolean; showMobileMenu: bo gap: { lg: 2, base: 0 }, textDecoration: "underline", color: showMobileMenu ? "white" : "black", - })}> + })} + onClick={() => { + localStorage.removeItem("invitation_id"); + }}> Date: Thu, 11 Apr 2024 02:35:51 +0900 Subject: [PATCH 03/61] fix: update condition --- src/app/dashboard/ProjectView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/dashboard/ProjectView.tsx b/src/app/dashboard/ProjectView.tsx index f984dda0..cd6e7832 100644 --- a/src/app/dashboard/ProjectView.tsx +++ b/src/app/dashboard/ProjectView.tsx @@ -37,7 +37,7 @@ export const handleCopyInviteLink = async ( }); return; } - if (!idIsValid || !inviteId || isCommittee) { + if (!idIsValid) { client .POST("/invitations", { body: { From 7319a4b2872fa3d2e145780ff3845e522d291811 Mon Sep 17 00:00:00 2001 From: s7tya <53410646+s7tya@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:29:44 +0900 Subject: [PATCH 04/61] update --- .vscode/settings.json | 7 +- panda.config.ts | 3 + src/app/committee/forms/new/page.tsx | 149 +++++++++++++++++++++++++++ src/lib/textUtils.ts | 35 +++++++ 4 files changed, 191 insertions(+), 3 deletions(-) create mode 100644 src/app/committee/forms/new/page.tsx create mode 100644 src/lib/textUtils.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 31f2c9f3..234fb89f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,8 @@ { "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.tabSize": 2, - "files.insertFinalNewline": true + "files.insertFinalNewline": true, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + } } diff --git a/panda.config.ts b/panda.config.ts index ed752dde..7eb747a0 100644 --- a/panda.config.ts +++ b/panda.config.ts @@ -22,6 +22,9 @@ export default defineConfig({ orange: { value: "#ed6d1f" }, purple: { value: "#60C" }, }, + tsukuba: { + purple: { value: "#60C" }, + } }, }, }, diff --git a/src/app/committee/forms/new/page.tsx b/src/app/committee/forms/new/page.tsx new file mode 100644 index 00000000..ac838b4b --- /dev/null +++ b/src/app/committee/forms/new/page.tsx @@ -0,0 +1,149 @@ +"use client"; + +import { getProjectAttributeText, getProjectCategoryText } from "@/lib/textUtils"; +import { projectAttributes, projectCategories } from "@/lib/valibot"; +import { css } from "@styled-system/css"; +import { stack, visuallyHidden } from "@styled-system/patterns"; +import { NextPage } from "next"; +import { FC } from "react"; +import { useForm } from "react-hook-form"; + +const sectionTitleStyle = css({ + fontSize: "xl", + fontWeight: "bold", +}); + +const descriptionStyle = css({ + fontSize: "sm", + color: "gray.600", +}); + +const checkboxStyle = css({ + py: 1, + px: 4, + rounded: "full", + background: "gray.200", + color: "gray.500", + fontSize: "sm", + fontWeight: "bold", + "&:has(:checked)": { + background: "tsukuba.purple", + color: "white", + }, +}); + +const checkboxGrpupStyle = css({ + display: "flex", + flexWrap: "wrap", + gap: 1, +}); + +const textInputStyle = css({ + border: "1px solid token(colors.gray.400)", + background: "gray.100", + rounded: "sm", + width: "full", + padding: 2, +}); + +const Divider: FC = () => { + return
; +}; + +const CreateFormPage: NextPage = () => { + const { register } = useForm(); + + return ( +
+

+ 新規申請作成 +

+ +
+
+ 送信先絞り込み +

選択しない場合全ての企画が対象になります

+
+ +
+ {projectCategories.map((category) => ( + + ))} +
+
+ +
+ +
+ {projectAttributes.map((attribute) => ( + + ))} +
+
+
+ + + +
+
+ + +
+
+ +