1
- import { CheckIcon } from "@bitcoin-design/bitcoin-icons-react/filled" ;
2
1
import ConfirmOrCancel from "@components/ConfirmOrCancel" ;
3
2
import Container from "@components/Container" ;
4
3
import PublisherCard from "@components/PublisherCard" ;
5
4
import { useState } from "react" ;
6
5
import { useTranslation } from "react-i18next" ;
6
+ import ContentMessage from "~/app/components/ContentMessage" ;
7
+ import Hyperlink from "~/app/components/Hyperlink" ;
7
8
import ScreenHeader from "~/app/components/ScreenHeader" ;
8
9
import Checkbox from "~/app/components/form/Checkbox" ;
9
10
import { useNavigationState } from "~/app/hooks/useNavigationState" ;
10
11
import { USER_REJECTED_ERROR } from "~/common/constants" ;
11
12
import msg from "~/common/lib/msg" ;
12
13
import { OriginData } from "~/types" ;
13
14
14
- function NostrConfirm ( ) {
15
+ function NostrConfirmEncryptOrDecrypt ( ) {
15
16
const { t } = useTranslation ( "translation" , {
16
17
keyPrefix : "nostr" ,
17
18
} ) ;
18
19
const { t : tCommon } = useTranslation ( "common" ) ;
19
20
const navState = useNavigationState ( ) ;
20
21
const origin = navState . origin as OriginData ;
21
- const description = navState . args ?. description ;
22
- const details = navState . args ?. details ;
22
+ const action = navState . args ?. encryptOrDecrypt ?. action ;
23
+ const peer = navState . args ?. encryptOrDecrypt ?. peer ;
24
+ const message = navState . args ?. encryptOrDecrypt ?. message ;
25
+
23
26
const [ loading , setLoading ] = useState ( false ) ;
27
+ const [ showDetails , setShowDetails ] = useState ( false ) ;
28
+
24
29
const [ rememberPermission , setRememberPermission ] = useState ( true ) ;
25
30
26
31
function confirm ( ) {
@@ -47,6 +52,10 @@ function NostrConfirm() {
47
52
msg . error ( USER_REJECTED_ERROR ) ;
48
53
}
49
54
55
+ function toggleShowDetails ( ) {
56
+ setShowDetails ( ( current ) => ! current ) ;
57
+ }
58
+
50
59
function handleSubmit ( event : React . FormEvent < HTMLFormElement > ) {
51
60
event . preventDefault ( ) ;
52
61
confirm ( ) ;
@@ -62,21 +71,29 @@ function NostrConfirm() {
62
71
title = { origin . name }
63
72
image = { origin . icon }
64
73
url = { origin . host }
65
- isSmall = { false }
74
+ isSmall = { true }
66
75
/>
67
- < div className = "dark:text-white pt-6 mb-4" >
68
- < p className = "mb-2" > { t ( "allow" , { host : origin . host } ) } </ p >
69
- < p className = "dark:text-white" >
70
- < CheckIcon className = "w-5 h-5 mr-2 inline" />
71
- { description }
72
- { details && (
73
- < >
74
- < br />
75
- < i className = "ml-7" > { details } </ i >
76
- </ >
76
+ { message && (
77
+ < ContentMessage
78
+ heading = { t (
79
+ action == "encrypt" ? "allow_encrypt" : "allow_decrypt" ,
80
+ {
81
+ host : origin . host ,
82
+ }
77
83
) }
78
- </ p >
84
+ content = { message }
85
+ />
86
+ ) }
87
+ < div className = "flex justify-center mb-4 gap-4" >
88
+ < Hyperlink onClick = { toggleShowDetails } >
89
+ { showDetails ? t ( "hide_details" ) : t ( "view_details" ) }
90
+ </ Hyperlink >
79
91
</ div >
92
+ { showDetails && (
93
+ < div className = "whitespace-pre-wrap break-words p-2 mb-4 shadow bg-white rounded-lg dark:bg-surface-02dp text-gray-500 dark:text-gray-400" >
94
+ { t ( "peer" ) } : { peer }
95
+ </ div >
96
+ ) }
80
97
</ div >
81
98
< div className = "text-center flex flex-col" >
82
99
< div className = "flex items-center mb-4" >
@@ -115,4 +132,4 @@ function NostrConfirm() {
115
132
) ;
116
133
}
117
134
118
- export default NostrConfirm ;
135
+ export default NostrConfirmEncryptOrDecrypt ;
0 commit comments