visuddhinanda 1 год назад
Родитель
Сommit
314a531352
1 измененных файлов с 21 добавлено и 5 удалено
  1. 21 5
      dashboard/src/components/template/Wbw/WbwParentIcon.tsx

+ 21 - 5
dashboard/src/components/template/Wbw/WbwParentIcon.tsx

@@ -1,21 +1,37 @@
 import { Tooltip } from "antd";
 import { IWbw } from "./WbwWord";
 import { Dict2SvgIcon } from "../../../assets/icon";
+import { errorClass } from "./WbwMeaning";
 
 interface IWidget {
   data: IWbw;
+  answer?: IWbw;
 }
-const WbwParentIcon = ({ data }: IWidget) => {
-  return data.parent?.value ? (
+const WbwParentIcon = ({ data, answer }: IWidget) => {
+  const iconEmpty = answer?.parent ? <Dict2SvgIcon /> : <></>;
+  let title: string | null | undefined = "空";
+  if (typeof data.parent?.value === "string" && data.parent?.value.length > 0) {
+    title = data.parent?.value;
+  }
+  const icon = data.parent?.value ? (
     data.parent.value.trim() !== "" ? (
-      <Tooltip title={data.parent?.value}>
+      <Tooltip title={title}>
         <Dict2SvgIcon />
       </Tooltip>
     ) : (
-      <></>
+      iconEmpty
     )
   ) : (
-    <></>
+    iconEmpty
+  );
+
+  const errClass = answer
+    ? errorClass("parent", data.parent?.value, answer?.parent?.value)
+    : "";
+  return (
+    <span className={"wbw_word_item" + errClass}>
+      <span className="icon">{icon}</span>
+    </span>
   );
 };