Skip to content

Commit

Permalink
Merge pull request #2015 from ever-co/feat/cardOrder
Browse files Browse the repository at this point in the history
Feat/cardOrder:  make cards element (of list view) draggable
  • Loading branch information
evereq authored Dec 27, 2023
2 parents c1e94e9 + 8151a3d commit 305b2c3
Show file tree
Hide file tree
Showing 11 changed files with 269 additions and 105 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@
"plasmohq",
"Proguard",
"horcrux",
"dimesions"
"dimesions",
"Ordereds"
],
"useGitignore": true,
"ignorePaths": [
Expand Down
167 changes: 82 additions & 85 deletions apps/mobile/app/services/client/requests/organization-team.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,39 @@
/* eslint-disable camelcase */
import moment from "moment"
import { PaginationResponse } from "../../interfaces/IDataResponse"
import moment from 'moment';
import { PaginationResponse } from '../../interfaces/IDataResponse';
import {
IOrganizationTeam,
IOrganizationTeamCreate,
IOrganizationTeamList,
IOrganizationTeamUpdate,
IOrganizationTeamWithMStatus,
} from "../../interfaces/IOrganizationTeam"
import { serverFetch } from "../fetch"
IOrganizationTeamWithMStatus
} from '../../interfaces/IOrganizationTeam';
import { serverFetch } from '../fetch';

export function createOrganizationTeamRequest(
datas: IOrganizationTeamCreate,
bearer_token: string,
) {
export function createOrganizationTeamRequest(datas: IOrganizationTeamCreate, bearer_token: string) {
return serverFetch<IOrganizationTeam>({
path: "/organization-team",
method: "POST",
path: '/organization-team',
method: 'POST',
body: datas,
bearer_token,
})
bearer_token
});
}

export function updateOrganizationTeamRequest({
id,
datas,
bearer_token,
bearer_token
}: {
datas: IOrganizationTeamList | IOrganizationTeamCreate
id: string
bearer_token: string
datas: IOrganizationTeamList | IOrganizationTeamCreate;
id: string;
bearer_token: string;
}) {
return serverFetch<IOrganizationTeamList>({
path: `/organization-team/${id}`,
method: "PUT",
method: 'PUT',
body: datas,
bearer_token,
})
bearer_token
});
}

export function getOrganizationTeamRequest(
Expand All @@ -45,131 +42,131 @@ export function getOrganizationTeamRequest(
tenantId,
teamId,
relations = [
"members",
"members.role",
"members.employee",
"members.employee.user",
"createdBy",
"createdBy.employee",
"projects",
],
'members',
'members.role',
'members.employee',
'members.employee.user',
'createdBy',
'createdBy.employee',
'projects'
]
}: TeamRequestParams & { teamId: string },
bearer_token: string,
bearer_token: string
) {
const params = {
organizationId,
tenantId,
// source: "BROWSER",
withLaskWorkedTask: "true",
startDate: moment().startOf("day").toISOString(),
endDate: moment().endOf("day").toISOString(),
includeOrganizationTeamId: "false",
} as { [x: string]: string }
withLaskWorkedTask: 'true',
startDate: moment().startOf('day').toISOString(),
endDate: moment().endOf('day').toISOString(),
includeOrganizationTeamId: 'false'
} as { [x: string]: string };

relations.forEach((rl, i) => {
params[`relations[${i}]`] = rl
})
params[`relations[${i}]`] = rl;
});

const queries = new URLSearchParams(params || {})
const queries = new URLSearchParams(params || {});
return serverFetch<IOrganizationTeamWithMStatus>({
path: `/organization-team/${teamId}?${queries.toString()}`,
method: "GET",
method: 'GET',
bearer_token,
tenantId,
})
tenantId
});
}

type TeamRequestParams = {
organizationId: string
tenantId: string
relations?: string[]
}
organizationId: string;
tenantId: string;
relations?: string[];
};

export function getAllOrganizationTeamRequest(
{
organizationId,
tenantId,
relations = [
"members",
"members.role",
"members.employee",
"members.employee.user",
"createdBy",
"createdBy.employee",
],
'members',
'members.role',
'members.employee',
'members.employee.user',
'createdBy',
'createdBy.employee'
]
}: TeamRequestParams,
bearer_token: string,
bearer_token: string
) {
const params = {
"where[organizationId]": organizationId,
"where[tenantId]": tenantId,
source: "BROWSER",
withLaskWorkedTask: "true",
} as { [x: string]: string }
'where[organizationId]': organizationId,
'where[tenantId]': tenantId,
source: 'BROWSER',
withLaskWorkedTask: 'true'
} as { [x: string]: string };

relations.forEach((rl, i) => {
params[`relations[${i}]`] = rl
})
params[`relations[${i}]`] = rl;
});

const query = new URLSearchParams(params)
const query = new URLSearchParams(params);

return serverFetch<PaginationResponse<IOrganizationTeamList>>({
path: `/organization-team?${query.toString()}`,
method: "GET",
method: 'GET',
bearer_token,
tenantId,
})
tenantId
});
}

export function removeEmployeeOrganizationTeamRequest({
employeeId,
bearer_token,
tenantId,
tenantId
}: {
employeeId: string
bearer_token: string
tenantId: string
employeeId: string;
bearer_token: string;
tenantId: string;
}) {
return serverFetch<boolean>({
path: `/organization-team-employee/${employeeId}`,
method: "DELETE",
method: 'DELETE',
bearer_token,
tenantId,
})
tenantId
});
}

