working displaying contacts, but of course not nice

This commit is contained in:
talksik
2022-03-20 18:24:50 -04:00
parent b491eee62c
commit b9f93d741d
5 changed files with 102 additions and 6 deletions
+25
View File
@@ -2,6 +2,7 @@ import { $authTokens, $searchQuery } from "./recoil";
import axios, { AxiosResponse } from "axios";
import { useMutation, useQuery } from "react-query";
import GetContactsResponse from "../../../core/responses/getContacts.response";
import GetConversationDetailsResponse from "@nirvana/core/responses/getConversationDetails.response";
import { ObjectId } from "mongodb";
import { RelationshipState } from "@nirvana/core/models/relationship.model";
@@ -77,11 +78,23 @@ const updateContactRequestState = async (
return response.data;
};
const getContactsBasicDetails = async (idToken: string) => {
const response = await axios.get<GetContactsResponse>(
localHost + `/contacts`,
{
headers: { Authorization: idToken },
}
);
return response.data;
};
// ====== QUERIES
export enum Querytypes {
GET_USER_DETAILS = "GET_USER_DETAILS",
GET_SEARCH_RESULTS = "GET_SEARCH_RESULTS",
GET_CONVERSATION_DETAILS = "GET_CONVERSATION_DETAILS",
GET_CONTACTS_RELATIONSHIPS = "GET_CONTACTS_RELATIONSHIPS",
}
export function useGetUserDetails() {
const authTokens = useRecoilValue($authTokens);
@@ -117,6 +130,18 @@ export function useConversationDetails(otherUserGoogleId: string) {
);
}
export function useGetAllContactBasicDetails() {
const authTokens = useRecoilValue($authTokens);
return useQuery(
Querytypes.GET_CONTACTS_RELATIONSHIPS,
() => getContactsBasicDetails(authTokens.idToken),
{
refetchOnWindowFocus: false,
}
);
}
// =========== MUTATIONS
export function useSendContactRequest() {