hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import { appendPageParams, client } from "../client"; |
| 2 | import type { Page, PageParams } from "../client"; |
| 3 | import type { Message, MessageFolder } from "../client"; |
| 4 | |
| 5 | export function getMessages( |
| 6 | folder: MessageFolder = "inbox", |
| 7 | options?: PageParams & { read?: boolean; q?: string } |
| 8 | ): Promise<Page<Message>> { |
| 9 | const params = new URLSearchParams(); |
| 10 | params.set("folder", folder); |
| 11 | if (options?.read !== undefined) params.set("read", String(options.read)); |
| 12 | // Free-text search is server-side; blank after trim means no filter. |
| 13 | const q = options?.q?.trim(); |
| 14 | if (q) params.set("q", q); |
| 15 | appendPageParams(params, options); |
| 16 | |
| 17 | const query = params.toString(); |
| 18 | const url = query ? `/messages?${query}` : `/messages`; |
| 19 | return client<Page<Message>>(url); |
| 20 | } |