export function removeUserFromAllTeam({
userId,
bearer_token,
tenantId,
tenantId
}: {
userId: string
bearer_token: string
tenantId: string
userId: string;
bearer_token: string;
tenantId: string;
}) {
return serverFetch({
path: `/organization-team/teams/${userId}`,
method: "DELETE",
method: 'DELETE',
bearer_token,
tenantId,
})
tenantId
});
}

export function deleteOrganizationTeamRequest({
id,
bearer_token,
tenantId,
organizationId,
organizationId
}: {
id: string
bearer_token: string
tenantId: string
organizationId: string
id: string;
bearer_token: string;
tenantId: string;
organizationId: string;
}) {
return serverFetch<IOrganizationTeamUpdate>({
path: `/organization-team/${id}?organizationId=${organizationId}`,
method: "DELETE",
method: 'DELETE',
bearer_token,
tenantId,
})
tenantId
});
}
33 changes: 31 additions & 2 deletions apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IOrganizationTeamEmployeeUpdate } from '@app/interfaces';
import { IOrganizationTeamEmployeeUpdate, OT_Member } from '@app/interfaces';
import {
deleteOrganizationEmployeeTeamAPI,
updateOrganizationEmployeeTeamAPI,
Expand All @@ -7,9 +7,13 @@ import {
import { useCallback } from 'react';
import { useQuery } from '../useQuery';
import { useOrganizationTeams } from './useOrganizationTeams';
import { editEmployeeOrderOrganizationTeamAPI } from '@app/services/client/api';
import { userState } from '@app/stores';
import { useRecoilState } from 'recoil';

export function useOrganizationEmployeeTeams() {
const { loadTeamsData } = useOrganizationTeams();
const [user] = useRecoilState(userState);

const { loading: deleteOrganizationEmployeeTeamLoading, queryCall: deleteQueryCall } = useQuery(
deleteOrganizationEmployeeTeamAPI
Expand All @@ -19,6 +23,10 @@ export function useOrganizationEmployeeTeams() {
updateOrganizationEmployeeTeamAPI
);

const { loading: editEmployeeIndexOrganizationTeamLoading, queryCall: updateOrderCall } = useQuery(
editEmployeeOrderOrganizationTeamAPI
);

const {
loading: updateOrganizationTeamEmployeeActiveTaskLoading,
queryCall: updateOrganizationTeamEmployeeActiveTaskQueryCall
Expand Down Expand Up @@ -59,6 +67,25 @@ export function useOrganizationEmployeeTeams() {
[loadTeamsData, updateQueryCall]
);

const updateOrganizationTeamEmployeeOrderOnList = useCallback(
(employee: OT_Member, order: number) => {
updateOrderCall(
employee.id,
{
order,
organizationTeamId: employee.organizationTeamId,
organizationId: employee.organizationId
},
user?.tenantId || ''
).then((res) => {
loadTeamsData();
return res;
});
},

[loadTeamsData, updateOrderCall, user]
);

const updateOrganizationTeamEmployeeActiveTask = useCallback(
(id: string, data: Partial<IOrganizationTeamEmployeeUpdate>) => {
updateOrganizationTeamEmployeeActiveTaskQueryCall(id, data).then((res) => {
Expand All @@ -75,6 +102,8 @@ export function useOrganizationEmployeeTeams() {
updateOrganizationEmployeeTeamLoading,
updateOrganizationTeamEmployee,
updateOrganizationTeamEmployeeActiveTaskLoading,
updateOrganizationTeamEmployeeActiveTask
updateOrganizationTeamEmployeeActiveTask,
editEmployeeIndexOrganizationTeamLoading,
updateOrganizationTeamEmployeeOrderOnList
};
}
1 change: 1 addition & 0 deletions apps/web/app/interfaces/IOrganizationEmployeeTeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface IOrganizationTeamEmployeeCreate {
roleId?: string;
isTrackingEnabled?: boolean;
activeTaskId?: string;
order?: number;
}
export interface IOrganizationTeamEmployeeUpdate extends IOrganizationTeamEmployeeCreate {
id: string;
Expand Down
1 change: 1 addition & 0 deletions apps/web/app/interfaces/IOrganizationTeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export type IOrganizationTeamWithMStatus = IOrganizationTeamList;

export interface OT_Member {
id: string;
order?: number;
createdAt: string;
updatedAt: string;
tenantId: any;
Expand Down
13 changes: 12 additions & 1 deletion apps/web/app/services/client/api/organization-team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
IOrganizationTeamWithMStatus,
IOrganizationTeamUpdate,
IOrganizationTeam,
TimerSource
TimerSource,
OT_Member
} from '@app/interfaces';
import moment from 'moment';
import api, { get } from '../axios';
Expand Down Expand Up @@ -92,6 +93,16 @@ export function removeEmployeeOrganizationTeamAPI(employeeId: string) {
return api.delete<boolean>(`/organization-team/employee/${employeeId}`);
}

export function editEmployeeOrderOrganizationTeamAPI(
employeeId: string,
data: { order: number; organizationTeamId: string; organizationId: string },
tenantId?: string
) {
return api.put<CreateResponse<OT_Member>>(`/organization-team/employee/${employeeId}`, data, {
headers: { 'Tenant-Id': tenantId }
});
}

export function removeUserFromAllTeamAPI(userId: string) {
return api.delete<DeleteResponse | CreateResponse<ISuccessResponse>>(`/organization-team/teams/${userId}`);
}
Loading

0 comments on commit 305b2c3

Please sign in to comment.