Skip to content

Commit

Permalink
🐞 fix(dict): dict editable check
Browse files Browse the repository at this point in the history
  • Loading branch information
summerscar committed Nov 6, 2024
1 parent be6a91f commit cc2e096
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions app/actions/user-dict-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ const addWordsToUserDictAction = async (dictId: string, words: string[]) => {
const getDictList = async (dictId: string) => {
// TODO: 权限做 增删改
const ctx = keystoneContext.sudo();
const res = (await ctx.query.Dict.findOne({
where: { id: dictId },
query: "list { id name trans example exTrans }",
})) as { list: Dict } | null;
return toPlainObject(res?.list || []);
const res = (await ctx.query.DictItem.findMany({
where: { dict: { some: { id: { equals: dictId } } } },
query: "id name trans example exTrans",
orderBy: { createdAt: "asc" },
})) as Dict;
return toPlainObject(res);
};

const importDictItemToUserDict = async (dictId: string, JSONString: string) => {
Expand Down
6 changes: 3 additions & 3 deletions app/components/home-drawer/dict-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const DictMenu = ({
isUserDict: boolean;
isLocalDict: boolean;
}) => {
const { isLogin } = useUser();
const { isLogin, isAdmin } = useUser();
const tHome = useTranslations("Home");
const router = useRouter();
const tDict = useTranslations("Dict");
Expand All @@ -67,7 +67,7 @@ const DictMenu = ({
};

const createWord = async () => {
const word = prompt(tHome("createWord"), tHome("exampleWord"));
const word = prompt(`✨ ${tHome("createWord")}`, tHome("exampleWord"));
if (word) {
const removeInfoToast = createLoadingToast(tHome("generating"));

Expand Down Expand Up @@ -147,7 +147,7 @@ const DictMenu = ({
removeInfoToast();
createSuccessToast("success");
};
const canEdit = isUserDict || dictId === Dicts.local;
const canEdit = isAdmin || isUserDict || dictId === Dicts.local;
return (
<div className="sticky top-2 z-10 bg-base-200 rounded-xl mb-3 shadow-md flex justify-between items-center p-1 max-w-full">
<div className="pl-3 flex items-center *:mx-1 *:inline-block *:cursor-pointer *:select-none">
Expand Down
2 changes: 1 addition & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Index": {
"title": "Korean Studio",
"title": "Let's Speak Korean",
"description": "Korean Language Learning",
"keywords": "Korean, Korean Language, Korean Learning, Korean Studio"
},
Expand Down
2 changes: 1 addition & 1 deletion messages/ja.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Index": {
"title": "韓国語教室",
"title": "韓国語を話しましょう",
"description": "Korean Language Learning",
"keywords": "Korean, Korean Language, Korean Learning, Korean Studio"
},
Expand Down
2 changes: 1 addition & 1 deletion messages/zh-CN.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Index": {
"title": "韩语教室",
"title": "让我们说韩语",
"description": "欢迎来到我们的网站,您的一站式韩语学习平台。无论您是初学者还是进阶学者,我们为您提供丰富的学习资源,包括韩语打字练习、词汇和语法学习、真题训练等功能。通过我们的互动式课程和模拟考试,您可以全面提升韩语听说读写能力。立即加入我们,开启您的韩语学习之旅吧!",
"keywords": "韩语,韩语教室,韩语学习,韩语词汇,韩语语法,韩语真题,Topik,Topik真题"
},
Expand Down

0 comments on commit cc2e096

Please sign in to comment.