Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

feat(demo): added demo mock for documents search endpoint (#48)

Corentin THOMASSET694e55565577
diff --git a/apps/papra-client/src/modules/command-palette/command-palette.provider.tsx b/apps/papra-client/src/modules/command-palette/command-palette.provider.tsx
index e2903eb7..f6b7315c 100644
--- a/apps/papra-client/src/modules/command-palette/command-palette.provider.tsx
+++ b/apps/papra-client/src/modules/command-palette/command-palette.provider.tsx
@@ -132,7 +132,7 @@ export const CommandPaletteProvider: ParentComponent = (props) => {
onOpenChange={setIsCommandPaletteOpen}
>
- <CommandInput placeholder="Search commands" onValueChange={setSearchQuery} />
+ <CommandInput onValueChange={setSearchQuery} placeholder="Search commands or documents" />
<CommandList>
<Show when={getIsLoading()}>
<CommandLoading>
diff --git a/apps/papra-client/src/modules/demo/demo-api-mock.ts b/apps/papra-client/src/modules/demo/demo-api-mock.ts
index 0ca3de66..dc09d811 100644
--- a/apps/papra-client/src/modules/demo/demo-api-mock.ts
+++ b/apps/papra-client/src/modules/demo/demo-api-mock.ts
@@ -146,6 +146,32 @@ const inMemoryApiMock: Record<string, { handler: any }> = {
},
}),
+ ...defineHandler({
+ path: '/api/organizations/:organizationId/documents/search',
+ method: 'GET',
+ handler: async ({ params: { organizationId }, query }) => {
+ const {
+ pageIndex = 0,
+ pageSize = 5,
+ searchQuery = '',
+ } = query ?? {};
+
+ const organization = organizationStorage.getItem(organizationId);
+ assert(organization, { status: 403 });
+
+ const allKeys = await documentStorage.getKeys();
+ const keys = allKeys.filter(key => key.startsWith(organizationId));
+
+ const documents = await Promise.all(keys.map(key => documentStorage.getItem(key)));
+
+ const filteredDocuments = documents.filter(document => document?.name.includes(searchQuery));
+
+ return {
+ documents: filteredDocuments.slice(pageIndex * pageSize, (pageIndex + 1) * pageSize),
+ };
+ },
+ }),
+
...defineHandler({
path: '/api/organizations/:organizationId/documents/:documentId',
method: 'DELETE',