Explorar o código

提取函数 relationWordId

visuddhinanda hai 1 ano
pai
achega
b41a7c502e
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      dashboard/src/components/template/Wbw/WbwRelationAdd.tsx

+ 6 - 1
dashboard/src/components/template/Wbw/WbwRelationAdd.tsx

@@ -4,6 +4,11 @@ import { useAppSelector } from "../../../hooks";
 import { add, relationAddParam } from "../../../reducers/relation-add";
 import store from "../../../store";
 import { IWbw } from "./WbwWord";
+
+export const relationWordId = (word: IWbw) => {
+  return `${word.book}-${word.para}-` + word.sn.join("-");
+};
+
 interface IWidget {
   data: IWbw;
 }
@@ -32,7 +37,7 @@ const WbwRelationAddWidget = ({ data }: IWidget) => {
                   book: addParam.book,
                   para: addParam.para,
                   src_sn: addParam?.src_sn,
-                  target_id: `${data.book}-${data.para}-` + data.sn.join("-"),
+                  target_id: relationWordId(data),
                   target_spell: data.word.value,
                   command: "apply",
                 })