searchHistoryService.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. import { SearchHistoryItem, SearchHistoryDetail } from '../types';
  2. import { apiClient } from './apiClient';
  3. export const searchHistoryService = {
  4. // 検索履歴リストの取得
  5. async getHistories(page: number = 1, limit: number = 20): Promise<{
  6. histories: SearchHistoryItem[];
  7. total: number;
  8. page: number;
  9. limit: number;
  10. }> {
  11. const { data } = await apiClient.get(`/search-history?page=${page}&limit=${limit}`);
  12. return data;
  13. },
  14. // 検索履歴詳細の取得
  15. async getHistoryDetail(id: string): Promise<SearchHistoryDetail> {
  16. const { data } = await apiClient.get(`/search-history/${id}`);
  17. return data;
  18. },
  19. // 検索履歴の作成
  20. async createHistory(title: string, selectedGroups?: string[]): Promise<{ id: string }> {
  21. const { data } = await apiClient.post(`/search-history`, { title, selectedGroups });
  22. return data;
  23. },
  24. // 検索履歴の削除
  25. async deleteHistory(id: string): Promise<void> {
  26. await apiClient.delete(`/search-history/${id}`);
  27. },
  28. };