From 48fc595d73d48290d1d21009e05dc3a38da1821e Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Thu, 6 Jun 2024 16:04:23 +0900 Subject: [PATCH 01/24] =?UTF-8?q?[fix]=E3=83=AD=E3=82=B0=E3=81=AE=E5=89=8A?= =?UTF-8?q?=E9=99=A4=E3=80=81warning=E5=AF=BE=E7=AD=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view/next-project/src/pages/purchaseorders/index.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/view/next-project/src/pages/purchaseorders/index.tsx b/view/next-project/src/pages/purchaseorders/index.tsx index 3030cf2d0..4157f9b26 100644 --- a/view/next-project/src/pages/purchaseorders/index.tsx +++ b/view/next-project/src/pages/purchaseorders/index.tsx @@ -180,8 +180,6 @@ export default function PurchaseOrders(props: Props) { getUser(); }, []); - console.log(props.expenseByPeriods); - return ( @@ -320,17 +318,17 @@ export default function PurchaseOrders(props: Props) { onOpen(purchaseOrderViewItem.purchaseOrder.id || 0, purchaseOrderViewItem); }} > -
+
{purchaseOrderViewItem.purchaseItem && purchaseOrderViewItem.purchaseItem.map( (purchaseItem: PurchaseItem, index: number) => ( - <> +

{purchaseOrderViewItem.purchaseItem.length - 1 === index ? ( <>{purchaseItem.item} ) : ( <>{purchaseItem.item}, )} - +

), )}
From f5b9b343e3dae085756a71a85d13d01b789f24ae Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Thu, 6 Jun 2024 16:04:36 +0900 Subject: [PATCH 02/24] =?UTF-8?q?[feat]=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view/next-project/src/utils/api/api_methods.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/view/next-project/src/utils/api/api_methods.ts b/view/next-project/src/utils/api/api_methods.ts index 1b17a8e13..66412708e 100644 --- a/view/next-project/src/utils/api/api_methods.ts +++ b/view/next-project/src/utils/api/api_methods.ts @@ -46,6 +46,19 @@ export const put = async (url: string, data: unknown) => { 'Content-Type': 'application/json', }, body: JSON.stringify(data), - }).then((response) => response.json()); + }).then((response) => response); return res; }; + +export const get_with_token_valid = async (url: string, accessToken?: string) => { + const res = await fetch(url, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'access-token': accessToken ? accessToken : localStorage.getItem('access-token') || 'none', + client: localStorage.getItem('client') || 'none', + uid: localStorage.getItem('uid') || 'none', + }, + }).then((response) => response); + return res.status === 200; +}; From 3865b805424c6aba582c410cf020969d71a57523 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Thu, 6 Jun 2024 16:05:10 +0900 Subject: [PATCH 03/24] =?UTF-8?q?[feat]=E3=82=BB=E3=83=83=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=81=AE=E3=83=88=E3=83=BC=E3=82=AF=E3=83=B3?= =?UTF-8?q?=E3=81=8C=E6=AD=A3=E3=81=97=E3=81=8F=E3=81=AA=E3=81=84=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=83=AD=E3=82=B0=E3=82=A2=E3=82=A6=E3=83=88=E3=81=95?= =?UTF-8?q?=E3=81=9B=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/MainLayout/MainLayout.tsx | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/view/next-project/src/components/layout/MainLayout/MainLayout.tsx b/view/next-project/src/components/layout/MainLayout/MainLayout.tsx index 97582195d..87ce0ff80 100644 --- a/view/next-project/src/components/layout/MainLayout/MainLayout.tsx +++ b/view/next-project/src/components/layout/MainLayout/MainLayout.tsx @@ -4,10 +4,11 @@ import { useRouter } from 'next/router'; import React, { useEffect, useState } from 'react'; import { useRecoilState } from 'recoil'; import s from './MainLayout.module.css'; - -import { authAtom } from '@/store/atoms'; +import { get_with_token_valid } from '@utils/api/api_methods'; +import { authAtom, userAtom } from '@/store/atoms'; import 'tailwindcss/tailwind.css'; import { Header, SideNav } from '@components/common'; +import { User } from '@type/common'; interface LayoutProps { children?: React.ReactNode; @@ -15,19 +16,34 @@ interface LayoutProps { export default function MainLayout(props: LayoutProps) { const router = useRouter(); - const [auth] = useRecoilState(authAtom); + const [auth, setAuth] = useRecoilState(authAtom); + const [_, setUser] = useRecoilState(userAtom); const [isSideNavOpen, setIsSideNavOpen] = useState(true); useEffect(() => { - if (router.isReady) { - if (!auth.isSignIn) { - router.push('/'); + const getCurrentUserUrl = process.env.CSR_API_URI + '/current_user'; + get_with_token_valid(getCurrentUserUrl, auth.accessToken).then((result) => { + if (!result) { localStorage.clear(); - } else if (auth.isSignIn === true && router.pathname == '/') { - router.push('/purchaseorders'); + const authData = { + isSignIn: false, + accessToken: '', + }; + setAuth(authData); + setUser({} as User); + router.push('/'); + } else { + if (router.isReady) { + if (!auth.isSignIn) { + router.push('/'); + localStorage.clear(); + } else if (auth.isSignIn === true && router.pathname == '/') { + router.push('/purchaseorders'); + } + } } - } - }, [router, auth]); + }); + }, [router]); return ( <> From 899623fbaa042cc0c87b9fb715080eede2087c81 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Mon, 10 Jun 2024 17:42:58 +0900 Subject: [PATCH 04/24] =?UTF-8?q?[fix]=E5=90=84=E3=83=9A=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=81=A7=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E6=83=85=E5=A0=B1?= =?UTF-8?q?=E5=8F=96=E5=BE=97=E3=81=AE=E3=81=9F=E3=82=81API=E5=91=BC?= =?UTF-8?q?=E3=81=B3=E5=87=BA=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F=E3=81=9F?= =?UTF-8?q?=E3=82=81=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view/next-project/src/pages/budgets/index.tsx | 22 ++---- .../src/pages/fund_informations/index.tsx | 67 +++++-------------- .../src/pages/purchaseorders/index.tsx | 49 +++++--------- .../src/pages/purchasereports/index.tsx | 50 +++++--------- .../next-project/src/pages/teachers/index.tsx | 32 ++++----- view/next-project/src/pages/users/index.tsx | 12 ++-- .../src/pages/yearperiods/index.tsx | 11 +-- .../next-project/src/utils/api/api_methods.ts | 2 +- 8 files changed, 76 insertions(+), 169 deletions(-) diff --git a/view/next-project/src/pages/budgets/index.tsx b/view/next-project/src/pages/budgets/index.tsx index f27bc195c..7fe08150e 100644 --- a/view/next-project/src/pages/budgets/index.tsx +++ b/view/next-project/src/pages/budgets/index.tsx @@ -1,7 +1,7 @@ import { Tabs, TabList, TabPanels, Tab, TabPanel } from '@chakra-ui/react'; import clsx from 'clsx'; import Head from 'next/head'; -import { useState, useEffect, useMemo } from 'react'; +import { useState, useEffect } from 'react'; import { RiAddCircleLine } from 'react-icons/ri'; import { useRecoilValue } from 'recoil'; @@ -9,8 +9,7 @@ import OpenExpenditureAddModalButton from '@/components/budgets/OpenExpenditureA import OpenExpenseAddModalButton from '@/components/budgets/OpenExpenseAddModalButton'; import OpenExpenseDeleteModalButton from '@/components/budgets/OpenExpenseDeleteModalButton'; import OpenExpenseEditModalButton from '@/components/budgets/OpenExpenseEditModalButton'; -import { authAtom } from '@/store/atoms'; -import { getCurrentUser } from '@/utils/api/currentUser'; +import { userAtom } from '@/store/atoms'; import { get } from '@api/api_methods'; import DetailModal from '@components/budgets/DetailModal'; import OpenAddModalButton from '@components/budgets/OpenAddModalButton'; @@ -58,25 +57,16 @@ export async function getServerSideProps() { export default function BudgetList(props: Props) { const { budgets, sources, years, expenses } = props; - const auth = useRecoilValue(authAtom); + const user = useRecoilValue(userAtom); const [currentUser, setCurrentUser] = useState(); const [budgetViews, setBudgetViews] = useState(props.budgets); const [expenseViews, setExpenseViews] = useState(props.expenses); useEffect(() => { - const getUser = async () => { - const res = await getCurrentUser(auth); - setCurrentUser(res); - }; - getUser(); - }, [auth]); + setCurrentUser(user); + }, []); - const isDisabled = useMemo(() => { - if (currentUser) { - return !(currentUser.roleID === 2 || currentUser.roleID === 3); - } - return true; - }, [currentUser]); + const isDisabled = !(currentUser?.roleID === 2 || currentUser?.roleID === 3); const [forcusExpense, setForcusExpense] = useState(null); const [isOpen, setIsOpen] = useState(false); diff --git a/view/next-project/src/pages/fund_informations/index.tsx b/view/next-project/src/pages/fund_informations/index.tsx index 475520cfa..986b376a6 100644 --- a/view/next-project/src/pages/fund_informations/index.tsx +++ b/view/next-project/src/pages/fund_informations/index.tsx @@ -2,10 +2,8 @@ import clsx from 'clsx'; import Head from 'next/head'; import { useEffect, useCallback, useState, useMemo } from 'react'; import { useRecoilValue } from 'recoil'; - -import { authAtom } from '@/store/atoms'; +import { userAtom } from '@/store/atoms'; import { get } from '@api/api_methods'; -import { getCurrentUser } from '@api/currentUser'; import { put } from '@api/fundInformations'; import { Title, Card } from '@components/common'; import { Checkbox } from '@components/common'; @@ -67,9 +65,13 @@ export default function FundInformations(props: Props) { const teachers: Teacher[] = props.teachers; const users: User[] = props.users; const departments: Department[] = props.departments; - const auth = useRecoilValue(authAtom); + const user = useRecoilValue(userAtom); const [currentUser, setCurrentUser] = useState(); + useEffect(() => { + setCurrentUser(user); + }, []); + // 募金一覧 const [fundInformationViews, setFundInformationViews] = useState( props.fundInformationView, @@ -97,53 +99,18 @@ export default function FundInformations(props: Props) { const [isFirstChecks, setIsFirstChecks] = useState([]); const [isLastChecks, setIsLastChecks] = useState([]); - const isDeveloper = useMemo(() => { - if (currentUser?.roleID == 2) { - return true; - } else { - return false; - } - }, [currentUser?.roleID]); - - const isFinanceDirector = useMemo(() => { - if (currentUser?.roleID == 3) { - return true; - } else { - return false; - } - }, [currentUser?.roleID]); - - const isFinanceStaff = useMemo(() => { - if (currentUser?.bureauID == 3 || currentUser?.bureauID == 4) { - return true; - } else { - return false; - } - }, [currentUser?.bureauID]); - - const isDisabled = useCallback( - (fundViewItem: FundInformationView) => { - if ( - fundViewItem.fundInformation.userID == currentUser?.id || - isDeveloper || - isFinanceStaff || - isFinanceDirector - ) { - return false; - } else { - return true; - } - }, - [currentUser?.id, isDeveloper, isFinanceStaff, isFinanceDirector], - ); + const isDeveloper = currentUser?.roleID == 2; + const isFinanceDirector = currentUser?.roleID == 3; + const isFinanceStaff = currentUser?.bureauID == 3 || currentUser?.bureauID == 4; - useEffect(() => { - const getUser = async () => { - const res = await getCurrentUser(auth); - setCurrentUser(res); - }; - getUser(); - }, []); + const isDisabled = (fundViewItem: FundInformationView) => { + return !( + fundViewItem.fundInformation.userID == currentUser?.id || + isDeveloper || + isFinanceStaff || + isFinanceDirector + ); + }; useEffect(() => { if (fundInformationViews) { diff --git a/view/next-project/src/pages/purchaseorders/index.tsx b/view/next-project/src/pages/purchaseorders/index.tsx index 4157f9b26..f6e0909d0 100644 --- a/view/next-project/src/pages/purchaseorders/index.tsx +++ b/view/next-project/src/pages/purchaseorders/index.tsx @@ -2,12 +2,11 @@ import Head from 'next/head'; import { useCallback, useEffect, useState, useMemo } from 'react'; import { useRecoilValue } from 'recoil'; import PrimaryButton from '@/components/common/OutlinePrimaryButton/OutlinePrimaryButton'; -import { authAtom } from '@/store/atoms'; +import { userAtom } from '@/store/atoms'; import { put } from '@/utils/api/purchaseOrder'; import { createPurchaseOrdersCsv } from '@/utils/createPurchaseOrdersCsv'; import { downloadFile } from '@/utils/downloadFile'; import { get } from '@api/api_methods'; -import { getCurrentUser } from '@api/currentUser'; import { Card, Checkbox, Title, BureauLabel } from '@components/common'; import MainLayout from '@components/layout/MainLayout'; import DetailModal from '@components/purchaseorders/DetailModal'; @@ -67,7 +66,7 @@ const formatYYYYMMDD = (date: Date) => { }; export default function PurchaseOrders(props: Props) { - const auth = useRecoilValue(authAtom); + const user = useRecoilValue(userAtom); const [currentUser, setCurrentUser] = useState(); const [purchaseOrderChecks, setPurchaseOrderChecks] = useState([]); const [purchaseOrderID, setPurchaseOrderID] = useState(1); @@ -82,6 +81,10 @@ export default function PurchaseOrders(props: Props) { setIsOpen(true); }; + useEffect(() => { + setCurrentUser(user); + }, []); + const formatDate = (date: string) => { const datetime = date.replace('T', ' '); const datetime2 = datetime.substring(5, datetime.length - 10).replace('-', '/'); @@ -96,7 +99,6 @@ export default function PurchaseOrders(props: Props) { const getPurchaseOrders = async () => { const getPurchaseOrderViewUrlByYear = process.env.CSR_API_URI + '/purchaseorders/details/' + selectedYear; - console.log(getPurchaseOrderViewUrlByYear); const getPurchaseOrderByYears = await get(getPurchaseOrderViewUrlByYear); setPurchaseOrderViews(getPurchaseOrderByYears); }; @@ -148,36 +150,17 @@ export default function PurchaseOrders(props: Props) { setPurchaseOrderViews(newPurchaseOrderViews); }; - const isFinanceDirector = useMemo(() => { - if (currentUser?.roleID === 3) { - return true; - } else { - return false; - } - }, [currentUser?.roleID]); + const isFinanceDirector = currentUser?.roleID === 3; - const isDisabled = useCallback( - (purchaseOrderViewItem: PurchaseOrderView) => { - if ( - !purchaseOrderViewItem.purchaseOrder.financeCheck && - (currentUser?.roleID === 2 || - currentUser?.roleID === 3 || - currentUser?.id === purchaseOrderViewItem.purchaseOrder.userID) - ) { - return false; - } else { - return true; - } - }, - [currentUser?.id, currentUser?.roleID, purchaseOrderViews], - ); - - useEffect(() => { - const getUser = async () => { - const res = await getCurrentUser(auth); - setCurrentUser(res); - }; - getUser(); + const isDisabled = useCallback((purchaseOrderViewItem: PurchaseOrderView) => { + return ( + purchaseOrderViewItem.purchaseOrder.financeCheck && + !( + currentUser?.roleID === 2 || + currentUser?.roleID === 3 || + currentUser?.id === purchaseOrderViewItem.purchaseOrder.userID + ) + ); }, []); return ( diff --git a/view/next-project/src/pages/purchasereports/index.tsx b/view/next-project/src/pages/purchasereports/index.tsx index b6dd01dda..33452df12 100644 --- a/view/next-project/src/pages/purchasereports/index.tsx +++ b/view/next-project/src/pages/purchasereports/index.tsx @@ -2,12 +2,11 @@ import Head from 'next/head'; import { useCallback, useEffect, useState, useMemo } from 'react'; import { useRecoilValue } from 'recoil'; import PrimaryButton from '@/components/common/OutlinePrimaryButton/OutlinePrimaryButton'; -import { authAtom } from '@/store/atoms'; +import { userAtom } from '@/store/atoms'; import { put } from '@/utils/api/api_methods'; import { createPurchaseReportCsv } from '@/utils/createPurchaseReportCsv'; import { downloadFile } from '@/utils/downloadFile'; import { get } from '@api/api_methods'; -import { getCurrentUser } from '@api/currentUser'; import { Card, Checkbox, Title, BureauLabel } from '@components/common'; import MainLayout from '@components/layout/MainLayout'; import DetailModal from '@components/purchasereports/DetailModal'; @@ -71,7 +70,7 @@ const formatYYYYMMDD = (date: Date) => { }; export default function PurchaseReports(props: Props) { - const auth = useRecoilValue(authAtom); + const user = useRecoilValue(userAtom); const [currentUser, setCurrentUser] = useState(); const [purchaseReportID, setPurchaseReportID] = useState(1); const [purchaseReportViewItem, setPurchaseReportViewItem] = useState(); @@ -138,21 +137,20 @@ export default function PurchaseReports(props: Props) { // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedYear]); - const isDisabled = useCallback( - (purchaseReportView: PurchaseReportView) => { - if ( - !purchaseReportView.purchaseReport.financeCheck && - (currentUser?.roleID === 2 || - currentUser?.roleID === 3 || - currentUser?.id === purchaseReportView.purchaseReport.userID) - ) { - return false; - } else { - return true; - } - }, - [currentUser?.roleID, currentUser?.id], - ); + useEffect(() => { + setCurrentUser(user); + }, []); + + const isDisabled = useCallback((purchaseReportView: PurchaseReportView) => { + return ( + purchaseReportView.purchaseReport.financeCheck && + !( + currentUser?.roleID === 2 || + currentUser?.roleID === 3 || + currentUser?.id === purchaseReportView.purchaseReport.userID + ) + ); + }, []); const updatePurchaseReport = async (purchaseReportID: number, purchaseReport: PurchaseReport) => { const url = process.env.CSR_API_URI + '/purchasereports/' + purchaseReportID; @@ -175,21 +173,7 @@ export default function PurchaseReports(props: Props) { } }, [purchaseReportViews]); - const isFinanceDirector = useMemo(() => { - if (currentUser?.roleID === 3) { - return true; - } else { - return false; - } - }, [currentUser?.roleID]); - - useEffect(() => { - const getUser = async () => { - const res = await getCurrentUser(auth); - setCurrentUser(res); - }; - getUser(); - }, []); + const isFinanceDirector = currentUser?.roleID === 3; return ( diff --git a/view/next-project/src/pages/teachers/index.tsx b/view/next-project/src/pages/teachers/index.tsx index 858c3a9ff..02d0346c1 100644 --- a/view/next-project/src/pages/teachers/index.tsx +++ b/view/next-project/src/pages/teachers/index.tsx @@ -2,8 +2,7 @@ import clsx from 'clsx'; import Head from 'next/head'; import { useMemo, useState, useEffect } from 'react'; import { useRecoilValue } from 'recoil'; -import { authAtom } from '@/store/atoms'; -import { getCurrentUser } from '@/utils/api/currentUser'; +import { userAtom } from '@/store/atoms'; import { get } from '@api/api_methods'; import { Card, Title } from '@components/common'; import MainLayout from '@components/layout/MainLayout'; @@ -42,18 +41,19 @@ export default function TeachersList(props: Props) { departments[0], ); - const auth = useRecoilValue(authAtom); - const [currentUser, setCurrentUser] = useState(null); - const isDisabled = useMemo(() => { - if (currentUser?.roleID === 2 || currentUser?.roleID === 3 || currentUser?.id === 4) { - return false; - } else { - return true; - } - }, [currentUser?.roleID, currentUser?.id, currentUser]); - + const user = useRecoilValue(userAtom); + const [currentUser, setCurrentUser] = useState(); + const isDisabled = !( + currentUser?.roleID === 2 || + currentUser?.roleID === 3 || + currentUser?.id === 4 + ); const [filterTeachers, setFilterTeachers] = useState(teachers); + useEffect(() => { + setCurrentUser(user); + }, []); + useEffect(() => { const newFilterTeachers = selectedDepartment?.id === 0 @@ -64,14 +64,6 @@ export default function TeachersList(props: Props) { setFilterTeachers(newFilterTeachers); }, [selectedDepartment]); - useEffect(() => { - const getUser = async () => { - const res = await getCurrentUser(auth); - setCurrentUser(res); - }; - getUser(); - }, []); - return ( diff --git a/view/next-project/src/pages/users/index.tsx b/view/next-project/src/pages/users/index.tsx index 43d855cf3..eccff3c2a 100644 --- a/view/next-project/src/pages/users/index.tsx +++ b/view/next-project/src/pages/users/index.tsx @@ -4,8 +4,7 @@ import { useRouter } from 'next/router'; import { useEffect, useState, useMemo } from 'react'; import { useRecoilValue } from 'recoil'; import OpenDeleteModalButton from '@/components/users/OpenDeleteModalButton'; -import { authAtom } from '@/store/atoms'; -import { getCurrentUser } from '@/utils/api/currentUser'; +import { userAtom } from '@/store/atoms'; import { get } from '@api/api_methods'; import { Card, Title } from '@components/common'; import MainLayout from '@components/layout/MainLayout/MainLayout'; @@ -33,14 +32,11 @@ export default function Users(props: Props) { const { users } = props; const router = useRouter(); - const auth = useRecoilValue(authAtom); + const user = useRecoilValue(userAtom); const [currentUser, setCurrentUser] = useState(); + useEffect(() => { - const getUser = async () => { - const res = await getCurrentUser(auth); - setCurrentUser(res); - }; - getUser(); + setCurrentUser(user); }, []); const [deleteUsers, setDeleteUsers] = useState<{ users: User[]; ids: number[] }>({ diff --git a/view/next-project/src/pages/yearperiods/index.tsx b/view/next-project/src/pages/yearperiods/index.tsx index fa21915dd..f676fc47f 100644 --- a/view/next-project/src/pages/yearperiods/index.tsx +++ b/view/next-project/src/pages/yearperiods/index.tsx @@ -7,8 +7,7 @@ import { useRecoilValue } from 'recoil'; import OpenAddModalButton from '@/components/yearperiods/OpenAddModalButton'; import OpenDeleteModalButton from '@/components/yearperiods/OpenDeleteModalButton'; import OpenEditModalButton from '@/components/yearperiods/OpenEditModalButton'; -import { authAtom } from '@/store/atoms'; -import { getCurrentUser } from '@/utils/api/currentUser'; +import { userAtom } from '@/store/atoms'; import { get } from '@api/api_methods'; import { Card, Title } from '@components/common'; import MainLayout from '@components/layout/MainLayout/MainLayout'; @@ -33,7 +32,7 @@ export default function Periods(props: Props) { const { yearPeriods } = props; const router = useRouter(); - const auth = useRecoilValue(authAtom); + const user = useRecoilValue(userAtom); const [currentUser, setCurrentUser] = useState(); const formatYearPeriods = @@ -47,11 +46,7 @@ export default function Periods(props: Props) { }); useEffect(() => { - const getUser = async () => { - const res = await getCurrentUser(auth); - setCurrentUser(res); - }; - getUser(); + setCurrentUser(user); }, []); // ログイン中のユーザの権限 diff --git a/view/next-project/src/utils/api/api_methods.ts b/view/next-project/src/utils/api/api_methods.ts index 66412708e..fa02273f9 100644 --- a/view/next-project/src/utils/api/api_methods.ts +++ b/view/next-project/src/utils/api/api_methods.ts @@ -46,7 +46,7 @@ export const put = async (url: string, data: unknown) => { 'Content-Type': 'application/json', }, body: JSON.stringify(data), - }).then((response) => response); + }).then((response) => response.json()); return res; }; From 23f0dd2b5cc5f1e09e2e9b2d6dd4067b606bb804 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Tue, 11 Jun 2024 09:03:08 +0000 Subject: [PATCH 05/24] formatted by workflow --- .../src/components/layout/MainLayout/MainLayout.tsx | 2 +- view/next-project/src/pages/fund_informations/index.tsx | 2 +- view/next-project/src/pages/teachers/index.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/view/next-project/src/components/layout/MainLayout/MainLayout.tsx b/view/next-project/src/components/layout/MainLayout/MainLayout.tsx index 87ce0ff80..4a611f462 100644 --- a/view/next-project/src/components/layout/MainLayout/MainLayout.tsx +++ b/view/next-project/src/components/layout/MainLayout/MainLayout.tsx @@ -4,11 +4,11 @@ import { useRouter } from 'next/router'; import React, { useEffect, useState } from 'react'; import { useRecoilState } from 'recoil'; import s from './MainLayout.module.css'; -import { get_with_token_valid } from '@utils/api/api_methods'; import { authAtom, userAtom } from '@/store/atoms'; import 'tailwindcss/tailwind.css'; import { Header, SideNav } from '@components/common'; import { User } from '@type/common'; +import { get_with_token_valid } from '@utils/api/api_methods'; interface LayoutProps { children?: React.ReactNode; diff --git a/view/next-project/src/pages/fund_informations/index.tsx b/view/next-project/src/pages/fund_informations/index.tsx index 986b376a6..9f82d5f0b 100644 --- a/view/next-project/src/pages/fund_informations/index.tsx +++ b/view/next-project/src/pages/fund_informations/index.tsx @@ -1,6 +1,6 @@ import clsx from 'clsx'; import Head from 'next/head'; -import { useEffect, useCallback, useState, useMemo } from 'react'; +import { useEffect, useState, useMemo } from 'react'; import { useRecoilValue } from 'recoil'; import { userAtom } from '@/store/atoms'; import { get } from '@api/api_methods'; diff --git a/view/next-project/src/pages/teachers/index.tsx b/view/next-project/src/pages/teachers/index.tsx index 02d0346c1..695eebd82 100644 --- a/view/next-project/src/pages/teachers/index.tsx +++ b/view/next-project/src/pages/teachers/index.tsx @@ -1,6 +1,6 @@ import clsx from 'clsx'; import Head from 'next/head'; -import { useMemo, useState, useEffect } from 'react'; +import { useState, useEffect } from 'react'; import { useRecoilValue } from 'recoil'; import { userAtom } from '@/store/atoms'; import { get } from '@api/api_methods'; From a722b6f8165998b3e5ddb0b91c599fd7a395fb21 Mon Sep 17 00:00:00 2001 From: TkymHrt <23.h.takayama.nutfes@gmail.com> Date: Sun, 16 Jun 2024 00:12:57 +0900 Subject: [PATCH 06/24] =?UTF-8?q?[feat]=20=E9=81=B8=E6=8A=9E=E3=83=A2?= =?UTF-8?q?=E3=83=BC=E3=83=80=E3=83=AB=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../purchasereports/OpenEditModalButton.tsx | 53 ++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/view/next-project/src/components/purchasereports/OpenEditModalButton.tsx b/view/next-project/src/components/purchasereports/OpenEditModalButton.tsx index 0bd901767..8349ebfd2 100644 --- a/view/next-project/src/components/purchasereports/OpenEditModalButton.tsx +++ b/view/next-project/src/components/purchasereports/OpenEditModalButton.tsx @@ -1,7 +1,8 @@ import * as React from 'react'; import { useState } from 'react'; -import { EditButton } from '@components/common'; +import { DetailEditModal } from './DetailEditModal'; +import { CloseButton, EditButton, Modal, PrimaryButton } from '@components/common'; import EditModal from '@components/purchasereports/EditModal'; interface Props { @@ -10,15 +11,55 @@ interface Props { isDisabled: boolean; } +const InitialModal: React.FC<{ setStep: (step: string) => void; closeModal: () => void }> = ({ + setStep, + closeModal, +}) => ( + +
+ +
+
+

購入報告の修正

+
+
+ setStep('editDetails')}>局と期限日を編集 + setStep('editPurchases')}>購入物品を編集 +
+
+); + const OpenEditModalButton: React.FC = (props) => { - const [isOpen, setIsOpen] = useState(false); - const onOpen = () => { - setIsOpen(true); + const [step, setStep] = useState(null); + + const onOpenInitial = () => { + setStep('initial'); }; + + const closeModal = () => { + setStep(null); + }; + return ( <> - - {isOpen && } + + {step === 'initial' && } + {step === 'editDetails' && ( + + )} + {step === 'editPurchases' && ( + + )} ); }; From 379ff058fd6b8857b037f12fa473010fe8598c9c Mon Sep 17 00:00:00 2001 From: TkymHrt <23.h.takayama.nutfes@gmail.com> Date: Sun, 16 Jun 2024 00:13:32 +0900 Subject: [PATCH 07/24] =?UTF-8?q?[feat]=20=E9=81=B8=E6=8A=9E=E3=83=A2?= =?UTF-8?q?=E3=83=BC=E3=83=80=E3=83=AB=E3=81=B8=E6=88=BB=E3=82=8B=E3=83=9C?= =?UTF-8?q?=E3=82=BF=E3=83=B3=E3=82=92=E8=A1=A8=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/purchasereports/EditModal.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/view/next-project/src/components/purchasereports/EditModal.tsx b/view/next-project/src/components/purchasereports/EditModal.tsx index 7095bb82a..2932c11e8 100644 --- a/view/next-project/src/components/purchasereports/EditModal.tsx +++ b/view/next-project/src/components/purchasereports/EditModal.tsx @@ -22,6 +22,7 @@ interface ModalProps { purchaseReportId: number; isOpen: boolean; setIsOpen: (isOpen: boolean) => void; + onOpenInitial: () => void; } export default function EditModal(props: ModalProps) { @@ -310,11 +311,12 @@ export default function EditModal(props: ModalProps) { {formDataList.length > 0 ? (
{/* stepが1より大きい時のみ戻るボタンを表示 */} - {activeStep > 1 && ( - - 戻る - - )} + 1 ? prevStep : props.onOpenInitial} + className={'mx-2'} + > + 戻る + { From 519658e73a7b799632f33ad4c68fcedcb0bbba8e Mon Sep 17 00:00:00 2001 From: TkymHrt <23.h.takayama.nutfes@gmail.com> Date: Sun, 16 Jun 2024 00:13:50 +0900 Subject: [PATCH 08/24] =?UTF-8?q?[feat]=20=E5=B1=80=E3=81=A8=E6=9C=9F?= =?UTF-8?q?=E9=99=90=E6=97=A5=E3=82=92=E7=B7=A8=E9=9B=86=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=83=A2=E3=83=BC=E3=83=80=E3=83=AB=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../purchasereports/DetailEditModal.tsx | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 view/next-project/src/components/purchasereports/DetailEditModal.tsx diff --git a/view/next-project/src/components/purchasereports/DetailEditModal.tsx b/view/next-project/src/components/purchasereports/DetailEditModal.tsx new file mode 100644 index 000000000..c76060ccb --- /dev/null +++ b/view/next-project/src/components/purchasereports/DetailEditModal.tsx @@ -0,0 +1,116 @@ +import router from 'next/router'; +import { useEffect, useState } from 'react'; +import { Expense, PurchaseOrder, PurchaseReport } from '@/type/common'; +import { put } from '@/utils/api/purchaseOrder'; +import { get } from '@api/api_methods'; +import { + CloseButton, + Input, + Modal, + OutlinePrimaryButton, + PrimaryButton, + Select, +} from '@components/common'; + +export const DetailEditModal: React.FC<{ + purchaseReportId: number; + isOpen: boolean; + setIsOpen: () => void; + onOpenInitial: () => void; +}> = ({ purchaseReportId, setIsOpen, onOpenInitial }) => { + const [purchaseOrderId, setPurchaseOrderId] = useState(); + const [expenses, setExpenses] = useState([]); + const [deadline, setDeadline] = useState(''); + const [userId, setUserId] = useState(0); + const [expenseID, setExpenseID] = useState(0); + const [finansuCheck, setFinansuCheck] = useState(false); + + useEffect(() => { + const fetchData = async () => { + try { + const purchaseReportRes: PurchaseReport = await get(`${process.env.CSR_API_URI}/purchasereports/${purchaseReportId}`); + const purchaseOrderId = purchaseReportRes.purchaseOrderID; + const expensesRes: Expense[] = await get(`${process.env.CSR_API_URI}/expenses`); + const purchaseOrderRes: PurchaseOrder = await get(`${process.env.CSR_API_URI}/purchaseorders/${purchaseOrderId}`); + setPurchaseOrderId(purchaseOrderId); + setExpenses(expensesRes); + setDeadline(purchaseOrderRes.deadline); + setUserId(purchaseOrderRes.userID); + setExpenseID(purchaseOrderRes.expenseID); + setFinansuCheck(purchaseOrderRes.financeCheck); + } catch (error) { + console.error('Failed to fetch data:', error); + } + }; + fetchData(); + }, [purchaseReportId]); + + const formatDate = (date: string) => { + const d = new Date(date); + const year = d.getFullYear(); + const month = (1 + d.getMonth()).toString().padStart(2, '0'); + const day = d.getDate().toString().padStart(2, '0'); + return `${year}-${month}-${day}`; + }; + + const submit = async () => { + const submitData = { + id: purchaseOrderId, + deadline: deadline, + userID: userId, + expenseID: expenseID, + financeCheck: finansuCheck, + }; + try { + const updatePurchaseOrderUrl = `${process.env.CSR_API_URI}/purchaseorders/${submitData.id}`; + await put(updatePurchaseOrderUrl, submitData); + } finally { + router.reload(); + } + }; + return ( + +
+ +
+
+

購入した局と期限日を修正

+
+
+

購入した局

+
+ +
+

期限日

+
+ setDeadline(e.target.value)} + className='w-full' + /> +
+
+
+ + 戻る + + + 編集完了 + +
+
+ ); +}; From b7803ad7ccd5ac6474174f578a3c775646e1c320 Mon Sep 17 00:00:00 2001 From: TkymHrt <23.h.takayama.nutfes@gmail.com> Date: Sun, 16 Jun 2024 00:18:24 +0900 Subject: [PATCH 09/24] =?UTF-8?q?[fix]=20=E4=B8=8D=E8=A6=81=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=81=A3=E3=81=9F=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view/next-project/src/components/purchasereports/EditModal.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/view/next-project/src/components/purchasereports/EditModal.tsx b/view/next-project/src/components/purchasereports/EditModal.tsx index 2932c11e8..571bbf920 100644 --- a/view/next-project/src/components/purchasereports/EditModal.tsx +++ b/view/next-project/src/components/purchasereports/EditModal.tsx @@ -310,7 +310,6 @@ export default function EditModal(props: ModalProps) {
{formDataList.length > 0 ? (
- {/* stepが1より大きい時のみ戻るボタンを表示 */} 1 ? prevStep : props.onOpenInitial} className={'mx-2'} From 50e74e8a995052fd9d9e15444f7e4da8c41380ef Mon Sep 17 00:00:00 2001 From: hikahana <22.h.hanada.nutfes@gmail.com> Date: Mon, 17 Jun 2024 04:48:02 +0000 Subject: [PATCH 10/24] =?UTF-8?q?[fix]=20updated=5Fat=E3=81=AE=E9=99=8D?= =?UTF-8?q?=E9=A0=86=E3=81=A7=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/externals/repository/activity_repository.go | 2 +- api/externals/repository/fund_information_repository.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/externals/repository/activity_repository.go b/api/externals/repository/activity_repository.go index 304208bc8..e70a9a002 100644 --- a/api/externals/repository/activity_repository.go +++ b/api/externals/repository/activity_repository.go @@ -181,7 +181,7 @@ func (ar *activityRepository) AllDetailsByPeriod(c context.Context, year string) year_periods.year_id = years.id WHERE years.year = ` + year + - " ORDER BY activities.id" + " ORDER BY activities.updated_at DESC" return ar.crud.Read(c, query) } diff --git a/api/externals/repository/fund_information_repository.go b/api/externals/repository/fund_information_repository.go index 8eb67305c..561ac3ae6 100644 --- a/api/externals/repository/fund_information_repository.go +++ b/api/externals/repository/fund_information_repository.go @@ -198,6 +198,6 @@ func (fir *fundInformationRepository) AllDetailsByPeriod(c context.Context, year year_periods.year_id = years.id WHERE years.year = ` + year + - " ORDER BY fund_informations.id;" + " ORDER BY fund_informations.updated_at DESC;" return fir.crud.Read(c, query) } From 96ffc56bc124723a3145dfaeb0c6c608feb91b6e Mon Sep 17 00:00:00 2001 From: hikahana <22.h.hanada.nutfes@gmail.com> Date: Mon, 17 Jun 2024 05:24:05 +0000 Subject: [PATCH 11/24] =?UTF-8?q?[fix]=20=E3=83=95=E3=82=A3=E3=83=AB?= =?UTF-8?q?=E3=82=BF=E3=83=BC=E3=81=AE=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB?= =?UTF-8?q?=E3=83=88=E3=82=92=E6=9B=B4=E6=96=B0=E6=97=A5=E6=99=82=E9=99=8D?= =?UTF-8?q?=E9=A0=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/sponsoractivities/index.tsx | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/view/next-project/src/pages/sponsoractivities/index.tsx b/view/next-project/src/pages/sponsoractivities/index.tsx index ec8d8d164..90e33e0d7 100644 --- a/view/next-project/src/pages/sponsoractivities/index.tsx +++ b/view/next-project/src/pages/sponsoractivities/index.tsx @@ -144,36 +144,36 @@ export default function SponsorActivities(props: Props) { } switch (selectedSort) { - case 'createDesSort': + case 'updateSort': if (!Array.isArray(filteredActivities)) { return []; } return [...filteredActivities].sort( (firstObject: SponsorActivityView, secondObject: SponsorActivityView) => - new Date(firstObject.sponsorActivity.createdAt || 0).getTime() > - new Date(secondObject.sponsorActivity.createdAt || 0).getTime() - ? -1 - : 1, + new Date(firstObject.sponsorActivity.updatedAt || 0).getTime() > + new Date(secondObject.sponsorActivity.updatedAt || 0).getTime() + ? 1 + : -1, ); - case 'updateSort': + case 'createSort': if (!Array.isArray(filteredActivities)) { return []; } return [...filteredActivities].sort( (firstObject: SponsorActivityView, secondObject: SponsorActivityView) => - new Date(firstObject.sponsorActivity.updatedAt || 0).getTime() > - new Date(secondObject.sponsorActivity.updatedAt || 0).getTime() - ? 1 - : -1, + new Date(firstObject.sponsorActivity.createdAt || 0).getTime() < + new Date(secondObject.sponsorActivity.createdAt || 0).getTime() + ? -1 + : 1, ); - case 'updateDesSort': + case 'createDesSort': if (!Array.isArray(filteredActivities)) { return []; } return [...filteredActivities].sort( (firstObject: SponsorActivityView, secondObject: SponsorActivityView) => - new Date(firstObject.sponsorActivity.updatedAt || 0).getTime() > - new Date(secondObject.sponsorActivity.updatedAt || 0).getTime() + new Date(firstObject.sponsorActivity.createdAt || 0).getTime() > + new Date(secondObject.sponsorActivity.createdAt || 0).getTime() ? -1 : 1, ); @@ -278,12 +278,12 @@ export default function SponsorActivities(props: Props) { defaultValue={'default'} onChange={(e) => setSelectedSort(e.target.value)} > - - + - - + + + Date: Mon, 17 Jun 2024 06:33:52 +0000 Subject: [PATCH 12/24] formatted by workflow --- .../src/components/purchasereports/DetailEditModal.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/view/next-project/src/components/purchasereports/DetailEditModal.tsx b/view/next-project/src/components/purchasereports/DetailEditModal.tsx index c76060ccb..c007b6061 100644 --- a/view/next-project/src/components/purchasereports/DetailEditModal.tsx +++ b/view/next-project/src/components/purchasereports/DetailEditModal.tsx @@ -28,10 +28,14 @@ export const DetailEditModal: React.FC<{ useEffect(() => { const fetchData = async () => { try { - const purchaseReportRes: PurchaseReport = await get(`${process.env.CSR_API_URI}/purchasereports/${purchaseReportId}`); + const purchaseReportRes: PurchaseReport = await get( + `${process.env.CSR_API_URI}/purchasereports/${purchaseReportId}`, + ); const purchaseOrderId = purchaseReportRes.purchaseOrderID; const expensesRes: Expense[] = await get(`${process.env.CSR_API_URI}/expenses`); - const purchaseOrderRes: PurchaseOrder = await get(`${process.env.CSR_API_URI}/purchaseorders/${purchaseOrderId}`); + const purchaseOrderRes: PurchaseOrder = await get( + `${process.env.CSR_API_URI}/purchaseorders/${purchaseOrderId}`, + ); setPurchaseOrderId(purchaseOrderId); setExpenses(expensesRes); setDeadline(purchaseOrderRes.deadline); From e5850063933e937fbd98f66507cbf2ee1becacbf Mon Sep 17 00:00:00 2001 From: Ryotakobayash Date: Wed, 19 Jun 2024 00:56:16 +0900 Subject: [PATCH 13/24] [add]EditButton.stories.tsx --- .../src/stories/EditButton.stories.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 view/next-project/src/stories/EditButton.stories.tsx diff --git a/view/next-project/src/stories/EditButton.stories.tsx b/view/next-project/src/stories/EditButton.stories.tsx new file mode 100644 index 000000000..cd51806b8 --- /dev/null +++ b/view/next-project/src/stories/EditButton.stories.tsx @@ -0,0 +1,18 @@ +import { Meta } from '@storybook/react'; +import { EditButton } from '@components/common'; + +const meta: Meta = { + title: 'FinanSu/EditButton', + component: EditButton, + tags: ['autodocs'], + argTypes: {}, +}; + +export default meta; + +export const Primary = { + args: { + className: 'm-10', + children:

children

, + }, +}; From 75605dcb75f70157211f9da594d4f44c5832d8c5 Mon Sep 17 00:00:00 2001 From: Ryotakobayash Date: Wed, 19 Jun 2024 01:25:13 +0900 Subject: [PATCH 14/24] [add] OpenModalButton.stories.tsx --- .../src/components/common/index.ts | 1 + .../src/stories/OpenModalButton.stories.tsx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 view/next-project/src/stories/OpenModalButton.stories.tsx diff --git a/view/next-project/src/components/common/index.ts b/view/next-project/src/components/common/index.ts index bdd36509c..f2524c7ec 100644 --- a/view/next-project/src/components/common/index.ts +++ b/view/next-project/src/components/common/index.ts @@ -10,6 +10,7 @@ export { default as EditButton } from './EditButton'; export { default as Input } from './Input'; export { default as Modal } from './Modal'; export { default as OutlinePrimaryButton } from './OutlinePrimaryButton'; +export { default as OpenModalButton } from './OpenModalButton'; export { default as PrimaryButton } from './PrimaryButton'; export { default as PullDown } from './PullDown'; export { default as Radio } from './Radio'; diff --git a/view/next-project/src/stories/OpenModalButton.stories.tsx b/view/next-project/src/stories/OpenModalButton.stories.tsx new file mode 100644 index 000000000..d6bcc82d8 --- /dev/null +++ b/view/next-project/src/stories/OpenModalButton.stories.tsx @@ -0,0 +1,18 @@ +import { Meta } from '@storybook/react'; +import { OpenModalButton } from '@components/common'; + +const meta: Meta = { + title: 'FinanSu/OpenModalButton', + component: OpenModalButton, + tags: ['autodocs'], + argTypes: {}, +}; + +export default meta; + +export const Primary = { + args: { + className: 'm-10', + children:

children

, + }, +}; From a38978d8238a56dc542ce8a9cbccca4f3f7acb98 Mon Sep 17 00:00:00 2001 From: Ryotakobayash Date: Wed, 19 Jun 2024 01:42:06 +0900 Subject: [PATCH 15/24] [add]RegistButton.stories.tsx --- .../next-project/src/components/common/index.ts | 1 + .../src/stories/RegistButton.stories.tsx | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 view/next-project/src/stories/RegistButton.stories.tsx diff --git a/view/next-project/src/components/common/index.ts b/view/next-project/src/components/common/index.ts index f2524c7ec..975e1c872 100644 --- a/view/next-project/src/components/common/index.ts +++ b/view/next-project/src/components/common/index.ts @@ -15,6 +15,7 @@ export { default as PrimaryButton } from './PrimaryButton'; export { default as PullDown } from './PullDown'; export { default as Radio } from './Radio'; export { default as RedButton } from './RedButton'; +export { default as RegistButton } from './RegistButton'; export { default as Select } from './Select'; export { default as Stepper } from './Stepper'; export { default as Textarea } from './Textarea'; diff --git a/view/next-project/src/stories/RegistButton.stories.tsx b/view/next-project/src/stories/RegistButton.stories.tsx new file mode 100644 index 000000000..9098a68ef --- /dev/null +++ b/view/next-project/src/stories/RegistButton.stories.tsx @@ -0,0 +1,17 @@ +import { Meta } from '@storybook/react'; +import { RegistButton } from '@components/common'; +const meta: Meta = { + title: 'FinanSu/RegistButton', + component: RegistButton, + tags: ['autodocs'], + argTypes: {}, +}; + +export default meta; + +export const Primary = { + args: { + className: 'm-10', + children:

children

, + }, +}; From fa53f892b73c173732853bda075a87076152cfe3 Mon Sep 17 00:00:00 2001 From: Ryotakobayash Date: Wed, 19 Jun 2024 01:48:11 +0900 Subject: [PATCH 16/24] [add]LoadingButton.stories.tsx --- .../src/components/common/index.ts | 1 + .../src/stories/LoadingButton.stories.tsx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 view/next-project/src/stories/LoadingButton.stories.tsx diff --git a/view/next-project/src/components/common/index.ts b/view/next-project/src/components/common/index.ts index 975e1c872..46838d5a2 100644 --- a/view/next-project/src/components/common/index.ts +++ b/view/next-project/src/components/common/index.ts @@ -23,6 +23,7 @@ export { default as Title } from './Title'; export { default as Tooltip } from './Tooltip'; export { default as UnderlinePrimaryButton } from './UnderlinePrimaryButton'; export { default as Label } from './Label'; +export { default as LoadingButton } from './LoadingButton'; export { default as BureauLabel } from './BureauLabel'; export { default as Header } from './Header'; export { default as SideNav } from './SideNav'; diff --git a/view/next-project/src/stories/LoadingButton.stories.tsx b/view/next-project/src/stories/LoadingButton.stories.tsx new file mode 100644 index 000000000..4c4b704ac --- /dev/null +++ b/view/next-project/src/stories/LoadingButton.stories.tsx @@ -0,0 +1,18 @@ +import { Meta } from '@storybook/react'; +import { LoadingButton } from '@components/common'; + +const meta: Meta = { + title: 'FinanSu/LoadingButton', + component: LoadingButton, + tags: ['autodocs'], + argTypes: {}, +}; + +export default meta; + +export const Primary = { + args: { + className: 'm-10', + children:

children

, + }, +}; From 36e12104c777f09c8ed6d4dec77ab05a0df6068c Mon Sep 17 00:00:00 2001 From: Ryotakobayash Date: Wed, 19 Jun 2024 01:59:26 +0900 Subject: [PATCH 17/24] [add]SideNav.stories.tsx --- .../src/stories/SideNav.stories.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 view/next-project/src/stories/SideNav.stories.tsx diff --git a/view/next-project/src/stories/SideNav.stories.tsx b/view/next-project/src/stories/SideNav.stories.tsx new file mode 100644 index 000000000..734cf569b --- /dev/null +++ b/view/next-project/src/stories/SideNav.stories.tsx @@ -0,0 +1,18 @@ +import { Meta } from '@storybook/react'; +import { SideNav } from '@components/common'; + +const meta: Meta = { + title: 'FinanSu/SideNav', + component: SideNav, + tags: ['autodocs'], + argTypes: {}, +}; + +export default meta; + +export const Primary = { + args: { + className: 'm-10', + children:

children

, + }, +}; From 3997daab23bb74fcb32f2699216f1a8e4016678a Mon Sep 17 00:00:00 2001 From: Ryotakobayash Date: Wed, 19 Jun 2024 01:59:50 +0900 Subject: [PATCH 18/24] [add]Stepper.stories.tsx --- .../src/stories/Stepper.stories.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 view/next-project/src/stories/Stepper.stories.tsx diff --git a/view/next-project/src/stories/Stepper.stories.tsx b/view/next-project/src/stories/Stepper.stories.tsx new file mode 100644 index 000000000..44c893412 --- /dev/null +++ b/view/next-project/src/stories/Stepper.stories.tsx @@ -0,0 +1,18 @@ +import { Meta } from '@storybook/react'; +import { Stepper } from '@components/common'; + +const meta: Meta = { + title: 'FinanSu/Stepper', + component: Stepper, + tags: ['autodocs'], + argTypes: {}, +}; + +export default meta; + +export const Primary = { + args: { + className: 'm-10', + children:

children

, + }, +}; From d7e7e449aaa64a0488344970eb99f96486a3b1cd Mon Sep 17 00:00:00 2001 From: Ryotakobayash Date: Wed, 19 Jun 2024 02:13:29 +0900 Subject: [PATCH 19/24] [add]Title.stories.tsx --- .../next-project/src/stories/Title.stories.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 view/next-project/src/stories/Title.stories.tsx diff --git a/view/next-project/src/stories/Title.stories.tsx b/view/next-project/src/stories/Title.stories.tsx new file mode 100644 index 000000000..21f1a32a4 --- /dev/null +++ b/view/next-project/src/stories/Title.stories.tsx @@ -0,0 +1,18 @@ +import { Meta } from '@storybook/react'; +import { Title } from '@components/common'; + +const meta: Meta = { + title: 'FinanSu/Title', + component: Title, + tags: ['autodocs'], + argTypes: {}, +}; + +export default meta; + +export const Primary = { + args: { + className: 'm-10', + children:

children

, + }, +}; From 4c5dca1ef1b3e61a9c9bd2e0ca5a4abdb38508a5 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Thu, 27 Jun 2024 00:14:57 +0900 Subject: [PATCH 20/24] =?UTF-8?q?[feat]=E4=B8=80=E8=88=AC=E3=83=A6?= =?UTF-8?q?=E3=83=BC=E3=82=B6=E3=83=BC=E3=81=AE=E5=8B=9F=E9=87=91=E3=83=9A?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=82=92=E9=96=B2=E8=A6=A7=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mysql/db/users.sql | 2 +- .../src/pages/fund_informations/index.tsx | 20 +++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/mysql/db/users.sql b/mysql/db/users.sql index e9a480bc2..13b474caf 100644 --- a/mysql/db/users.sql +++ b/mysql/db/users.sql @@ -21,4 +21,4 @@ INSERT into users (name, bureau_id, role_id) values ('技大太郎2', 6, 2); INSERT into users (name, bureau_id, role_id) values ('技大太郎3', 3, 3); -- 一般ユーザー(財務局員) -INSERT into users (name, bureau_id, role_id) values ('技大太郎4', 3, 1); +INSERT into users (name, bureau_id, role_id) values ('技大太郎4', 3, 4); diff --git a/view/next-project/src/pages/fund_informations/index.tsx b/view/next-project/src/pages/fund_informations/index.tsx index 9f82d5f0b..5f7c266aa 100644 --- a/view/next-project/src/pages/fund_informations/index.tsx +++ b/view/next-project/src/pages/fund_informations/index.tsx @@ -12,6 +12,7 @@ import OpenDeleteModalButton from '@components/fund_information/OpenDeleteModalB import OpenEditModalButton from '@components/fund_information/OpenEditModalButton'; import MainLayout from '@components/layout/MainLayout'; import { Department, FundInformation, Teacher, User, YearPeriod } from '@type/common'; +import Router from 'next/router'; interface FundInformationView { fundInformation: FundInformation; @@ -36,24 +37,16 @@ export const getServerSideProps = async () => { const periodsRes = await get(getPeriodsUrl); const getTeachersInformationURL = process.env.SSR_API_URI + '/teachers'; const getDepartmentURL = process.env.SSR_API_URI + '/departments'; - const getFundInformationURL = process.env.SSR_API_URI + '/fund_informations'; - const getFundInformationViewURL = - process.env.SSR_API_URI + - '/fund_informations/details/' + - (periodsRes ? String(periodsRes[periodsRes.length - 1].year) : String(date.getFullYear())); + const getUserURL = process.env.SSR_API_URI + '/users'; const teachersInformationRes = await get(getTeachersInformationURL); - const fundInformationRes = await get(getFundInformationURL); const departmentRes = await get(getDepartmentURL); - const fundInformationViewRes = await get(getFundInformationViewURL); const userRes = await get(getUserURL); return { props: { teachers: teachersInformationRes, departments: departmentRes, - fundInformation: fundInformationRes, - fundInformationView: fundInformationViewRes, users: userRes, yearPeriods: periodsRes, }, @@ -68,14 +61,15 @@ export default function FundInformations(props: Props) { const user = useRecoilValue(userAtom); const [currentUser, setCurrentUser] = useState(); + // 一般ユーザーの場合、購入申請へ飛ばす + user?.roleID === 1 && Router.push('/purchaseorders'); + useEffect(() => { setCurrentUser(user); }, []); // 募金一覧 - const [fundInformationViews, setFundInformationViews] = useState( - props.fundInformationView, - ); + const [fundInformationViews, setFundInformationViews] = useState(); //年の指定 const yearPeriods = props.yearPeriods; @@ -147,7 +141,7 @@ export default function FundInformations(props: Props) { const putURL = process.env.CSR_API_URI + '/fund_informations/' + id; await put(putURL, fundItem); - const newFundInformationViews = fundInformationViews.map((fundInformationView) => { + const newFundInformationViews = fundInformationViews?.map((fundInformationView) => { if (fundInformationView.fundInformation.id == id) { return { ...fundInformationView, From 3ae0322b71998860cb36af53ae65d29a009e3bab Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Wed, 26 Jun 2024 15:19:18 +0000 Subject: [PATCH 21/24] formatted by workflow --- view/next-project/src/pages/fund_informations/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/next-project/src/pages/fund_informations/index.tsx b/view/next-project/src/pages/fund_informations/index.tsx index 5f7c266aa..91b352ee8 100644 --- a/view/next-project/src/pages/fund_informations/index.tsx +++ b/view/next-project/src/pages/fund_informations/index.tsx @@ -1,5 +1,6 @@ import clsx from 'clsx'; import Head from 'next/head'; +import Router from 'next/router'; import { useEffect, useState, useMemo } from 'react'; import { useRecoilValue } from 'recoil'; import { userAtom } from '@/store/atoms'; @@ -12,7 +13,6 @@ import OpenDeleteModalButton from '@components/fund_information/OpenDeleteModalB import OpenEditModalButton from '@components/fund_information/OpenEditModalButton'; import MainLayout from '@components/layout/MainLayout'; import { Department, FundInformation, Teacher, User, YearPeriod } from '@type/common'; -import Router from 'next/router'; interface FundInformationView { fundInformation: FundInformation; From 73d5b84513e4e2ea7f0be3604b2d752080af68a5 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Thu, 27 Jun 2024 08:55:35 +0900 Subject: [PATCH 22/24] =?UTF-8?q?[fix]=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mysql/db/users.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql/db/users.sql b/mysql/db/users.sql index 13b474caf..fb57004da 100644 --- a/mysql/db/users.sql +++ b/mysql/db/users.sql @@ -20,5 +20,5 @@ INSERT into users (name, bureau_id, role_id) values ('技大太郎2', 6, 2); -- 財務局長 INSERT into users (name, bureau_id, role_id) values ('技大太郎3', 3, 3); --- 一般ユーザー(財務局員) +-- 財務局員 INSERT into users (name, bureau_id, role_id) values ('技大太郎4', 3, 4); From 1cd7e761b344b8e173aed0d791fe5811230f4fa2 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Thu, 27 Jun 2024 09:21:04 +0900 Subject: [PATCH 23/24] =?UTF-8?q?[feat]=E4=B8=80=E8=88=AC=E3=83=A6?= =?UTF-8?q?=E3=83=BC=E3=82=B6=E3=83=BC=E5=A0=B4=E5=90=88=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E3=82=92=E9=9D=9E=E8=A1=A8=E7=A4=BA=E3=81=AB=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view/next-project/src/pages/fund_informations/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/view/next-project/src/pages/fund_informations/index.tsx b/view/next-project/src/pages/fund_informations/index.tsx index 91b352ee8..700aad409 100644 --- a/view/next-project/src/pages/fund_informations/index.tsx +++ b/view/next-project/src/pages/fund_informations/index.tsx @@ -284,6 +284,7 @@ export default function FundInformations(props: Props) { {fundInformationViews && + user?.roleID !== 1 && fundInformationViews.map((fundViewItem: FundInformationView, index) => ( Date: Thu, 27 Jun 2024 10:48:03 +0900 Subject: [PATCH 24/24] =?UTF-8?q?[fix]=20=E5=88=86=E5=89=B2=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=9FState=E3=81=AE=E3=83=AA=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=AF=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../purchasereports/DetailEditModal.tsx | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/view/next-project/src/components/purchasereports/DetailEditModal.tsx b/view/next-project/src/components/purchasereports/DetailEditModal.tsx index c007b6061..08cba4a6f 100644 --- a/view/next-project/src/components/purchasereports/DetailEditModal.tsx +++ b/view/next-project/src/components/purchasereports/DetailEditModal.tsx @@ -18,12 +18,14 @@ export const DetailEditModal: React.FC<{ setIsOpen: () => void; onOpenInitial: () => void; }> = ({ purchaseReportId, setIsOpen, onOpenInitial }) => { - const [purchaseOrderId, setPurchaseOrderId] = useState(); const [expenses, setExpenses] = useState([]); - const [deadline, setDeadline] = useState(''); - const [userId, setUserId] = useState(0); - const [expenseID, setExpenseID] = useState(0); - const [finansuCheck, setFinansuCheck] = useState(false); + const [purchaseOrder, setPurchaseOrder] = useState({ + id: 0, + deadline: '', + userID: 0, + expenseID: 0, + financeCheck: false, + }); useEffect(() => { const fetchData = async () => { @@ -36,12 +38,8 @@ export const DetailEditModal: React.FC<{ const purchaseOrderRes: PurchaseOrder = await get( `${process.env.CSR_API_URI}/purchaseorders/${purchaseOrderId}`, ); - setPurchaseOrderId(purchaseOrderId); setExpenses(expensesRes); - setDeadline(purchaseOrderRes.deadline); - setUserId(purchaseOrderRes.userID); - setExpenseID(purchaseOrderRes.expenseID); - setFinansuCheck(purchaseOrderRes.financeCheck); + setPurchaseOrder(purchaseOrderRes); } catch (error) { console.error('Failed to fetch data:', error); } @@ -58,20 +56,18 @@ export const DetailEditModal: React.FC<{ }; const submit = async () => { - const submitData = { - id: purchaseOrderId, - deadline: deadline, - userID: userId, - expenseID: expenseID, - financeCheck: finansuCheck, - }; try { - const updatePurchaseOrderUrl = `${process.env.CSR_API_URI}/purchaseorders/${submitData.id}`; - await put(updatePurchaseOrderUrl, submitData); + const updatePurchaseOrderUrl = `${process.env.CSR_API_URI}/purchaseorders/${purchaseOrder.id}`; + await put(updatePurchaseOrderUrl, purchaseOrder); } finally { router.reload(); } }; + + const handleInputChange = (key: keyof PurchaseOrder, value: string | number) => { + setPurchaseOrder((prev) => ({ ...prev, [key]: value })); + }; + return (
@@ -84,10 +80,8 @@ export const DetailEditModal: React.FC<{

購入した局

setDeadline(e.target.value)} + value={purchaseOrder.deadline ? formatDate(purchaseOrder.deadline) : ''} + onChange={(e) => handleInputChange('deadline', e.target.value)} className='w-full' />