Skip to content

Commit

Permalink
Merge pull request #1945 from ever-co/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored Dec 3, 2023
2 parents b1efaf0 + fcc256e commit 2aff84c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
2 changes: 1 addition & 1 deletion apps/web/app/hooks/features/useLanguageSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function useLanguageSettings() {
if (user) {
return queryCall(user.role.isSystem).then((res) => {
setLanguages(
res?.data?.data?.items.filter((item) => APPLICATION_LANGUAGES_CODE.includes(item.code)) || []
res?.data?.data?.items.filter((item: any) => APPLICATION_LANGUAGES_CODE.includes(item.code)) || []
);
return res;
});
Expand Down
16 changes: 11 additions & 5 deletions apps/web/app/hooks/features/useTeamInvitations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { useQuery } from '../useQuery';
import { useAuthenticateUser } from './useAuthenticateUser';

export function useTeamInvitations() {
const { user } = useAuthenticateUser();

const setTeamInvitations = useSetRecoilState(teamInvitationsState);
const [myInvitationsList, setMyInvitationsList] = useRecoilState(myInvitationsState);

Expand Down Expand Up @@ -57,12 +59,12 @@ export function useTeamInvitations() {
);

useEffect(() => {
if (activeTeamId && firstLoad && isTeamManager) {
queryCall().then((res) => {
if (activeTeamId && firstLoad && isTeamManager && user?.tenantId) {
queryCall(user?.tenantId, user.employee.organizationId, 'EMPLOYEE', activeTeamId).then((res) => {
setTeamInvitations(res.data?.items || []);
});
}
}, [activeTeamId, firstLoad, isTeamManager, queryCall, setTeamInvitations]);
}, [activeTeamId, firstLoad, isTeamManager, queryCall, setTeamInvitations, user]);

useEffect(() => {
if (firstLoad) {
Expand All @@ -87,11 +89,15 @@ export function useTeamInvitations() {
);

const myInvitations = useCallback(() => {
myInvitationsQueryCall().then((res) => {
if (!user?.tenantId) {
return;
}

myInvitationsQueryCall(user.tenantId).then((res) => {
setMyInvitationsList(res.data.items);
return res.data;
});
}, [myInvitationsQueryCall, setMyInvitationsList]);
}, [myInvitationsQueryCall, setMyInvitationsList, user]);
const removeMyInvitation = useCallback(
(id: string) => {
setMyInvitationsList(myInvitationsList.filter((invitation) => invitation.id !== id));
Expand Down
26 changes: 20 additions & 6 deletions apps/web/app/services/client/api/invite.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import { PaginationResponse } from '@app/interfaces/IDataResponse';
import { IInvitation, IInviteRequest, IMyInvitations, MyInvitationActionEnum, CreateResponse } from '@app/interfaces';
import api from '../axios';
import { IInvitation, IInviteRequest, MyInvitationActionEnum, CreateResponse } from '@app/interfaces';
import api, { get } from '../axios';

export function inviteByEmailsAPI(data: IInviteRequest) {
return api.post<PaginationResponse<IInvitation>>('/invite/emails', data);
}

export function getTeamInvitationsAPI() {
return api.get<PaginationResponse<IInvitation>>('/invite');
export async function getTeamInvitationsAPI(tenantId: string, organizationId: string, role: string, teamId: string) {
const query = new URLSearchParams({
'where[tenantId]': tenantId,
'where[organizationId]': organizationId,
'where[role][name]': role,
'where[teams][id][0]': teamId,
'where[status]': 'INVITED'
});

const endpoint = `/invite?${query.toString()}`;
const data = await get(endpoint, true, { tenantId });

return process.env.NEXT_PUBLIC_GAUZY_API_SERVER_URL ? data.data : data;
}

export function removeTeamInvitationsAPI(invitationId: string) {
Expand All @@ -20,8 +31,11 @@ export function resendTeamInvitationsAPI(inviteId: string) {
});
}

export function getMyInvitationsAPI() {
return api.get<PaginationResponse<IMyInvitations>>('/invite/me');
export async function getMyInvitationsAPI(tenantId: string) {
const endpoint = '/invite/me';
const data = await get(endpoint, true, { tenantId });

return process.env.NEXT_PUBLIC_GAUZY_API_SERVER_URL ? data.data : data;
}

export function acceptRejectMyInvitationsAPI(invitationId: string, action: MyInvitationActionEnum) {
Expand Down
10 changes: 6 additions & 4 deletions apps/web/app/services/client/api/languages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ILanguageItemList, CreateResponse, PaginationResponse } from '@app/interfaces';
import api from '../axios';
import { get } from '../axios';

export function getLanguageListAPI(is_system: boolean) {
return api.get<CreateResponse<PaginationResponse<ILanguageItemList>>>(`/languages?is_system=${is_system}`);
export async function getLanguageListAPI(is_system: boolean) {
const endpoint = `/languages?is_system=${is_system}`;
const data = await get(endpoint, true);

return process.env.NEXT_PUBLIC_GAUZY_API_SERVER_URL ? data.data : data;
}

0 comments on commit 2aff84c

Please sign in to comment.