Skip to content

Commit c7a49ea

Browse files
committed
refactor: remove oramaProvider
1 parent 9cb58f6 commit c7a49ea

File tree

3 files changed

+53
-79
lines changed

3 files changed

+53
-79
lines changed

apps/site/components/Common/Searchbox/index.tsx

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,64 +6,54 @@ import { useTranslations } from 'next-intl';
66
import type { FC } from 'react';
77

88
import '@orama/ui/styles.css';
9-
10-
import { OramaProvider, useOrama } from '#site/providers/oramaProvider';
119
import { SearchboxProvider } from '#site/providers/searchboxProvider';
1210

1311
import styles from './index.module.css';
1412
import { InnerSearchboxModal } from './InnerSearchboxModal';
13+
import { oramaClient } from './orama-client';
1514

1615
const Searchbox: FC = () => {
17-
const orama = useOrama();
1816
const t = useTranslations();
1917

2018
return (
21-
<div className={styles.searchboxContainer}>
22-
<Modal.Root>
23-
<Modal.Trigger
24-
type="button"
25-
disabled={!orama}
26-
enableCmdK
27-
className={styles.searchButton}
28-
>
29-
<div className={styles.searchButtonContent}>
30-
<MagnifyingGlassIcon />
31-
{t('components.search.searchPlaceholder')}
32-
</div>
33-
<span className={styles.searchButtonShortcut}>⌘ K</span>
34-
</Modal.Trigger>
35-
36-
<Modal.Wrapper
37-
closeOnOutsideClick
38-
closeOnEscape
39-
className={styles.modalWrapper}
40-
>
41-
<SearchRoot client={orama ?? null}>
42-
<ChatRoot
43-
client={orama ?? null}
44-
askOptions={{ throttle_delay: 50 }}
45-
>
46-
<Modal.Inner className={styles.modalInner}>
47-
<Modal.Content className={styles.modalContent}>
48-
<InnerSearchboxModal />
49-
</Modal.Content>
50-
</Modal.Inner>
51-
</ChatRoot>
52-
</SearchRoot>
53-
</Modal.Wrapper>
54-
</Modal.Root>
55-
</div>
56-
);
57-
};
58-
59-
const OramaSearchWrapper = () => {
60-
return (
61-
<OramaProvider>
62-
<SearchboxProvider>
63-
<Searchbox />
64-
</SearchboxProvider>
65-
</OramaProvider>
19+
<SearchboxProvider>
20+
<div className={styles.searchboxContainer}>
21+
<Modal.Root>
22+
<Modal.Trigger
23+
type="button"
24+
disabled={!oramaClient}
25+
enableCmdK
26+
className={styles.searchButton}
27+
>
28+
<div className={styles.searchButtonContent}>
29+
<MagnifyingGlassIcon />
30+
{t('components.search.searchPlaceholder')}
31+
</div>
32+
<span className={styles.searchButtonShortcut}>⌘ K</span>
33+
</Modal.Trigger>
34+
35+
<Modal.Wrapper
36+
closeOnOutsideClick
37+
closeOnEscape
38+
className={styles.modalWrapper}
39+
>
40+
<SearchRoot client={oramaClient}>
41+
<ChatRoot
42+
client={oramaClient}
43+
askOptions={{ throttle_delay: 50 }}
44+
>
45+
<Modal.Inner className={styles.modalInner}>
46+
<Modal.Content className={styles.modalContent}>
47+
<InnerSearchboxModal />
48+
</Modal.Content>
49+
</Modal.Inner>
50+
</ChatRoot>
51+
</SearchRoot>
52+
</Modal.Wrapper>
53+
</Modal.Root>
54+
</div>
55+
</SearchboxProvider>
6656
);
6757
};
6858

69-
export default OramaSearchWrapper;
59+
export default Searchbox;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { OramaCloud } from '@orama/core';
2+
3+
import {
4+
ORAMA_CLOUD_PROJECT_ID,
5+
ORAMA_CLOUD_READ_API_KEY,
6+
} from '#site/next.constants.mjs';
7+
8+
export const oramaClient =
9+
ORAMA_CLOUD_PROJECT_ID && ORAMA_CLOUD_READ_API_KEY
10+
? new OramaCloud({
11+
projectId: ORAMA_CLOUD_PROJECT_ID,
12+
apiKey: ORAMA_CLOUD_READ_API_KEY,
13+
})
14+
: null;

apps/site/providers/oramaProvider.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)