Skip to content

Commit

Permalink
授業編集時に勝手に空文字が担当教員欄に入りバリデーションエラーになるバグを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
HosokawaR committed Apr 15, 2024
1 parent 00f91f9 commit 0e61e16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/infrastructure/api/converters/instructor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { removeDuplicate } from "~/utils";

export const apiToInstructors = (apiInstructor: string): string[] => {
// [Workaround]
// 担当教員がいない場合に BE は空文字で返すが、FE は空文字をバリデーションエラーとして扱うため、空配列に変換する
if (apiInstructor === "") return [];
return removeDuplicate(
apiInstructor.split(/,|、/).map((instructor) => instructor.trim())
);
Expand Down
1 change: 1 addition & 0 deletions src/presentation/presenters/instructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const instructorsToDisplay = (instructors: string[]): string => {
};

export const validateInstructors = (instructors: string[]): boolean => {
console.log("🚀 ~ validateInstructors ~ instructors:", instructors)
if (instructors.some((instructor) => instructor === "")) return false;
if (new Set(instructors).size !== instructors.length) return false;

Expand Down

0 comments on commit 0e61e16

Please sign in to comment.