|
-
- 協賛活動の登録
+ 協賛活動の登録
{!isDone && <>{content(formData)}>}
{isDone ? (
<>
diff --git a/view/next-project/src/components/teacher/AddModal.tsx b/view/next-project/src/components/teacher/AddModal.tsx
index e6cccdabe..b04cd2b30 100644
--- a/view/next-project/src/components/teacher/AddModal.tsx
+++ b/view/next-project/src/components/teacher/AddModal.tsx
@@ -1,9 +1,9 @@
import { useRouter } from 'next/router';
-import React, { Dispatch, FC, SetStateAction, useState } from 'react';
+import { Dispatch, FC, SetStateAction, useState } from 'react';
import { RiCloseCircleLine } from 'react-icons/ri';
import { post } from '@api/teachers';
-import { PrimaryButton, Modal, Select, Input } from '@components/common';
+import { Input, Modal, PrimaryButton, Radio, Select } from '@components/common';
import { Department, Teacher } from '@type/common';
interface ModalProps {
@@ -52,7 +52,7 @@ const OpenAddModal: FC = (props) => {
教員の登録
-
+
教員名
@@ -81,28 +81,22 @@ const OpenAddModal: FC = (props) => {
ブラックリスト
-
- setIsBlack('true')}
- />
-
-
-
- setIsBlack('false')}
- />
-
-
+ setIsBlack('true')}
+ >
+ はい
+
+ setIsBlack('false')}
+ >
+ いいえ
+
備考
diff --git a/view/next-project/src/components/teacher/EditModal.tsx b/view/next-project/src/components/teacher/EditModal.tsx
index c7a563174..a0d856eff 100644
--- a/view/next-project/src/components/teacher/EditModal.tsx
+++ b/view/next-project/src/components/teacher/EditModal.tsx
@@ -3,7 +3,7 @@ import React, { Dispatch, SetStateAction, useState } from 'react';
import { RiCloseCircleLine } from 'react-icons/ri';
import { put } from '@api/teachers';
-import { PrimaryButton, Modal, Input, Select } from '@components/common';
+import { Input, Modal, PrimaryButton, Radio, Select } from '@components/common';
import { Department, Teacher } from '@type/common';
interface ModalProps {
@@ -46,7 +46,7 @@ export default function FundInformationEditModal(props: ModalProps) {
教員情報の編集
-
+
教員名
@@ -75,28 +75,22 @@ export default function FundInformationEditModal(props: ModalProps) {
ブラックリスト
-
- setFormData({ ...formData, isBlack: true })}
- />
-
-
-
- setFormData({ ...formData, isBlack: false })}
- />
-
-
+ setFormData({ ...formData, isBlack: true })}
+ >
+ はい
+
+ setFormData({ ...formData, isBlack: false })}
+ >
+ いいえ
+
備考
diff --git a/view/next-project/src/hooks/useToast.tsx b/view/next-project/src/hooks/useToast.tsx
new file mode 100644
index 000000000..439e1cfcc
--- /dev/null
+++ b/view/next-project/src/hooks/useToast.tsx
@@ -0,0 +1,120 @@
+import React, { createContext, useCallback, useContext, useState } from 'react';
+import {
+ IoMdCheckmarkCircle,
+ IoMdCloseCircle,
+ IoMdInformationCircle,
+ IoMdWarning,
+} from 'react-icons/io';
+
+type ToastStatus = 'success' | 'error' | 'warning' | 'info';
+
+interface Toast {
+ id: string;
+ title: string;
+ description?: string;
+ status: ToastStatus;
+ duration?: number;
+ isClosable?: boolean;
+}
+
+interface ToastContextValue {
+ addToast: (toast: Omit ) => void;
+}
+
+const ToastContext = createContext(null);
+
+const statusConfig: Record = {
+ success: {
+ bgColor: 'bg-green-500',
+ icon: ,
+ },
+ error: {
+ bgColor: 'bg-accent-1',
+ icon: ,
+ },
+ warning: {
+ bgColor: 'bg-yellow-500',
+ icon: ,
+ },
+ info: {
+ bgColor: 'bg-primary-1',
+ icon: ,
+ },
+};
+
+export function ToastProvider({ children }: { children: React.ReactNode }) {
+ const [toasts, setToasts] = useState([]);
+
+ const addToast = useCallback((toast: Omit) => {
+ const id = Math.random().toString(36).substr(2, 9);
+ const newToast: Toast = { ...toast, id };
+
+ setToasts((prev) => [...prev, newToast]);
+
+ // Auto-remove after duration
+ const duration = toast.duration ?? 5000;
+ setTimeout(() => {
+ setToasts((prev) => prev.filter((t) => t.id !== id));
+ }, duration);
+ }, []);
+
+ const removeToast = useCallback((id: string) => {
+ setToasts((prev) => prev.filter((t) => t.id !== id));
+ }, []);
+
+ return (
+
+ {children}
+
+ {toasts.map((toast) => {
+ const config = statusConfig[toast.status];
+ return (
+
+ {config.icon}
+
+ {toast.title}
+ {toast.description && (
+ {toast.description}
+ )}
+
+ {toast.isClosable !== false && (
+
+ )}
+
+ );
+ })}
+
+
+ );
+}
+
+export function useToast() {
+ const context = useContext(ToastContext);
+
+ // Return a function that matches Chakra's useToast API
+ // When called outside of context, return a no-op function
+ const toast = useCallback(
+ (options: Omit) => {
+ if (context) {
+ context.addToast(options);
+ } else {
+ console.warn('useToast must be used within a ToastProvider');
+ }
+ },
+ [context],
+ );
+
+ return toast;
+}
+
+export default useToast;
diff --git a/view/next-project/src/pages/create_purchase_report/index.tsx b/view/next-project/src/pages/create_purchase_report/index.tsx
index 4e6e12d42..5371e861e 100644
--- a/view/next-project/src/pages/create_purchase_report/index.tsx
+++ b/view/next-project/src/pages/create_purchase_report/index.tsx
@@ -1,19 +1,15 @@
+import { useRouter } from 'next/router';
+import React, { useEffect, useRef, useState } from 'react';
+
import {
- Box,
- Button,
- Center,
FormControl,
FormErrorMessage,
FormLabel,
- Input,
+ PrimaryButton,
Select,
Spinner,
- VStack,
-} from '@chakra-ui/react';
-import { useRouter } from 'next/router';
-import React, { useEffect, useRef, useState } from 'react';
-
-import { PrimaryButton, Title } from '@/components/common';
+ Title,
+} from '@/components/common';
import FileUploadField from '@/components/create_purchase_report/FileUploadField';
import FormField from '@/components/create_purchase_report/FormField';
import { usePurchaseReportForm } from '@/components/create_purchase_report/usePurchaseReportForm';
@@ -110,14 +106,14 @@ const PurchaseReportPage = () => {
if (isEditMode && isReportDataLoading) {
return (
-
-
+
+
);
}
@@ -126,21 +122,25 @@ const PurchaseReportPage = () => {
return (
-
-
+
{/* フォームアクション */}
-
+
- {isProcessing ? : null}
+ {isProcessing ? : null}
{isEditMode ? '更新する' : '登録する'}
-
+
-
-
-
+
+
+
);
};
diff --git a/view/next-project/src/pages/fund_informations/[id]/edit.tsx b/view/next-project/src/pages/fund_informations/[id]/edit.tsx
index 0383f409f..3a272ca1c 100644
--- a/view/next-project/src/pages/fund_informations/[id]/edit.tsx
+++ b/view/next-project/src/pages/fund_informations/[id]/edit.tsx
@@ -1,27 +1,22 @@
+import { useRouter } from 'next/router';
+import React, { useEffect, useState } from 'react';
+
import {
- Box,
- Button,
- Center,
FormControl,
FormErrorMessage,
FormLabel,
- Input,
+ PrimaryButton,
Radio,
RadioGroup,
Select,
Spinner,
- Stack,
- useToast,
- VStack,
-} from '@chakra-ui/react';
-import { useRouter } from 'next/router';
-import React, { useEffect, useState } from 'react';
-
-import { PrimaryButton, Title } from '@/components/common';
+ Title,
+} from '@/components/common';
import { useFundInformations } from '@/components/fund_information/useFundInformations';
import MainLayout from '@/components/layout/MainLayout';
import { Income } from '@/generated/model/income';
import { IncomeReceiveOption } from '@/generated/model/incomeReceiveOption';
+import { useToast } from '@/hooks/useToast';
import { notoSansJP } from '@/pages/_app';
interface FormFieldProps {
@@ -216,12 +211,12 @@ const EditFundInformation = () => {
if (isLoading) {
return (
-
-
+
);
}
@@ -229,27 +224,27 @@ const EditFundInformation = () => {
if (hookError) {
return (
-
-
+
+
収入データの取得中にエラーが発生しました。ページを更新してください。
-
-
+
+
);
}
return (
-
-
+
-
+
- {isLoading ? : null}
+ {isLoading ? : null}
更新する
-
+
-
-
-
+
+
+
);
};
diff --git a/view/next-project/src/pages/fund_informations/create/index.tsx b/view/next-project/src/pages/fund_informations/create/index.tsx
index d2e88dde8..eecfb2d1e 100644
--- a/view/next-project/src/pages/fund_informations/create/index.tsx
+++ b/view/next-project/src/pages/fund_informations/create/index.tsx
@@ -1,4 +1,3 @@
-import { Box, useToast } from '@chakra-ui/react';
import Head from 'next/head';
import { useState } from 'react';
@@ -9,6 +8,7 @@ import {
useFundInformations,
} from '@/components/fund_information/useFundInformations';
import MainLayout from '@/components/layout/MainLayout';
+import { useToast } from '@/hooks/useToast';
import { notoSansJP } from '@/pages/_app';
const CreateFundInformation = () => {
@@ -64,10 +64,10 @@ const CreateFundInformation = () => {
収入報告作成
-
-
+
{error && {error} }
@@ -78,8 +78,8 @@ const CreateFundInformation = () => {
incomeTypes={incomeTypes}
isIncomeTypesLoading={isLoading}
/>
-
-
+
+
);
};
From 2b3468e758c745e57ab283a658305ceddc74f1af Mon Sep 17 00:00:00 2001
From: TkymHrt <23.h.takayama.nutfes@gmail.com>
Date: Tue, 13 Jan 2026 17:54:40 +0900
Subject: [PATCH 3/7] =?UTF-8?q?refactor:=20ESLint=E3=81=AEWarning=E3=81=AB?=
=?UTF-8?q?=E5=AF=BE=E5=87=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Consolidated import statements for better readability in AddBudgetManagementModal, BudgetManagement, DeleteBudgetManagementModal, EditBudgetManagementModal, and other components.
- Enhanced error handling to provide clearer messages in case of failures in AddBudgetManagementModal, DeleteBudgetManagementModal, and EditBudgetManagementModal.
- Updated RadioGroup and SearchSelect components to improve type safety and ensure proper prop handling.
- Replaced ![]() tags with from 'next/image' for better performance and optimization in DetailPage2 and other components.
- Added missing dependencies to useEffect hooks to prevent potential stale closures in various components.
- Removed unnecessary variables and improved function signatures for clarity in multiple files.
- Updated API handler in receipts.tsx for better error handling and code organization.
---
.../AddBudgetManagementModal.tsx | 18 ++---
.../budget_managements/BudgetManagement.tsx | 4 +-
.../DeleteBudgetManagementModal.tsx | 12 ++--
.../EditBudgetManagementModal.tsx | 14 ++--
.../common/BureauLabel/BureauLabel.tsx | 2 +-
.../src/components/common/Modal.tsx | 2 +-
.../common/RadioGroup/RadioGroup.tsx | 18 +++--
.../common/SearchSelect/SearchSelect.tsx | 6 +-
.../purchasereports/DeleteModal.tsx | 5 +-
.../purchasereports/DetailPage2.tsx | 19 ++++--
.../purchasereports/OpenEditModalButton.tsx | 3 +-
.../PurchaseOrderListModal.tsx | 3 +-
.../PurchaseReportAddModal.tsx | 1 +
.../PurchaseReportConfirmModal.tsx | 3 -
.../PurchaseReportItemNumModal.tsx | 1 +
.../purchasereports/UploadFileModal.tsx | 16 +++--
.../sponsoractivities/DetailPage2.tsx | 24 ++++---
.../sponsoractivities/EditModal.tsx | 4 ++
.../sponsoractivities/FilterModal.tsx | 12 ++--
.../SponsorActivitiesAddModal.tsx | 4 ++
.../src/components/yearperiods/AddModal.tsx | 2 -
view/next-project/src/pages/api/receipts.tsx | 67 ++++++++++---------
.../src/pages/reset_password/[id]/index.tsx | 6 +-
.../pages/reset_password/request/index.tsx | 4 +-
.../src/pages/sponsoractivities/index.tsx | 2 +
.../next-project/src/pages/teachers/index.tsx | 4 +-
view/next-project/src/pages/users/index.tsx | 2 +-
.../src/pages/yearperiods/index.tsx | 2 +
.../sponsors/SponsorEditModal.stories.tsx | 4 +-
.../src/utils/createSponsorActivityPdf.ts | 17 +----
30 files changed, 151 insertions(+), 130 deletions(-)
diff --git a/view/next-project/src/components/budget_managements/AddBudgetManagementModal.tsx b/view/next-project/src/components/budget_managements/AddBudgetManagementModal.tsx
index f32a76e12..1ca3d1ffa 100644
--- a/view/next-project/src/components/budget_managements/AddBudgetManagementModal.tsx
+++ b/view/next-project/src/components/budget_managements/AddBudgetManagementModal.tsx
@@ -1,12 +1,9 @@
-import { useRouter } from 'next/router';
-import * as React from 'react';
-import { Dispatch, SetStateAction, useState } from 'react';
-import { FC } from 'react';
+import { Dispatch, FC, SetStateAction, useState } from 'react';
import { RiCloseCircleLine } from 'react-icons/ri';
-import { usePostFestivalItems, usePostFinancialRecords, usePostDivisions } from '@/generated/hooks';
+import { usePostDivisions, usePostFestivalItems, usePostFinancialRecords } from '@/generated/hooks';
import { Year } from '@/type/common';
-import { PrimaryButton, Input, Modal } from '@components/common';
+import { Input, Modal, PrimaryButton } from '@components/common';
import formatNumber from '../common/Formatter';
@@ -36,8 +33,6 @@ const AddBudgetManagementModal: FC = (props) => {
const [festivalItemName, setFestivalItemName] = useState('');
const [amount, setAmount] = useState(null);
- const router = useRouter();
-
const closeModal = () => {
props.setShowModal(false);
};
@@ -97,9 +92,10 @@ const AddBudgetManagementModal: FC = (props) => {
if (onSuccess) {
onSuccess();
}
- } catch (error: any) {
- console.error('登録エラー:', error.message);
- alert(`登録エラー: ${error.message}`);
+ } catch (error: unknown) {
+ const errorMessage = error instanceof Error ? error.message : '不明なエラー';
+ console.error('登録エラー:', errorMessage);
+ alert(`登録エラー: ${errorMessage}`);
}
};
diff --git a/view/next-project/src/components/budget_managements/BudgetManagement.tsx b/view/next-project/src/components/budget_managements/BudgetManagement.tsx
index 686ccc88b..92afdd301 100644
--- a/view/next-project/src/components/budget_managements/BudgetManagement.tsx
+++ b/view/next-project/src/components/budget_managements/BudgetManagement.tsx
@@ -44,7 +44,7 @@ export default function BudgetManagement(props: Props) {
division_id: divisionId ?? undefined,
};
- const [selectedYear, setSelectedYear] = useState(
+ const [selectedYear, _setSelectedYear] = useState(
// 本番環境では、2025のyear_idを1にします
years ? years[years.length - 1] : { id: 1, year: 2025 },
);
@@ -148,7 +148,7 @@ export default function BudgetManagement(props: Props) {
}
}, [financialRecordId, divisionId, selectedYear.id, financialRecords, divisions]);
- const handleRowClick = (item: any) => {
+ const handleRowClick = (item: { id?: number }) => {
if (financialRecordId === null) {
setQueryState({ financialRecordId: item.id, divisionId: null, festivalItemId: null });
return;
diff --git a/view/next-project/src/components/budget_managements/DeleteBudgetManagementModal.tsx b/view/next-project/src/components/budget_managements/DeleteBudgetManagementModal.tsx
index 0f344af77..fb9b6f5d0 100644
--- a/view/next-project/src/components/budget_managements/DeleteBudgetManagementModal.tsx
+++ b/view/next-project/src/components/budget_managements/DeleteBudgetManagementModal.tsx
@@ -1,14 +1,13 @@
import * as React from 'react';
-import { Dispatch, SetStateAction } from 'react';
-import { FC } from 'react';
+import { Dispatch, FC, SetStateAction } from 'react';
import { RiCloseCircleLine } from 'react-icons/ri';
import {
- useDeleteFinancialRecordsId,
useDeleteDivisionsId,
useDeleteFestivalItemsId,
+ useDeleteFinancialRecordsId,
} from '@/generated/hooks';
-import { PrimaryButton, Modal } from '@components/common';
+import { Modal, PrimaryButton } from '@components/common';
export interface ModalProps {
setShowModal: Dispatch>;
@@ -54,8 +53,9 @@ const DeleteBudgetManagementModal: FC = (props) => {
if (onSuccess) {
onSuccess();
}
- } catch (error: any) {
- alert(`削除エラー: ${error.message}`);
+ } catch (error: unknown) {
+ const errorMessage = error instanceof Error ? error.message : '不明なエラー';
+ alert(`削除エラー: ${errorMessage}`);
}
};
diff --git a/view/next-project/src/components/budget_managements/EditBudgetManagementModal.tsx b/view/next-project/src/components/budget_managements/EditBudgetManagementModal.tsx
index 31625da17..dae2bfcd2 100644
--- a/view/next-project/src/components/budget_managements/EditBudgetManagementModal.tsx
+++ b/view/next-project/src/components/budget_managements/EditBudgetManagementModal.tsx
@@ -1,17 +1,16 @@
import * as React from 'react';
-import { Dispatch, SetStateAction, useEffect, useState } from 'react';
-import { FC } from 'react';
+import { Dispatch, FC, SetStateAction, useEffect, useState } from 'react';
import { RiCloseCircleLine } from 'react-icons/ri';
import {
- useGetFinancialRecordsId,
useGetDivisionsId,
useGetFestivalItemsId,
- usePutFinancialRecordsId,
+ useGetFinancialRecordsId,
usePutDivisionsId,
usePutFestivalItemsId,
+ usePutFinancialRecordsId,
} from '@/generated/hooks';
-import { PrimaryButton, Input, Modal } from '@components/common';
+import { Input, Modal, PrimaryButton } from '@components/common';
import formatNumber from '../common/Formatter';
@@ -91,8 +90,9 @@ const EditBudgetManagementModal: FC = (props) => {
if (onSuccess) {
onSuccess();
}
- } catch (error: any) {
- alert(`登録エラー: ${error.message}`);
+ } catch (error: unknown) {
+ const errorMessage = error instanceof Error ? error.message : '不明なエラー';
+ alert(`登録エラー: ${errorMessage}`);
}
};
diff --git a/view/next-project/src/components/common/BureauLabel/BureauLabel.tsx b/view/next-project/src/components/common/BureauLabel/BureauLabel.tsx
index d7952a246..2d937218c 100644
--- a/view/next-project/src/components/common/BureauLabel/BureauLabel.tsx
+++ b/view/next-project/src/components/common/BureauLabel/BureauLabel.tsx
@@ -11,7 +11,7 @@ const BureauLabel: React.FC = (props) => {
const bureau = BUREAUS_WITH_EN.find((bureau) => bureau.name === bureauName);
if (!bureau) return 'other';
return bureau.name_en;
- }, []);
+ }, [bureauName]);
return (
|