Skip to content

Commit

Permalink
Merge pull request #2359 from ever-co/stage
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored Apr 5, 2024
2 parents 8b6ac2b + 22a5165 commit 6589f66
Show file tree
Hide file tree
Showing 15 changed files with 351 additions and 134 deletions.
2 changes: 1 addition & 1 deletion .deploy/k8s/k8s-manifest-api.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apiVersion: apps/v1
metadata:
name: ever-teams-prod-api
spec:
replicas: 6
replicas: 3
selector:
matchLabels:
app: ever-teams-prod-api
Expand Down
2 changes: 1 addition & 1 deletion .deploy/k8s/k8s-manifest-api.stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apiVersion: apps/v1
metadata:
name: ever-teams-stage-api
spec:
replicas: 3
replicas: 2
selector:
matchLabels:
app: ever-teams-stage-api
Expand Down
2 changes: 1 addition & 1 deletion .deploy/k8s/k8s-manifest.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ apiVersion: apps/v1
metadata:
name: ever-teams-prod-webapp
spec:
replicas: 8
replicas: 4
selector:
matchLabels:
app: ever-teams-prod-webapp
Expand Down
22 changes: 16 additions & 6 deletions apps/mobile/app/services/client/requests/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,30 @@ type IUEmployeeParam = {
relations?: string[];
};

