Skip to content

Commit

Permalink
[fix]年度が2024に固定されていたので、currentYearに設定
Browse files Browse the repository at this point in the history
  • Loading branch information
Kubosaka committed Jul 8, 2024
1 parent 55cd1c8 commit 1da9afb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ interface ModalProps {
departments: Department[];
users: User[];
currentUser?: User;
currentYear: string;
}

const OpenAddModal: FC<ModalProps> = (props) => {
const [user] = useRecoilState(userAtom);
const { teachers } = props;
const { teachers, currentYear } = props;

const router = useRouter();
const [departmentID, setDepartmentID] = useState<number | string>(1);
Expand Down Expand Up @@ -101,7 +102,8 @@ const OpenAddModal: FC<ModalProps> = (props) => {
const isValid = !formData.userID || formData.teacherID == 0;

async function getRegisteredTeachers() {
const registeredTeachersURL = process.env.CSR_API_URI + '/teachers/fundRegistered/2024';
const registeredTeachersURL =
process.env.CSR_API_URI + `/teachers/fundRegistered/${currentYear}`;
const resData = await get(registeredTeachersURL);
setRegisteredTeacherIds(resData);
const firstNotRegisteredTeacher = teachers.find((teacher) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ interface ModalProps {
users: User[];
departments: Department[];
fundInformation: FundInformation;
currentYear: string;
}

export default function EditModal(props: ModalProps) {
const router = useRouter();

const { teachers, fundInformation } = props;
const { teachers, fundInformation, currentYear } = props;

const [formData, setFormData] = useState<FundInformation>({
id: fundInformation.id,
Expand Down Expand Up @@ -101,7 +102,8 @@ export default function EditModal(props: ModalProps) {
}, [bureauId]);

async function getRegisteredTeachers() {
const registeredTeachersURL = process.env.CSR_API_URI + '/teachers/fundRegistered/2024';
const registeredTeachersURL =
process.env.CSR_API_URI + `/teachers/fundRegistered/${currentYear}`;
const resData = await get(registeredTeachersURL);
setRegisteredTeacherIds(resData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface Props {
departments: Department[];
users: User[];
currentUser?: User;
currentYear: string;
}

export const OpenAddModalButton = (props: Props) => {
Expand All @@ -32,6 +33,7 @@ export const OpenAddModalButton = (props: Props) => {
departments={props.departments}
users={props.users}
currentUser={props.currentUser}
currentYear={props.currentYear}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface Props {
users: User[];
fundInformation: FundInformation;
isDisabled: boolean;
currentYear: string;
}

export const OpenAddModalButton = (props: Props) => {
Expand All @@ -30,6 +31,7 @@ export const OpenAddModalButton = (props: Props) => {
departments={props.departments}
users={props.users}
fundInformation={props.fundInformation}
currentYear={props.currentYear}
/>
)}
</>
Expand Down
11 changes: 8 additions & 3 deletions view/next-project/src/pages/fund_informations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ export default function FundInformations(props: Props) {

//年の指定
const yearPeriods = props.yearPeriods;
const [selectedYear, setSelectedYear] = useState<string>(
yearPeriods ? String(yearPeriods[yearPeriods.length - 1].year) : String(date.getFullYear()),
);
const currentYear = yearPeriods
? String(yearPeriods[yearPeriods.length - 1].year)
: String(date.getFullYear());
const [selectedYear, setSelectedYear] = useState<string>(currentYear);

//年度を指定して募金を取得し、fundInformationViewsにset
const getFundInformations = async () => {
Expand Down Expand Up @@ -185,6 +186,7 @@ export default function FundInformations(props: Props) {
departments={departments}
users={users}
currentUser={currentUser}
currentYear={currentYear}
>
学内募金登録
</OpenAddModalButton>
Expand All @@ -195,6 +197,7 @@ export default function FundInformations(props: Props) {
departments={departments}
users={users}
currentUser={currentUser}
currentYear={currentYear}
></OpenAddModalButton>
</div>
</div>
Expand Down Expand Up @@ -241,6 +244,7 @@ export default function FundInformations(props: Props) {
users={users}
departments={departments}
isDisabled={isDisabled(fundViewItem)}
currentYear={currentYear}
/>
<OpenDeleteModalButton
id={fundViewItem.fundInformation.id ? fundViewItem.fundInformation.id : 0}
Expand Down Expand Up @@ -358,6 +362,7 @@ export default function FundInformations(props: Props) {
users={users}
departments={departments}
isDisabled={isDisabled(fundViewItem)}
currentYear={currentYear}
/>
<OpenDeleteModalButton
id={fundViewItem.fundInformation.id ? fundViewItem.fundInformation.id : 0}
Expand Down

0 comments on commit 1da9afb

Please sign in to comment.