Skip to content

Commit a2de1a5

Browse files
committed
add error message for invalid pubkey
1 parent bd4301e commit a2de1a5

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/components/header/Header.styles.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { BaseCol } from '../common/BaseCol/BaseCol';
77

88
export const HeaderActionWrapper = styled.div`
99
cursor: pointer;
10+
position: relative;
1011
1112
& > .ant-btn > span[role='img'],
1213
.ant-badge {
@@ -22,6 +23,18 @@ export const HeaderActionWrapper = styled.div`
2223
}
2324
`;
2425

26+
export const InvalidPubkey = styled.div`
27+
position: absolute;
28+
top: 3rem;
29+
left: 2rem;
30+
width: 100%;
31+
color: var(--error-color);
32+
height: 100%;
33+
display: flex;
34+
align-items: center;
35+
font-weight: bold;
36+
`;
37+
2538
export const DropdownCollapse = styled(BaseCollapse)`
2639
& > .ant-collapse-item > .ant-collapse-header {
2740
font-weight: 600;

src/components/header/components/HeaderSearch/HeaderSearch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const HeaderSearch: React.FC = () => {
3737

3838
useEffect(() => {
3939
setModalOpen(false);
40-
setOverlayOpen(false);
40+
//setOverlayOpen(false);
4141
}, [pathname]);
4242

4343
return (

src/components/header/components/searchDropdown/SearchDropdown.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { BasePopover } from '@app/components/common/BasePopover/BasePopover';
88
import { NDKUserProfile, useNDK } from '@nostr-dev-kit/ndk-hooks';
99
import usePaidSubscribers from '@app/hooks/usePaidSubscribers';
1010
import { convertNDKUserProfileToSubscriberProfile } from '@app/utils/utils';
11+
import { InvalidPubkey } from '../../Header.styles';
12+
1113
import { SubscriberProfile } from '@app/hooks/usePaidSubscribers';
1214
import { SubscriberDetailModal } from '@app/components/relay-dashboard/paid-subscribers/SubscriberDetailModal';
1315
interface SearchOverlayProps {
@@ -30,6 +32,7 @@ export const SearchDropdown: React.FC<SearchOverlayProps> = ({
3032
const [fetchingProfile, setFetchingProfile] = useState(false);
3133
const [fetchingFailed, setFetchingFailed] = useState(false);
3234
const [subscriberProfile, setSubscriberProfile] = useState<SubscriberProfile | null>(null);
35+
const [invalidPubkey, setInvalidPubkey] = useState(false);
3336
const { subscribers } = usePaidSubscribers();
3437
const ndkInstance = useNDK();
3538
const { t } = useTranslation();
@@ -95,12 +98,20 @@ export const SearchDropdown: React.FC<SearchOverlayProps> = ({
9598
setSubscriberProfile(subscriberProfile);
9699
}
97100
}
101+
}else{
102+
setInvalidPubkey(true);
98103
}
99104
};
100105
const onCloseSubscriberDetailModal = () => {
101106
setSubscriberDetailModalOpen(false);
102107
setSubscriberProfile(null);
103108
};
109+
110+
useEffect(() => {
111+
if(query.length === 0) {
112+
setInvalidPubkey(false);
113+
}
114+
}, [query]);
104115
return (
105116
<>
106117
<BasePopover
@@ -111,6 +122,11 @@ export const SearchDropdown: React.FC<SearchOverlayProps> = ({
111122
getPopupContainer={() => ref.current}
112123
>
113124
<HeaderActionWrapper>
125+
{invalidPubkey && (
126+
<InvalidPubkey>
127+
{"Invalid pubkey. Please enter a hexadecimal string."}
128+
</InvalidPubkey>
129+
)}
114130
<InputSearch
115131
width="100%"
116132
value={query}

0 commit comments

Comments
 (0)