mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-08 00:10:24 +08:00
Rename function to getTypeSafei18nKey
This commit is contained in:
@@ -14,7 +14,7 @@ import { HelpCircle } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { useTranslation } from "next-i18next";
|
||||
import { useMemo } from "react";
|
||||
import { normalizei18nKey } from "src/lib/i18n";
|
||||
import { getTypeSafei18nKey } from "src/lib/i18n";
|
||||
import { TaskType } from "src/types/Task";
|
||||
|
||||
import { TaskCategory, TaskCategoryLabels, TaskInfo, TaskInfos } from "../Tasks/TaskTypes";
|
||||
@@ -63,8 +63,8 @@ export const TaskOption = ({ content }: TasksOptionProps) => {
|
||||
className="flex flex-col justify-between h-full"
|
||||
>
|
||||
<Flex className="p-6 pb-10" flexDir="column" gap="3">
|
||||
<Heading size="md">{t(normalizei18nKey(`tasks:${item.id}.label`))}</Heading>
|
||||
<Text size="sm">{t(normalizei18nKey(`tasks:${item.id}.desc`))}</Text>
|
||||
<Heading size="md">{t(getTypeSafei18nKey(`tasks:${item.id}.label`))}</Heading>
|
||||
<Text size="sm">{t(getTypeSafei18nKey(`tasks:${item.id}.desc`))}</Text>
|
||||
</Flex>
|
||||
<Text
|
||||
fontWeight="bold"
|
||||
|
||||
@@ -6,7 +6,7 @@ import { TrackedTextarea } from "src/components/Survey/TrackedTextarea";
|
||||
import { TwoColumnsWithCards } from "src/components/Survey/TwoColumnsWithCards";
|
||||
import { TaskSurveyProps } from "src/components/Tasks/Task";
|
||||
import { TaskHeader } from "src/components/Tasks/TaskHeader";
|
||||
import { normalizei18nKey } from "src/lib/i18n";
|
||||
import { getTypeSafei18nKey } from "src/lib/i18n";
|
||||
|
||||
export const CreateTask = ({
|
||||
task,
|
||||
@@ -49,7 +49,7 @@ export const CreateTask = ({
|
||||
<Stack spacing="4">
|
||||
{!!i18n.exists(`task.${taskType.id}.instruction`) && (
|
||||
<Text fontSize="xl" fontWeight="bold" color={titleColor}>
|
||||
{t(normalizei18nKey(`${taskType.id}.instruction`))}
|
||||
{t(getTypeSafei18nKey(`${taskType.id}.instruction`))}
|
||||
</Text>
|
||||
)}
|
||||
<TrackedTextarea
|
||||
|
||||
@@ -7,7 +7,7 @@ import { LabelTask } from "src/components/Tasks/LabelTask";
|
||||
import { TaskCategory, TaskInfo, TaskInfos } from "src/components/Tasks/TaskTypes";
|
||||
import { UnchangedWarning } from "src/components/Tasks/UnchangedWarning";
|
||||
import { post } from "src/lib/api";
|
||||
import { normalizei18nKey } from "src/lib/i18n";
|
||||
import { getTypeSafei18nKey } from "src/lib/i18n";
|
||||
import { TaskContent, TaskReplyValidity } from "src/types/Task";
|
||||
import useSWRMutation from "swr/mutation";
|
||||
|
||||
@@ -160,8 +160,8 @@ export const Task = ({ frontendId, task, trigger, mutate }) => {
|
||||
/>
|
||||
<UnchangedWarning
|
||||
show={showUnchangedWarning}
|
||||
title={t(normalizei18nKey(`${taskType.id}.unchanged_title`)) || t("default.unchanged_title")}
|
||||
message={t(normalizei18nKey(`${taskType.id}.unchanged_message`)) || t("default.unchanged_message")}
|
||||
title={t(getTypeSafei18nKey(`${taskType.id}.unchanged_title`)) || t("default.unchanged_title")}
|
||||
message={t(getTypeSafei18nKey(`${taskType.id}.unchanged_message`)) || t("default.unchanged_message")}
|
||||
continueButtonText={"Continue anyway"}
|
||||
onClose={() => setShowUnchangedWarning(false)}
|
||||
onContinueAnyway={() => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { HStack, IconButton, Link, Stack, Text, useColorModeValue } from "@chakr
|
||||
import { HelpCircle } from "lucide-react";
|
||||
import { useTranslation } from "next-i18next";
|
||||
import type { TaskInfo } from "src/components/Tasks/TaskTypes";
|
||||
import { normalizei18nKey } from "src/lib/i18n";
|
||||
import { getTypeSafei18nKey } from "src/lib/i18n";
|
||||
|
||||
interface TaskHeaderProps {
|
||||
/**
|
||||
@@ -22,14 +22,14 @@ const TaskHeader = ({ taskType }: TaskHeaderProps) => {
|
||||
<Stack spacing="1">
|
||||
<HStack>
|
||||
<Text fontSize="xl" fontWeight="bold" color={titleColor}>
|
||||
{t(normalizei18nKey(`${taskType.id}.label`))}
|
||||
{t(getTypeSafei18nKey(`${taskType.id}.label`))}
|
||||
</Text>
|
||||
<Link href={taskType.help_link} isExternal>
|
||||
<IconButton variant="ghost" aria-label="More Information" icon={<HelpCircle size="1em" />} />
|
||||
</Link>
|
||||
</HStack>
|
||||
<Text fontSize="md" color={labelColor}>
|
||||
{t(normalizei18nKey(`${taskType.id}.overview`))}
|
||||
{t(getTypeSafei18nKey(`${taskType.id}.overview`))}
|
||||
</Text>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const normalizei18nKey = (key: string) => key as unknown as TemplateStringsArray;
|
||||
export const getTypeSafei18nKey = (key: string) => key as unknown as TemplateStringsArray;
|
||||
|
||||
Reference in New Issue
Block a user