/**
* Fetches details of the currently authenticated user.
*
* @param {IUEmployeeParam} The employee parameters, including bearer token and optional relations.
* @returns A Promise resolving to the IUser object with the desired relations and employee details.
*/
export const currentAuthenticatedUserRequest = ({
bearer_token,
relations = ['employee', 'role', 'tenant']
relations = ['role', 'tenant']
}: IUEmployeeParam) => {
const params = {} as { [x: string]: string };
// Create a new instance of URLSearchParams for query string construction
const query = new URLSearchParams();

relations.forEach((rl, i) => {
params[`relations[${i}]`] = rl;
// Append each relation to the query string
relations.forEach((relation, index) => {
query.append(`relations[${index}]`, relation);
});

const query = new URLSearchParams(params);
// Append includeEmployee parameter set to true
query.append('includeEmployee', 'true');

// Construct the fetch request with the query string
return serverFetch<IUser>({
path: `/user/me?${query.toString()}`,
path: `/user/me?${query}`,
method: 'GET',
bearer_token
});
Expand Down
52 changes: 31 additions & 21 deletions apps/mobile/app/services/client/requests/organization-team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ export function updateOrganizationTeamRequest({
});
}

/**
* Fetches detailed information for a specific team within an organization.
*
* @param {TeamRequestParams & { teamId: string }} params Parameters including organizationId, tenantId, teamId, and optional relations.
* @param {string} bearer_token Authentication token for the request.
* @returns A Promise resolving to the detailed information of the organization team with member status.
*/
export function getOrganizationTeamRequest(
{
organizationId,
Expand All @@ -47,29 +54,28 @@ export function getOrganizationTeamRequest(
'members.employee',
'members.employee.user',
'createdBy',
'createdBy.employee',
'projects'
]
}: TeamRequestParams & { teamId: string },
bearer_token: string
) {
const params = {
// Define query parameters
const queryParameters = {
organizationId,
tenantId,
// source: "BROWSER",
withLaskWorkedTask: 'true',
withLastWorkedTask: 'true', // Corrected the typo here
startDate: moment().startOf('day').toISOString(),
endDate: moment().endOf('day').toISOString(),
includeOrganizationTeamId: 'false'
} as { [x: string]: string };
includeOrganizationTeamId: 'false',
...Object.fromEntries(relations.map((relation, index) => [`relations[${index}]`, relation]))
};

relations.forEach((rl, i) => {
params[`relations[${i}]`] = rl;
});
// Construct the query string
const query = new URLSearchParams(queryParameters);

const queries = new URLSearchParams(params);
// Fetch and return the team data
return serverFetch<IOrganizationTeamWithMStatus>({
path: `/organization-team/${teamId}?${queries.toString()}`,
path: `/organization-team/${teamId}?${query.toString()}`,
method: 'GET',
bearer_token,
tenantId
Expand All @@ -82,6 +88,13 @@ type TeamRequestParams = {
relations?: string[];
};

/**
* Fetches a list of all teams within an organization, including specified relation data.
*
* @param {TeamRequestParams} params Contains organizationId, tenantId, and optional relation specifications.
* @param {string} bearer_token Token for request authentication.
* @returns A Promise resolving to a paginated response of organization team lists.
*/
export function getAllOrganizationTeamRequest(
{
organizationId,
Expand All @@ -91,24 +104,21 @@ export function getAllOrganizationTeamRequest(
'members.role',
'members.employee',
'members.employee.user',
'createdBy',
'createdBy.employee'
'createdBy'
]
}: TeamRequestParams,
bearer_token: string
) {
const params = {
// Define query parameters
const queryParameters = {
'where[organizationId]': organizationId,
'where[tenantId]': tenantId,
source: 'BROWSER',
withLaskWorkedTask: 'true'
} as { [x: string]: string };

relations.forEach((rl, i) => {
params[`relations[${i}]`] = rl;
});
withLaskWorkedTask: 'true',
...Object.fromEntries(relations.map((relation, index) => [`relations[${index}]`, relation]))
};

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

return serverFetch<PaginationResponse<IOrganizationTeamList>>({
path: `/organization-team?${query.toString()}`,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/[locale]/kanban/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const Kanban = () => {
{/* <div className="h-20 w-full bg-red-500/50"></div> */}
</Container>
</div>
<div className="mt-[256px] mb-52">
<div className="mt-[256px] mb-24">
{/** TODO:fetch teamtask based on days */}
{activeTab && ( // add filter for today, yesterday and tomorrow
<div>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/hooks/features/useKanban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ export function useKanban() {
};

const isColumnCollapse = (column: string) => {
const columnData = taskStatusHook.taskStatus.filter((taskStatus: ITaskStatusItemList) => {
const columnData = taskStatusHook.taskStatus.find((taskStatus: ITaskStatusItemList) => {
return taskStatus.name === column;
});

return columnData[0].isCollapsed;
return columnData?.isCollapsed;
};

const reorderStatus = (itemStatus: string, index: number) => {
Expand Down
18 changes: 12 additions & 6 deletions apps/web/app/services/client/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ import {
import qs from 'qs';
import { signInEmailConfirmGauzy, signInWorkspaceGauzy } from './auth/invite-accept';

/**
* Fetches data of the authenticated user with specified relations and the option to include employee details.
*
* @returns A Promise resolving to the IUser object.
*/
export const getAuthenticatedUserDataAPI = () => {
const params = {} as { [x: string]: string };
const relations = ['employee', 'role', 'tenant'];
// Define the relations to be included in the request
const relations = ['role', 'tenant'];

relations.forEach((rl, i) => {
params[`relations[${i}]`] = rl;
// Construct the query string with 'qs', including the includeEmployee parameter
const query = qs.stringify({
relations: relations,
includeEmployee: true // Append includeEmployee parameter set to true
});

const query = qs.stringify(params);

// Execute the GET request to fetch the user data
return get<IUser>(`/user/me?${query}`);
};

Expand Down
26 changes: 16 additions & 10 deletions apps/web/app/services/client/api/auth/invite-accept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,38 @@ export function getUserOrganizationsRequest(params: { tenantId: string; userId:
});
}

/**
* Fetches a list of all teams within an organization, including specified relation data.
*
* @param {ITeamRequestParams} params Parameters for the team request, including organization and tenant IDs, and optional relations.
* @param {string} bearer_token The bearer token for authentication.
* @returns A Promise resolving to the pagination response of organization teams.
*/
export function getAllOrganizationTeamAPI(params: ITeamRequestParams, bearer_token: string) {
const relations = params.relations || [
'members',
'members.role',
'members.employee',
'members.employee.user',
'createdBy',
'createdBy.employee',
'projects',
'projects.repository'
];

const searchQueries = {
// Construct search queries
const queryParams = {
'where[organizationId]': params.organizationId,
'where[tenantId]': params.tenantId,
source: TimerSource.TEAMS,
withLaskWorkedTask: 'true'
} as { [x: string]: string };

relations.forEach((rl, i) => {
searchQueries[`relations[${i}]`] = rl;
});
withLastWorkedTask: 'true', // Corrected the typo here
...Object.fromEntries(relations.map((relation, index) => [`relations[${index}]`, relation]))
};

const query = qs.stringify(params);
// Serialize search queries into a query string
const queryString = qs.stringify(queryParams, { arrayFormat: 'brackets' });

return get<PaginationResponse<IOrganizationTeamList>>(`/organization-team?${query}`, {
// Construct and execute the request
return get<PaginationResponse<IOrganizationTeamList>>(`/organization-team?${queryString}`, {
tenantId: params.tenantId,
headers: {
Authorization: `Bearer ${bearer_token}`
Expand Down
63 changes: 38 additions & 25 deletions apps/web/app/services/client/api/organization-team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,35 @@ import { getAccessTokenCookie, getOrganizationIdCookie, getTenantIdCookie } from
import { createOrganizationProjectAPI } from './projects';
import qs from 'qs';

/**
* Fetches a list of teams for a specified organization.
*
* @param {string} organizationId The unique identifier for the organization.
* @param {string} tenantId The tenant identifier.
* @returns A Promise resolving to a paginated response containing the list of organization teams.
*/
export async function getOrganizationTeamsAPI(organizationId: string, tenantId: string) {
const relations = [
'members',
'members.role',
'members.employee',
'members.employee.user',
'createdBy',
'createdBy.employee',
'projects',
'projects.repository'
];

const params = {
// Construct the query parameters including relations
const queryParameters = {
'where[organizationId]': organizationId,
'where[tenantId]': tenantId,
source: TimerSource.TEAMS,
withLaskWorkedTask: 'true'
} as { [x: string]: string };
withLastWorkedTask: 'true', // Corrected the typo here
relations
};

// Serialize parameters into a query string
const query = qs.stringify(queryParameters, { arrayFormat: 'brackets' });

relations.forEach((rl, i) => {
params[`relations[${i}]`] = rl;
});
const query = qs.stringify(params);
const endpoint = `/organization-team?${query}`;

return get<PaginationResponse<IOrganizationTeamList>>(endpoint, { tenantId });
Expand Down Expand Up @@ -84,36 +90,43 @@ export async function createOrganizationTeamAPI(name: string, user: IUser) {
return api.post<PaginationResponse<IOrganizationTeamList>>('/organization-team', { name });
}

/**
* Fetches details of a specific team within an organization.
*
* @param {string} teamId The unique identifier of the team.
* @param {string} organizationId The unique identifier of the organization.
* @param {string} tenantId The tenant identifier.
* @returns A Promise resolving to the details of the specified organization team.
*/
export async function getOrganizationTeamAPI(teamId: string, organizationId: string, tenantId: string) {
const params = {
organizationId: organizationId,
tenantId: tenantId,
// source: TimerSource.TEAMS,
withLaskWorkedTask: 'true',
startDate: moment().startOf('day').toISOString(),
endDate: moment().endOf('day').toISOString(),
includeOrganizationTeamId: 'false'
} as { [x: string]: string };

const relations = [
'members',
'members.role',
'members.employee',
'members.employee.user',
'createdBy',
'createdBy.employee',
'projects',
'projects.repository'
];

relations.forEach((rl, i) => {
params[`relations[${i}]`] = rl;
});
// Define base parameters including organization and tenant IDs, and date range
const queryParams = {
organizationId,
tenantId,
withLastWorkedTask: 'true', // Corrected the typo here
startDate: moment().startOf('day').toISOString(),
endDate: moment().endOf('day').toISOString(),
includeOrganizationTeamId: 'false',
relations
};

const queries = qs.stringify(params);
// Serialize parameters into a query string using 'qs'
const queryString = qs.stringify(queryParams, { arrayFormat: 'brackets' });

const endpoint = `/organization-team/${teamId}?${queries}`;
// Construct the endpoint URL
const endpoint = `/organization-team/${teamId}?${queryString}`;

// Fetch and return the team details
return get<IOrganizationTeamList>(endpoint);
}

Expand Down
Loading

0 comments on commit 6589f66

Please sign in to comment.