Skip to content

Commit

Permalink
Merge pull request #46 from atlp-rwanda/configuring-new-server
Browse files Browse the repository at this point in the history
finishes some configuration
  • Loading branch information
niyontwali authored Jul 22, 2024
2 parents 8ac8cde + 8faf634 commit a6ea4c6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/services/chatApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ import { ChatMessage } from '../types/Types';
import io from 'socket.io-client';

const token = localStorage.getItem('token');

export const chatApi = mavericksApi.injectEndpoints({
endpoints: builder => ({
getMessages: builder.query<{ chat: ChatMessage[] }, string>({
query: token => ({
query: () => ({
url: 'chats',
headers: {
Authorization: token,
},
}),
async onCacheEntryAdded(arg, { updateCachedData, cacheDataLoaded, cacheEntryRemoved }) {
if (typeof arg !== 'undefined') {
const socket = io('https://e-commerce-mavericcks-bn-staging-istf.onrender.com', { auth: { token } });
const socket = io('https://mavericks.nijohn.dev', { auth: { token } });
try {
await cacheDataLoaded;
socket.on('returnMessage', newMessage => {
Expand All @@ -32,7 +30,7 @@ export const chatApi = mavericksApi.injectEndpoints({
}),
sendMessage: builder.mutation<void, { content: string; senderId: string }>({
queryFn: body => {
const socket = io('https://e-commerce-mavericcks-bn-staging-istf.onrender.com/', {
const socket = io('https://mavericks.nijohn.dev', {
auth: { token },
});
socket.emit('sentMessage', body);
Expand Down
2 changes: 1 addition & 1 deletion src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RootState } from '../redux/store';
export const mavericksApi = createApi({
reducerPath: 'mavericksApi',
baseQuery: fetchBaseQuery({
baseUrl: 'https://e-commerce-mavericcks-bn-staging-istf.onrender.com/api/',
baseUrl: 'https://mavericks.nijohn.dev/api/',
prepareHeaders: (headers, { getState }) => {
const token = (getState() as RootState).user.token;
if (token) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/handleGoogleAuthentication.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const handleGoogleAuthentication = (e: any) => {
e.preventDefault();
window.location.assign('https://e-commerce-mavericcks-bn-staging-istf.onrender.com/api/auth/google');
window.location.assign('https://mavericks.nijohn.dev/api/auth/google');
};

export default handleGoogleAuthentication;

0 comments on commit a6ea4c6

Please sign in to comment.