@@ -9,7 +9,11 @@ import {
99import toast from 'react-hot-toast'
1010import Loadbar from '../loaders/Loadbar'
1111import Spinner from '../common/Spinner'
12- import { LazerState , LazerFeed , LazerPublisher } from '@pythnetwork/xc-admin-common/src/programs/types'
12+ import {
13+ LazerState ,
14+ LazerFeed ,
15+ LazerPublisher ,
16+ } from '@pythnetwork/xc-admin-common/src/programs/types'
1317import { capitalizeFirstLetter } from '../../utils/capitalizeFirstLetter'
1418
1519interface PythLazerProps {
@@ -70,42 +74,52 @@ const ShardChangesRows: React.FC<ShardChangesRowsProps> = ({ changes }) => {
7074
7175 return (
7276 < >
73- { Object . entries ( changes . new ) . map ( ( [ key , newValue ] ) =>
74- ( isNewShard || ( changes . prev && changes . prev [ key as keyof typeof changes . prev ] !== newValue ) ) && (
75- < tr key = { key } >
76- < td className = "base16 py-4 pl-6 pr-2 lg:pl-6" >
77- { key
78- . split ( / (? = [ A - Z ] ) / )
79- . join ( ' ' )
80- . split ( '_' )
81- . map ( ( word ) => capitalizeFirstLetter ( word ) )
82- . join ( ' ' ) }
83- </ td >
84- < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" >
85- { ! isNewShard && changes . prev ? (
86- < >
87- < s > { String ( changes . prev [ key as keyof typeof changes . prev ] ) } </ s >
88- < br />
89- </ >
90- ) : null }
91- { String ( newValue ) }
92- </ td >
93- </ tr >
94- )
77+ { Object . entries ( changes . new ) . map (
78+ ( [ key , newValue ] ) =>
79+ ( isNewShard ||
80+ ( changes . prev &&
81+ changes . prev [ key as keyof typeof changes . prev ] !== newValue ) ) && (
82+ < tr key = { key } >
83+ < td className = "base16 py-4 pl-6 pr-2 lg:pl-6" >
84+ { key
85+ . split ( / (? = [ A - Z ] ) / )
86+ . join ( ' ' )
87+ . split ( '_' )
88+ . map ( ( word ) => capitalizeFirstLetter ( word ) )
89+ . join ( ' ' ) }
90+ </ td >
91+ < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" >
92+ { ! isNewShard && changes . prev ? (
93+ < >
94+ < s >
95+ { String ( changes . prev [ key as keyof typeof changes . prev ] ) }
96+ </ s >
97+ < br />
98+ </ >
99+ ) : null }
100+ { String ( newValue ) }
101+ </ td >
102+ </ tr >
103+ )
95104 ) }
96105 </ >
97106 )
98107}
99108
100- const FeedChangesRows : React . FC < FeedChangesRowsProps > = ( { changes, feedId } ) => {
109+ const FeedChangesRows : React . FC < FeedChangesRowsProps > = ( {
110+ changes,
111+ feedId,
112+ } ) => {
101113 const isNewFeed = ! changes . prev && changes . new
102114 const isDeletedFeed = changes . prev && ! changes . new
103115
104116 if ( isDeletedFeed ) {
105117 return (
106118 < tr >
107119 < td className = "base16 py-4 pl-6 pr-2 lg:pl-6" > Feed ID</ td >
108- < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" > { feedId . replace ( 'feed_' , '' ) } </ td >
120+ < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" >
121+ { feedId . replace ( 'feed_' , '' ) }
122+ </ td >
109123 </ tr >
110124 )
111125 }
@@ -116,7 +130,8 @@ const FeedChangesRows: React.FC<FeedChangesRowsProps> = ({ changes, feedId }) =>
116130 if ( ! changes . new ?. metadata ) return null
117131
118132 return Object . entries ( changes . new . metadata ) . map ( ( [ key , newValue ] ) => {
119- const prevValue = changes . prev ?. metadata ?. [ key as keyof typeof changes . prev . metadata ]
133+ const prevValue =
134+ changes . prev ?. metadata ?. [ key as keyof typeof changes . prev . metadata ]
120135 const hasChanged = isNewFeed || prevValue !== newValue
121136
122137 if ( ! hasChanged ) return null
@@ -146,13 +161,20 @@ const FeedChangesRows: React.FC<FeedChangesRowsProps> = ({ changes, feedId }) =>
146161 }
147162
148163 const renderPendingActivationChanges = ( ) => {
149- if ( changes . new ?. pendingActivation !== undefined || changes . prev ?. pendingActivation !== undefined ) {
150- const hasChanged = isNewFeed || changes . prev ?. pendingActivation !== changes . new ?. pendingActivation
164+ if (
165+ changes . new ?. pendingActivation !== undefined ||
166+ changes . prev ?. pendingActivation !== undefined
167+ ) {
168+ const hasChanged =
169+ isNewFeed ||
170+ changes . prev ?. pendingActivation !== changes . new ?. pendingActivation
151171
152172 if ( hasChanged ) {
153173 return (
154174 < tr key = "pendingActivation" >
155- < td className = "base16 py-4 pl-6 pr-2 lg:pl-6" > Pending Activation</ td >
175+ < td className = "base16 py-4 pl-6 pr-2 lg:pl-6" >
176+ Pending Activation
177+ </ td >
156178 < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" >
157179 { ! isNewFeed && changes . prev ?. pendingActivation ? (
158180 < >
@@ -177,15 +199,20 @@ const FeedChangesRows: React.FC<FeedChangesRowsProps> = ({ changes, feedId }) =>
177199 )
178200}
179201
180- const PublisherChangesRows : React . FC < PublisherChangesRowsProps > = ( { changes, publisherId } ) => {
202+ const PublisherChangesRows : React . FC < PublisherChangesRowsProps > = ( {
203+ changes,
204+ publisherId,
205+ } ) => {
181206 const isNewPublisher = ! changes . prev && changes . new
182207 const isDeletedPublisher = changes . prev && ! changes . new
183208
184209 if ( isDeletedPublisher ) {
185210 return (
186211 < tr >
187212 < td className = "base16 py-4 pl-6 pr-2 lg:pl-6" > Publisher ID</ td >
188- < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" > { publisherId . replace ( 'publisher_' , '' ) } </ td >
213+ < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" >
214+ { publisherId . replace ( 'publisher_' , '' ) }
215+ </ td >
189216 </ tr >
190217 )
191218 }
@@ -196,7 +223,9 @@ const PublisherChangesRows: React.FC<PublisherChangesRowsProps> = ({ changes, pu
196223 < >
197224 { Object . entries ( changes . new ) . map ( ( [ key , newValue ] ) => {
198225 const prevValue = changes . prev ?. [ key as keyof LazerPublisher ]
199- const hasChanged = isNewPublisher || JSON . stringify ( prevValue ) !== JSON . stringify ( newValue )
226+ const hasChanged =
227+ isNewPublisher ||
228+ JSON . stringify ( prevValue ) !== JSON . stringify ( newValue )
200229
201230 if ( ! hasChanged ) return null
202231
@@ -213,7 +242,11 @@ const PublisherChangesRows: React.FC<PublisherChangesRowsProps> = ({ changes, pu
213242 < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" >
214243 { ! isNewPublisher && prevValue !== undefined ? (
215244 < >
216- < s > { Array . isArray ( prevValue ) ? prevValue . join ( ', ' ) : String ( prevValue ) } </ s >
245+ < s >
246+ { Array . isArray ( prevValue )
247+ ? prevValue . join ( ', ' )
248+ : String ( prevValue ) }
249+ </ s >
217250 < br />
218251 </ >
219252 ) : null }
@@ -242,13 +275,25 @@ const ModalContent: React.FC<ModalContentProps> = ({
242275
243276 let title = key
244277 if ( key === 'shard' ) {
245- title = isAddition ? 'Add New Shard' : isDeletion ? 'Delete Shard' : 'Shard Configuration'
278+ title = isAddition
279+ ? 'Add New Shard'
280+ : isDeletion
281+ ? 'Delete Shard'
282+ : 'Shard Configuration'
246283 } else if ( key . startsWith ( 'feed_' ) ) {
247284 const feedId = key . replace ( 'feed_' , '' )
248- title = isAddition ? `Add New Feed (ID: ${ feedId } )` : isDeletion ? `Delete Feed (ID: ${ feedId } )` : `Feed ${ feedId } `
285+ title = isAddition
286+ ? `Add New Feed (ID: ${ feedId } )`
287+ : isDeletion
288+ ? `Delete Feed (ID: ${ feedId } )`
289+ : `Feed ${ feedId } `
249290 } else if ( key . startsWith ( 'publisher_' ) ) {
250291 const publisherId = key . replace ( 'publisher_' , '' )
251- title = isAddition ? `Add New Publisher (ID: ${ publisherId } )` : isDeletion ? `Delete Publisher (ID: ${ publisherId } )` : `Publisher ${ publisherId } `
292+ title = isAddition
293+ ? `Add New Publisher (ID: ${ publisherId } )`
294+ : isDeletion
295+ ? `Delete Publisher (ID: ${ publisherId } )`
296+ : `Publisher ${ publisherId } `
252297 }
253298
254299 return (
@@ -287,7 +332,8 @@ const ModalContent: React.FC<ModalContentProps> = ({
287332 />
288333 ) : null }
289334
290- { Object . keys ( changes ) . indexOf ( key ) !== Object . keys ( changes ) . length - 1 ? (
335+ { Object . keys ( changes ) . indexOf ( key ) !==
336+ Object . keys ( changes ) . length - 1 ? (
291337 < tr >
292338 < td className = "base16 py-4 pl-6 pr-6" colSpan = { 2 } >
293339 < hr className = "border-gray-700" />
0 commit comments