1- import { DateField , Show , useModalForm , useTable } from "@refinedev/antd" ;
1+ import { DateField , DeleteButton , EditButton , RefreshButton , Show , useModalForm , useTable } from "@refinedev/antd" ;
22import { useShow , useDelete } from "@refinedev/core" ;
3- import { Typography , Card , Row , Col , Table , Button , Space , Modal , Form , Input } from "antd" ;
3+ import { Alert , Typography , Card , Row , Col , Table , Button , Space , Modal , Form , Input } from "antd" ;
44import { useTranslation } from "react-i18next" ;
55import { DeleteOutlined , PlusOutlined } from "@ant-design/icons" ;
66
@@ -46,6 +46,8 @@ export const MailingListShow = () => {
4646 } ) ;
4747 } ;
4848
49+ const isInternal = record ?. source === "internal" ;
50+
4951 return (
5052 < Show
5153 isLoading = { isLoading }
@@ -54,23 +56,40 @@ export const MailingListShow = () => {
5456 { t ( "mailing_lists.titles.show" ) }
5557 </ span >
5658 }
59+ headerButtons = { ( { editButtonProps, deleteButtonProps, refreshButtonProps } ) => (
60+ < >
61+ { isInternal && editButtonProps && < EditButton { ...editButtonProps } /> }
62+ { isInternal && deleteButtonProps && < DeleteButton { ...deleteButtonProps } /> }
63+ { refreshButtonProps && < RefreshButton { ...refreshButtonProps } /> }
64+ </ >
65+ ) }
5766 >
67+ { ! isInternal && ! isLoading && (
68+ < Alert
69+ type = "warning"
70+ showIcon
71+ message = { t ( "mailing_lists.warnings.external_source" ) }
72+ style = { { marginBottom : 16 } }
73+ />
74+ ) }
5875 < Row gutter = { [ 16 , 16 ] } >
5976 < Col span = { 24 } >
6077 < Card size = "small" >
6178 < Row >
62- < Col span = { 6 } >
79+ < Col span = { isInternal ? 6 : 8 } >
6380 < Title level = { 5 } style = { { margin : 0 } } > { t ( "mailing_lists.fields.id" ) } </ Title >
6481 < Text > { record ?. id } </ Text >
6582 </ Col >
66- < Col span = { 12 } >
83+ < Col span = { isInternal ? 12 : 16 } >
6784 < Title level = { 5 } style = { { margin : 0 } } > { t ( "mailing_lists.fields.name" ) } </ Title >
6885 < Text > { record ?. name } </ Text >
6986 </ Col >
70- < Col span = { 6 } >
71- < Title level = { 5 } style = { { margin : 0 } } > { t ( "mailing_lists.fields.created_at" ) } </ Title >
72- < DateField value = { record ?. created_at } format = "LLL" />
73- </ Col >
87+ { isInternal && (
88+ < Col span = { 6 } >
89+ < Title level = { 5 } style = { { margin : 0 } } > { t ( "mailing_lists.fields.created_at" ) } </ Title >
90+ < DateField value = { record ?. created_at } format = "LLL" />
91+ </ Col >
92+ ) }
7493 </ Row >
7594 </ Card >
7695 </ Col >
@@ -82,13 +101,15 @@ export const MailingListShow = () => {
82101 </ span >
83102 }
84103 extra = {
85- < Button
86- type = "primary"
87- icon = { < PlusOutlined /> }
88- onClick = { ( ) => show ( ) }
89- >
90- { t ( "mailing_lists.fields.add_recipient" ) }
91- </ Button >
104+ isInternal && (
105+ < Button
106+ type = "primary"
107+ icon = { < PlusOutlined /> }
108+ onClick = { ( ) => show ( ) }
109+ >
110+ { t ( "mailing_lists.fields.add_recipient" ) }
111+ </ Button >
112+ )
92113 }
93114 >
94115 < Table
@@ -103,12 +124,14 @@ export const MailingListShow = () => {
103124 dataIndex = "actions"
104125 render = { ( _ , record : any ) => (
105126 < Space >
106- < Button
107- danger
108- size = "small"
109- icon = { < DeleteOutlined /> }
110- onClick = { ( ) => handleDelete ( record . id ) }
111- />
127+ { isInternal && (
128+ < Button
129+ danger
130+ size = "small"
131+ icon = { < DeleteOutlined /> }
132+ onClick = { ( ) => handleDelete ( record . id ) }
133+ />
134+ ) }
112135 </ Space >
113136 ) }
114137 />
0 commit comments