diff --git a/apps/timo-web/app/[locale]/(main)/settings/_hooks/account/use-settings-profile.ts b/apps/timo-web/app/[locale]/(main)/settings/_hooks/account/use-settings-profile.ts index 8ba2db38..c07f649f 100644 --- a/apps/timo-web/app/[locale]/(main)/settings/_hooks/account/use-settings-profile.ts +++ b/apps/timo-web/app/[locale]/(main)/settings/_hooks/account/use-settings-profile.ts @@ -20,7 +20,7 @@ import { MAX_CUSTOM_TAG_COUNT, tagCreateDataSchema, } from "@/schemas/tag/tag-schema"; -import { getDefaultTagLabelKey } from "@/utils/todo/tag-label"; +import { getDefaultTagLabelKey, isDefaultTagId } from "@/utils/todo/tag-label"; const LANGUAGE_REQUEST_MAP: Record< SettingsLanguage, @@ -58,14 +58,13 @@ export const useSettingsProfile = () => { const { mutate: logoutMutate, isPending: isLoggingOut } = useLogoutMutation(); const tagItems = (tagsQuery.data?.tags ?? []).map((tag) => { - const labelKey = tag.isDefault - ? getDefaultTagLabelKey(tag.tagId) - : undefined; + const isDefault = isDefaultTagId(tag.tagId); + const labelKey = isDefault ? getDefaultTagLabelKey(tag.tagId) : undefined; return { id: tag.tagId, label: labelKey ? tCommon(`tag.${labelKey}`) : tag.name, - isDefault: tag.isDefault, + isDefault, }; }); diff --git a/apps/timo-web/hooks/todo-modal/common/use-tag-field.tsx b/apps/timo-web/hooks/todo-modal/common/use-tag-field.tsx index e2cdb099..8039c8c0 100644 --- a/apps/timo-web/hooks/todo-modal/common/use-tag-field.tsx +++ b/apps/timo-web/hooks/todo-modal/common/use-tag-field.tsx @@ -12,7 +12,7 @@ import { MAX_CUSTOM_TAG_COUNT, tagCreateDataSchema, } from "@/schemas/tag/tag-schema"; -import { getDefaultTagLabelKey } from "@/utils/todo/tag-label"; +import { getDefaultTagLabelKey, isDefaultTagId } from "@/utils/todo/tag-label"; export interface UseTagFieldParams { control: Control; @@ -63,7 +63,7 @@ export const useTagField = ({ (option) => option.id === field.value, ); const customTagCount = (tagsQuery.data?.tags ?? []).filter( - (tag) => !tag.isDefault, + (tag) => !isDefaultTagId(tag.tagId), ).length; const handleSelectTag = (label: string) => { diff --git a/apps/timo-web/schemas/tag/tag-schema.ts b/apps/timo-web/schemas/tag/tag-schema.ts index 60d0787b..f3bf477b 100644 --- a/apps/timo-web/schemas/tag/tag-schema.ts +++ b/apps/timo-web/schemas/tag/tag-schema.ts @@ -5,7 +5,6 @@ export const MAX_CUSTOM_TAG_COUNT = 4; export const tagSchema = z.object({ tagId: z.number(), name: z.string(), - isDefault: z.boolean(), }); export const tagListDataSchema = z.object({ diff --git a/apps/timo-web/utils/todo/tag-label.ts b/apps/timo-web/utils/todo/tag-label.ts index 7454d662..f0cc3bd2 100644 --- a/apps/timo-web/utils/todo/tag-label.ts +++ b/apps/timo-web/utils/todo/tag-label.ts @@ -20,3 +20,6 @@ const DEFAULT_TAG_ID_TO_LABEL_KEY: Record = { export const getDefaultTagLabelKey = (tagId: number): TagLabelKey | undefined => DEFAULT_TAG_ID_TO_LABEL_KEY[tagId]; + +export const isDefaultTagId = (tagId: number): boolean => + getDefaultTagLabelKey(tagId) !== undefined;