perf: add notification picker empty state to guide user to create notification
This commit is contained in:
parent
09c3cfa0dc
commit
a567834e45
@ -1,20 +1,40 @@
|
|||||||
import { Select, SelectProps } from 'antd';
|
import { Button, Empty, Select, SelectProps } from 'antd';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { trpc } from '../../api/trpc';
|
import { trpc } from '../../api/trpc';
|
||||||
import { useCurrentWorkspaceId } from '../../store/user';
|
import { useCurrentWorkspaceId } from '../../store/user';
|
||||||
import { ColorTag } from '../ColorTag';
|
import { ColorTag } from '../ColorTag';
|
||||||
|
import { useNavigate } from 'react-router';
|
||||||
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
interface NotificationPickerProps extends SelectProps<string> {}
|
interface NotificationPickerProps extends SelectProps<string> {}
|
||||||
export const NotificationPicker: React.FC<NotificationPickerProps> = React.memo(
|
export const NotificationPicker: React.FC<NotificationPickerProps> = React.memo(
|
||||||
(props) => {
|
(props) => {
|
||||||
const workspaceId = useCurrentWorkspaceId();
|
const workspaceId = useCurrentWorkspaceId();
|
||||||
|
const navigate = useNavigate();
|
||||||
const { data: allNotification = [] } = trpc.notification.all.useQuery({
|
const { data: allNotification = [] } = trpc.notification.all.useQuery({
|
||||||
workspaceId,
|
workspaceId,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select {...props}>
|
<Select
|
||||||
{allNotification.map((m) => (
|
notFoundContent={
|
||||||
|
<Empty
|
||||||
|
description={
|
||||||
|
<div className="py-2">
|
||||||
|
<div className="mb-1">Not found any notification</div>
|
||||||
|
<Button
|
||||||
|
icon={<PlusOutlined />}
|
||||||
|
onClick={() => navigate('/settings/notifications')}
|
||||||
|
>
|
||||||
|
Create Now
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{allNotification.map((m: any) => (
|
||||||
<Select.Option key={m.id} value={m.id}>
|
<Select.Option key={m.id} value={m.id}>
|
||||||
<ColorTag label={m.type} />
|
<ColorTag label={m.type} />
|
||||||
{m.name}
|
{m.name}
|
||||||
|
Loading…
Reference in New Issue
Block a user