Skip to content

Commit

Permalink
feat(next/web): category.meta.slackNewTicketMentionUserEmails
Browse files Browse the repository at this point in the history
  • Loading branch information
sdjdd committed Jan 8, 2024
1 parent f1767c8 commit de582c4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
32 changes: 27 additions & 5 deletions next/web/src/App/Admin/Settings/Categories/CategoryForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,31 @@ const FORM_ITEM_STYLE = { marginBottom: 16 };

const CategoryMetaOptions: MetaOptionsGroup<CategorySchema>[] = [
{
label: 'AI 分类',
key: 'slack',
label: 'Slack 新工单通知用户邮箱',
children: [
{
key: 'slackNewTicketMentionUserEmails',
type: 'custom',
render: ({ value, onChange }) => (
<Form.Item
extra="当前分类的工单被创建时,将在指定频道 @ 上述用户"
style={{ marginBottom: 0 }}
>
<TextArea
placeholder="每行一个"
autoSize={{ minRows: 2 }}
value={value?.join('\n')}
onChange={(e) => onChange(e.target.value.split('\n'))}
/>
</Form.Item>
),
},
],
},
{
key: 'classify',
label: 'AI 分类',
children: [
{
key: 'enableAIClassify',
Expand All @@ -64,8 +87,8 @@ const CategoryMetaOptions: MetaOptionsGroup<CategorySchema>[] = [
},
{
key: 'previewAIClassify',
type: 'component',
component: <AiClassifyTest />,
type: 'custom',
render: () => <AiClassifyTest />,
predicate: (v) => !!v.alias,
},
],
Expand Down Expand Up @@ -563,8 +586,7 @@ export function CategoryForm({
control={control}
name="meta"
render={({ field: { ref, ...rest } }) => (
console.log(getValues()),
(<MetaField {...rest} options={CategoryMetaOptions} record={getValues()} />)
<MetaField {...rest} options={CategoryMetaOptions} record={getValues()} />
)}
/>

Expand Down
11 changes: 7 additions & 4 deletions next/web/src/App/Admin/components/MetaField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export type MetaOption<T = any> = (
label: string;
}
| {
type: 'component';
component: ReactNode;
type: 'custom';
render: (options: { value: any; onChange: (value: any) => void }) => ReactNode;
}
) & { key: string; predicate?: (data: T) => boolean; description?: string };

Expand Down Expand Up @@ -53,8 +53,11 @@ const MetaOptionsForm = <T extends SchemaWithMeta>({
.filter(({ predicate }) => !record || !predicate || predicate(record))
.map((option) => (
<Form.Item key={option.key} help={option.description} className="!mb-0">
{option.type === 'component' ? (
option.component
{option.type === 'custom' ? (
option.render({
value: value?.[option.key],
onChange: handleFieldChangeFactory(option.key, (v) => v),
})
) : (
<div>
{option.type === 'boolean' ? (
Expand Down

0 comments on commit de582c4

Please sign in to comment.