diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml index fabaaf3e..d8084623 100644 --- a/i18n/en_US.yaml +++ b/i18n/en_US.yaml @@ -962,9 +962,16 @@ ui: placeholder: "City, Country" notification: heading: Notifications - email: - label: Email Notifications - radio: "Answers to your questions, comments, and more" + email: Email + inbox: + label: Inbox notifications + description: Answers to your questions, comments, invites, and more. + all_new_question: + label: All new questions + description: Get notified of all new questions. Up to 50 questions per week. + all_new_question_for_following_tags: + label: All new questions for following tags + description: Get notified of new questions for following tags. account: heading: Account change_email_btn: Change email diff --git a/ui/src/common/interface.ts b/ui/src/common/interface.ts index f86d60a3..97e9bac0 100644 --- a/ui/src/common/interface.ts +++ b/ui/src/common/interface.ts @@ -57,7 +57,7 @@ export interface TagInfo extends TagBase { main_tag_slug_name?: string; excerpt?; } -export interface QuestionParams extends ImgCodeReq{ +export interface QuestionParams extends ImgCodeReq { title: string; url_title?: string; content: string; @@ -589,3 +589,13 @@ export interface UserOauthConnectorItem { binding: boolean; external_id: string; } + +export interface NotificationConfigItem { + enable: boolean; + key: string; +} +export interface NotificationConfig { + all_new_question: NotificationConfigItem[]; + all_new_question_for_following_tags: NotificationConfigItem[]; + inbox: NotificationConfigItem[]; +} diff --git a/ui/src/components/SchemaForm/components/Check.tsx b/ui/src/components/SchemaForm/components/Check.tsx index fd18fb89..23e5d520 100644 --- a/ui/src/components/SchemaForm/components/Check.tsx +++ b/ui/src/components/SchemaForm/components/Check.tsx @@ -27,12 +27,13 @@ const Index: FC = ({ index: number, ) => { const { name, checked } = evt.currentTarget; - const freshVal = checked ? enumValues?.[index] : ''; + enumValues[index] = checked; + const state = { ...formData, [name]: { ...formData[name], - value: freshVal, + value: enumValues, isInvalid: false, }, }; @@ -51,7 +52,7 @@ const Index: FC = ({ name={fieldName} id={`form-${String(item)}`} label={enumNames?.[index]} - checked={(fieldObject?.value || '') === item} + checked={fieldObject?.value?.[index] || false} feedback={fieldObject?.errorMsg} feedbackType="invalid" isInvalid={fieldObject?.isInvalid} diff --git a/ui/src/components/SchemaForm/index.tsx b/ui/src/components/SchemaForm/index.tsx index 16ea9dab..a82ae8a0 100644 --- a/ui/src/components/SchemaForm/index.tsx +++ b/ui/src/components/SchemaForm/index.tsx @@ -386,8 +386,13 @@ export const initFormData = (schema: JSONSchema): Type.FormDataType => { const props: JSONSchema['properties'] = schema?.properties || {}; Object.keys(props).forEach((key) => { const prop = props[key]; - const defaultVal = prop?.default; - + let defaultVal: any = ''; + if (Array.isArray(prop.default) && prop.enum && prop.enum.length > 0) { + // for checkbox default values + defaultVal = prop.enum; + } else { + defaultVal = prop?.default; + } formData[key] = { value: defaultVal, isInvalid: false, diff --git a/ui/src/components/SchemaForm/types.ts b/ui/src/components/SchemaForm/types.ts index f22e6b89..cbb48fb2 100644 --- a/ui/src/components/SchemaForm/types.ts +++ b/ui/src/components/SchemaForm/types.ts @@ -30,7 +30,7 @@ export interface JSONSchema { description?: string; enum?: Array; enumNames?: string[]; - default?: string | boolean | number; + default?: string | boolean | number | any[]; }; }; } diff --git a/ui/src/pages/Tags/Detail/index.tsx b/ui/src/pages/Tags/Detail/index.tsx index ce892495..5818b447 100644 --- a/ui/src/pages/Tags/Detail/index.tsx +++ b/ui/src/pages/Tags/Detail/index.tsx @@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next'; import { usePageTags } from '@/hooks'; import * as Type from '@/common/interface'; -import { FollowingTags, CustomSidebar } from '@/components'; +import { FollowingTags, CustomSidebar, Icon } from '@/components'; import { useTagInfo, useFollow, @@ -141,9 +141,16 @@ const Index: FC = () => {
{tagInfo.is_follower ? ( - +
+ + + + +
) : (