Skip to content

Commit 7ebe932

Browse files
committed
improve no results message
1 parent eabd4b9 commit 7ebe932

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

clients/admin-ui/src/features/consent-reporting/ConsentLookupModal.tsx

+10-5
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ interface ConsentLookupModalProps {
2929
const ConsentLookupModal = ({ isOpen, onClose }: ConsentLookupModalProps) => {
3030
const [isSearching, setIsSearching] = useState(false);
3131
const [searchResults, setSearchResults] = useState<
32-
PreferenceWithNoticeInformation[]
33-
>([]);
32+
PreferenceWithNoticeInformation[] | undefined
33+
>();
3434
const [getCurrentPrivacyPreferencesTrigger] =
3535
useLazyGetCurrentPrivacyPreferencesQuery();
3636

@@ -41,7 +41,8 @@ const ConsentLookupModal = ({ isOpen, onClose }: ConsentLookupModalProps) => {
4141
const { data, isError, error } = await getCurrentPrivacyPreferencesTrigger({
4242
search,
4343
});
44-
if (isError) {
44+
const errorStatus = error && "status" in error && error?.status;
45+
if (isError && errorStatus !== 404) {
4546
const errorMsg = getErrorMessage(
4647
error,
4748
`A problem occurred while looking up the preferences.`,
@@ -57,7 +58,7 @@ const ConsentLookupModal = ({ isOpen, onClose }: ConsentLookupModalProps) => {
5758
const columns = useConsentLookupTableColumns();
5859
const tableInstance = useReactTable<PreferenceWithNoticeInformation>({
5960
getCoreRowModel: getCoreRowModel(),
60-
data: searchResults,
61+
data: searchResults || [],
6162
columns,
6263
getRowId: (row) => `${row.privacy_notice_history_id}`,
6364
manualPagination: true,
@@ -105,7 +106,11 @@ const ConsentLookupModal = ({ isOpen, onClose }: ConsentLookupModalProps) => {
105106
tableInstance={tableInstance}
106107
emptyTableNotice={
107108
<Empty
108-
description="Search for an email, phone number, or device ID."
109+
description={
110+
searchResults === undefined
111+
? "Search for an email, phone number, or device ID."
112+
: "No results found."
113+
}
109114
image={Empty.PRESENTED_IMAGE_SIMPLE}
110115
imageStyle={{ marginBottom: 15 }}
111116
/>

0 commit comments

Comments
 (0)