From d04bfe27fd88159f2b1c6a981f26d4dc9cd0c37c Mon Sep 17 00:00:00 2001
From: chakkun1121 <99847806+chakkun1121@users.noreply.github.com>
Date: Mon, 29 Jan 2024 08:30:03 +0900
Subject: [PATCH] v1.0.5
---
@types/cardResult.ts | 15 +++-----
@types/flashCardSettings.ts | 5 ++-
app/(app)/app/ImportForm.tsx | 3 +-
app/(app)/flashCard/_card/answer.tsx | 9 +++--
app/(app)/flashCard/_card/card.tsx | 17 +++------
app/(app)/flashCard/_card/main.tsx | 7 ++--
app/(app)/flashCard/cardResult.tsx | 4 +-
app/(app)/flashCard/flashCardHome.tsx | 54 +++++++++++++--------------
app/(app)/flashCard/main.tsx | 6 +--
9 files changed, 57 insertions(+), 63 deletions(-)
diff --git a/@types/cardResult.ts b/@types/cardResult.ts
index 862c6ff..6d4c60c 100644
--- a/@types/cardResult.ts
+++ b/@types/cardResult.ts
@@ -1,22 +1,19 @@
+import { flashCardMode } from "./flashCardSettings";
+
// 保存するファイル名は result/<本体のファイルID>.jsonとすること
export type cardResult = {
fileInfo: {
id: string;
};
check: {
- en2ja?: {
- id: string;
- checked: boolean;
- }[];
- ja2en?: {
- id: string;
- checked: boolean;
- }[];
+ //英語→日本語
+ ["en-ja"]?: string[]; //チェック済みのカードのID 英語→日本語
+ ["ja-en"]?: string[]; //チェック済みのカードのID 日本語→英語
};
results: {
//キーボード入力での解答時のみ使用
date: string;
- mode?: "en2ja" | "ja2en"; //初期値は"en2ja"
+ mode?: flashCardMode; //初期値は"ja-en"
cardsResult: {
id: string;
result: boolean; //正解かどうか
diff --git a/@types/flashCardSettings.ts b/@types/flashCardSettings.ts
index 3ec4be8..847abdc 100644
--- a/@types/flashCardSettings.ts
+++ b/@types/flashCardSettings.ts
@@ -4,12 +4,13 @@ export type flashCardSettings =
isAnswerWithKeyboard: false;
removeChecked?: boolean;
questionCount?: number;
- mode: "en2ja" | "ja2en";
+ mode: flashCardMode;
}
| {
isRandom: boolean;
isAnswerWithKeyboard: true;
removeChecked: boolean;
questionCount?: number;
- mode: "en2ja";
+ mode: "ja-en";
};
+export type flashCardMode = "ja-en" | "en-ja";
diff --git a/app/(app)/app/ImportForm.tsx b/app/(app)/app/ImportForm.tsx
index ddc080e..ebb1293 100644
--- a/app/(app)/app/ImportForm.tsx
+++ b/app/(app)/app/ImportForm.tsx
@@ -5,6 +5,7 @@ import React, { MouseEventHandler, useState } from "react";
import { wayakuFile2file } from "./_library/wayaku";
import { uploadFile } from "./_library/uploadFile";
import { csvToFileContent } from "./_library/csvToFileContent";
+import { flashCardMode } from "@/@types/flashCardSettings";
export default function ImportForm({
close,
@@ -32,7 +33,7 @@ export default function ImportForm({
setTitle(title);
close();
}
- async function importFromCsv(mode?: "en-ja" | "ja-en") {
+ async function importFromCsv(mode?: flashCardMode) {
/**
* ファイル形式(ヘッダー行は基本的になしだが、含まれている場合はユーザーによって除去してもらう)
* 1. |表|裏|
diff --git a/app/(app)/flashCard/_card/answer.tsx b/app/(app)/flashCard/_card/answer.tsx
index 6d9cbf5..912c4f7 100644
--- a/app/(app)/flashCard/_card/answer.tsx
+++ b/app/(app)/flashCard/_card/answer.tsx
@@ -2,6 +2,7 @@ import { fileType } from "@/@types/fileType";
import { useState } from "react";
import { SpeechButton } from "./speechButton";
import { useHotkeys } from "react-hotkeys-hook";
+import { flashCardMode } from "@/@types/flashCardSettings";
export default function Answer({
mode,
@@ -10,7 +11,7 @@ export default function Answer({
setIsChecked,
isAnswerWithKeyboard,
}: {
- mode: "en2ja" | "ja2en";
+ mode: flashCardMode;
currentQuestion: fileType["content"][0];
isChecked: boolean;
setIsChecked: (isChecked: boolean) => void;
@@ -66,14 +67,14 @@ export default function Answer({
{isShowAnswer && (
- {mode == "en2ja" ? currentQuestion?.en : currentQuestion?.ja}
+ {mode == "ja-en" ? currentQuestion?.en : currentQuestion?.ja}
)}
) : isShowAnswer ? (
- {mode == "en2ja" ? currentQuestion?.en : currentQuestion?.ja}
+ {mode == "ja-en" ? currentQuestion?.en : currentQuestion?.ja}
) : (