1
1
import { useInfiniteQuery , useQuery , useQueryClient } from '@tanstack/react-query' ;
2
- import { ColumnFiltersState , createColumnHelper , flexRender , getCoreRowModel , getSortedRowModel , PaginationState , SortingState , useReactTable } from '@tanstack/react-table' ;
2
+ import { ColumnFiltersState , createColumnHelper , flexRender , getCoreRowModel , getSortedRowModel , PaginationState , useReactTable } from '@tanstack/react-table' ;
3
3
import classNames from 'classnames' ;
4
4
import { formatDistanceToNow } from 'date-fns' ;
5
5
import { useContext , useEffect , useMemo , useState } from 'react' ;
6
6
import Select , { components , MultiValue , OptionProps , ValueContainerProps } from 'react-select' ;
7
7
8
8
import { constraints , format , type } from '@maif/react-forms' ;
9
- import { Link , useNavigate , useSearchParams } from 'react-router-dom' ;
9
+ import { useSearchParams } from 'react-router-dom' ;
10
10
import { I18nContext , ModalContext , TranslateParams } from '../../../contexts' ;
11
11
import { GlobalContext } from '../../../contexts/globalContext' ;
12
12
import { CustomSubscriptionData } from '../../../contexts/modals/SubscriptionMetadataModal' ;
13
13
import * as Services from '../../../services' ;
14
- import { DaikokuMode , Display , IAccountCreationGQL , IApi , IApiGQL , IApiPost , IIssuesTag , isError , Issue , ISubscription , ISubscriptionDemand , ISubscriptionDemandGQL , ITeamFullGql , ITeamSimple , ITenant , ITesting , IUsagePlan , IUser , IValidationStepPayment } from '../../../types' ;
14
+ import { IAccountCreationGQL , IApiGQL , IApiPost , isError , Issue , ISubscription , ISubscriptionDemandGQL , ITeamFullGql , ITeamSimple , ITenant , IUsagePlan , IUser , IValidationStep } from '../../../types' ;
15
15
import { getLanguageFns , Spinner } from '../../utils' ;
16
16
import { FeedbackButton } from '../../utils/FeedbackButton' ;
17
- import { Option as opt } from '../../utils' ;
18
- import { IApiSubscriptionGql } from '../apis' ;
19
17
import { SimpleApiKeyCard } from '../apikeys/TeamApiKeysForApi' ;
18
+ import { IApiSubscriptionGql } from '../apis' ;
20
19
declare module '@tanstack/react-table' {
21
20
interface ColumnMeta < TData extends unknown , TValue > extends NotificationColumnMeta { }
22
21
}
@@ -170,7 +169,7 @@ type NotificationActionGQL =
170
169
| {
171
170
__typename : 'CheckoutForSubscription' ;
172
171
plan : IUsagePlan ;
173
- step : IValidationStepPayment ;
172
+ step : IValidationStep & { type : 'payment' } ;
174
173
demand : ISubscriptionDemandGQL ;
175
174
api : IApiGQL ;
176
175
}
@@ -779,7 +778,7 @@ export const NotificationList = () => {
779
778
return translate ( { key : 'notif.apikey.deletion' } )
780
779
case 'ApiKeyDeletionInformationV2' : {
781
780
const apiKeyDeletionInformationDescription = translate ( { key : 'notif.apikey.deletion' } )
782
- const __subscription = notification . action . subscription
781
+ const __subscription = notification . action . subscription
783
782
return (
784
783
< >
785
784
{ apiKeyDeletionInformationDescription }
@@ -810,7 +809,7 @@ export const NotificationList = () => {
810
809
const __api = notification . action . api
811
810
const __plan = notification . action . plan
812
811
const __team = notification . action . api . team
813
- const __subscription = notification . action . subscription
812
+ const __subscription = notification . action . subscription
814
813
return (
815
814
< >
816
815
{ apiKeyRotationInProgressDescription }
@@ -836,11 +835,11 @@ export const NotificationList = () => {
836
835
case 'ApiKeyRotationEnded' :
837
836
return translate ( 'notif.apikey.rotation.ended' )
838
837
case 'ApiKeyRotationEndedV2' : {
839
- const apiKeyRotationEndedV2Description = translate ( 'notif.apikey.rotation.ended' )
838
+ const apiKeyRotationEndedV2Description = translate ( 'notif.apikey.rotation.ended' )
840
839
const __api = notification . action . api
841
840
const __plan = notification . action . plan
842
841
const __team = notification . action . api . team
843
- const __subscription = notification . action . subscription
842
+ const __subscription = notification . action . subscription
844
843
return < >
845
844
{ apiKeyRotationEndedV2Description }
846
845
< a
@@ -868,7 +867,7 @@ export const NotificationList = () => {
868
867
const __api = notification . action . api
869
868
const __plan = notification . action . plan
870
869
const __team = notification . action . api . team
871
- const __subscription = notification . action . subscription
870
+ const __subscription = notification . action . subscription
872
871
return < >
873
872
{ apiKeyRefreshV2Description }
874
873
< a
@@ -920,11 +919,42 @@ export const NotificationList = () => {
920
919
return translate ( 'notif.issues.comment' )
921
920
case 'ApiSubscriptionTransferSuccess' :
922
921
return translate ( 'notif.subscription.transfer.success' )
923
- case 'AccountCreationAttempt' :
924
- return translate ( 'notif.account.creation.attempt' ) ;
922
+ case 'AccountCreationAttempt' :
923
+ const description = translate ( 'notif.account.creation.attempt' ) ;
924
+ const value = notification . action . demand . value
925
+ const formStep = notification . action . demand . steps . map ( s => s . step ) . find ( s => s . type === 'form' )
926
+
927
+ const regexp = / \[ \[ ( .+ ?) \] \] / g;
928
+ const matches = formStep ?. formatter . match ( regexp ) ;
929
+
930
+ const formattedValue = matches ?. reduce ( ( acc , match ) => {
931
+ const key = match . replace ( '[[' , '' ) . replace ( ']]' , '' ) ;
932
+ return acc . replace ( match , value [ key ] || match ) ;
933
+ } , formStep ?. formatter ?? "" ) ;
934
+
935
+ return (
936
+ < >
937
+ { description }
938
+ < a
939
+ href = '#'
940
+ className = 'underline'
941
+ aria-label = { translate ( 'notifications.page.account.creation.attempt.detail.button.label' ) }
942
+ title = { translate ( 'notifications.page.account.creation.attempt.detail.button.label' ) }
943
+ onClick = { ( ) => alert ( {
944
+ title : translate ( 'notifications.page.account.creation.attempt.detail.modal.title' ) ,
945
+ message : < div >
946
+ { ! ! formattedValue && < em > { formattedValue } </ em > }
947
+ < pre >
948
+ { JSON . stringify ( value , null , 2 ) }
949
+ </ pre >
950
+ </ div >
951
+ } ) } >
952
+ < span className = 'ms-2' > [{ translate ( 'notifications.page.account.creation.attempt.detail.button.label' ) } ]</ span >
953
+ </ a >
954
+ </ >
955
+ )
925
956
default :
926
957
return '' ;
927
-
928
958
}
929
959
}
930
960
@@ -1024,10 +1054,8 @@ export const NotificationList = () => {
1024
1054
meta : { className : "description-cell" } ,
1025
1055
cell : ( info ) => {
1026
1056
return < div className = 'notification d-flex align-items-center gap-3' >
1027
- < div >
1028
- < div className = 'notification__description' >
1029
- { notificationFormatter ( info . row . original , translate , tenant ) }
1030
- </ div >
1057
+ < div className = 'notification__description' >
1058
+ { notificationFormatter ( info . row . original , translate , tenant ) }
1031
1059
</ div >
1032
1060
</ div > ;
1033
1061
} ,
0 commit comments