Skip to content

Commit

Permalink
feat(SPV-806): Adjust to new search contact method (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
pawellewandowski98 authored May 23, 2024
1 parent e01eb9b commit 77fa155
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/api/requests/contact.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { PaginationParams } from '../types';
import { Contact, ContactMetadata } from '../types/contact';
import axios from 'axios';

export const searchContacts = async (_pagination?: PaginationParams) => {
const { data: response } = await axios.get(`/contact/search`);
export const searchContacts = async (pagination?: PaginationParams) => {
const { data: response } = await axios.post(`/contact/search`, {
params: pagination
});
return response;
};

Expand Down
2 changes: 1 addition & 1 deletion src/api/requests/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SendNewTransaction } from '@/api/types';
import { PaginationParams } from '../types/pagination';

export const getTransactions = async (pagination: PaginationParams) => {
const { data: response } = await axios.get(`/transaction`, {
const { data: response } = await axios.post(`/transaction/search`, {
params: pagination,
});
if (response != null && typeof response !== 'object') {
Expand Down
11 changes: 9 additions & 2 deletions src/providers/contacts/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { searchContacts } from '@/api/requests/contact';
import { Contact } from '@/api/types/contact';
import { PaginationParams } from '@/api/types';
import { usePikeEnabled } from '@/hooks/useFeatureFlags';
import { FC, PropsWithChildren, createContext, useCallback, useEffect, useMemo, useState } from 'react';
import { useAuthorization } from '../authorization';
Expand All @@ -26,8 +27,14 @@ export const ContactsProvider: FC<PropsWithChildren> = ({ children }) => {
}
setLoading(true);
try {
const contacts = await searchContacts();
setContacts(contacts);
const paginationParams : PaginationParams = {
page: 1,
page_size: 1000,
order: 'paymail',
sort: 'asc',
}
const contactsResponse = await searchContacts(paginationParams);
setContacts(contactsResponse.content);
} catch {
setContacts(null);
setError(true);
Expand Down

0 comments on commit 77fa155

Please sign in to comment.