Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #2126

Merged
merged 20 commits into from
Jan 26, 2024
Merged

Release #2126

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/mobile/app/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ComponentType } from 'react';
import { Pressable, PressableProps, PressableStateCallbackType, StyleProp, TextStyle, ViewStyle } from 'react-native';
import { colors, spacing, typography } from '../theme';
import { colors, spacing } from '../theme';
import { Text, TextProps } from './Text';

type Presets = keyof typeof $viewPresets;
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/app/components/LabelItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { FC, ReactNode } from 'react';
import { View, StyleSheet, Text } from 'react-native';
import { typography } from '../theme';
import { limitTextCharaters } from '../helpers/sub-text';
// import { limitTextCharaters } from '../helpers/sub-text';

interface Props {
label: string;
Expand Down
8 changes: 4 additions & 4 deletions apps/mobile/app/components/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,14 @@ function Switch(props: ToggleInputProps) {

const offsetLeft = ($innerStyleOverride?.paddingStart ||
$innerStyleOverride?.paddingLeft ||
$switchInner?.paddingStart ||
$switchInner?.paddingLeft ||
$switchInner.paddingStart ||
$switchInner.paddingLeft ||
0) as number;

const offsetRight = ($innerStyleOverride?.paddingEnd ||
$innerStyleOverride?.paddingRight ||
$switchInner?.paddingEnd ||
$switchInner?.paddingRight ||
$switchInner.paddingEnd ||
$switchInner.paddingRight ||
0) as number;

const start = withTiming(on ? '100%' : '0%');
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/app/models/task/Task.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { types } from 'mobx-state-tree';
// import { types } from 'mobx-state-tree';
import { ITeamTask } from '../../services/interfaces/ITask';

export interface ITaskCreateParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import React from 'react';
import { ScrollView, StyleSheet, View } from 'react-native';
import { Card } from 'react-native-paper';
import { Skeleton } from 'react-native-skeletons';
import { useOrganizationTeam } from '../../../../services/hooks/useOrganization';
// import { useOrganizationTeam } from '../../../../services/hooks/useOrganization';
import { useAppTheme } from '../../../../theme';

const ProfileScreenSkeleton = () => {
const { colors, dark } = useAppTheme();
const { isTeamManager } = useOrganizationTeam();
// const { isTeamManager } = useOrganizationTeam();

const MemberCard = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { View, StyleSheet, TextInput, Text } from 'react-native';
import { FontAwesome, AntDesign, Entypo } from '@expo/vector-icons';
import { View, StyleSheet, Text } from 'react-native';
import { FontAwesome, AntDesign } from '@expo/vector-icons';
import { typography, useAppTheme } from '../../../../theme';

type ITasDisplayBox = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function getOrganizationTeamRequest(
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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function useTeamMemberCard(member: IOrganizationTeamList["members"][numbe
const taskStatistics =
tasksStatisticsState?.all.find((statistics) => statistics.id === responseTask.id) ||
[]
responseTask.totalWorkedTime = taskStatistics?.duration || 0
responseTask.totalWorkedTime = taskStatistics.duration || 0
}

return responseTask
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/app/services/hooks/useLanguageModal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useState } from 'react';
import { useCallback, useState } from 'react';
import { ILanguageItemList } from '../interfaces/IUserData';

export function useLanguageModal() {
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/app/services/hooks/useOrganization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function useOrganizationTeam() {
getOrganizationTeam();
}, [organizationTeams]);

const activeTeamManagers = members?.filter((m) => m.role?.name === 'MANAGER');
const activeTeamManagers = members.filter((m) => m.role?.name === 'MANAGER');

const isManager = () => {
if (activeTeam) {
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/app/services/hooks/useTimezoneModal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useState } from 'react';
import { useCallback, useState } from 'react';

export function useTimezoneModal() {
const [isModalOpen, setIsModalOpen] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/[locale]/settings/team/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Team = () => {
{!user ? (
<SettingsTeamSkeleton />
) : (
<MainLayout className="items-start pb-1">
<MainLayout className="items-start pb-1 max-h-s">
<div className="pt-12 pb-4 bg-white dark:bg-dark--theme">
<Container>
<div className="flex items-center gap-8">
Expand Down
21 changes: 21 additions & 0 deletions apps/web/app/api/organization-projects/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app';

import { createOrganizationProjectRequest } from '@app/services/server/requests';
import { NextResponse } from 'next/server';

export async function POST(req: Request) {
const res = new NextResponse();
const { $res, user, access_token } = await authenticatedGuard(req, res);

if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });

const body: {
name: string;
tenantId: string;
organizationId: string;
} = await req.json();

const response = await createOrganizationProjectRequest(body, access_token);

return $res(response.data);
}
6 changes: 6 additions & 0 deletions apps/web/app/api/organization-team/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export async function POST(req: Request) {
if ($name.trim().length < 2) {
return NextResponse.json({ errors: { name: 'Invalid team name !' } }, { status: 400 });
}

await createOrganizationTeamRequest(
{
name: $name,
Expand All @@ -32,6 +33,11 @@ export async function POST(req: Request) {
);
}

if (<boolean>true) {
const teams = await getAllOrganizationTeamRequest({ tenantId, organizationId: organizationId }, access_token);
return $res(teams.data);
}

const { data: organizations } = await getUserOrganizationsRequest({ tenantId, userId: user.id }, access_token);

const organizationsItems = organizations.items;
Expand Down
32 changes: 16 additions & 16 deletions apps/web/app/api/tasks/employee/[employeeId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ export async function GET(req: Request, { params }: { params: { employeeId: stri
organizationTeamId: string;
};

return $res(
await getEmployeeTasksRequest({
tenantId,
employeeId,
organizationTeamId,
bearer_token
})
);
const response = await getEmployeeTasksRequest({
tenantId,
employeeId,
organizationTeamId,
bearer_token
});

return $res(response.data);
}

export async function DELETE(req: Request, { params }: { params: { employeeId: string } }) {
Expand All @@ -36,12 +36,12 @@ export async function DELETE(req: Request, { params }: { params: { employeeId: s
organizationTeamId: string;
};

return $res(
await deleteEmployeeFromTasksRequest({
tenantId,
employeeId,
organizationTeamId,
bearer_token
})
);
const response = await deleteEmployeeFromTasksRequest({
tenantId,
employeeId,
organizationTeamId,
bearer_token
});

return $res(response.data);
}
2 changes: 2 additions & 0 deletions apps/web/app/api/tasks/team/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export async function POST(req: Request) {
const body: Record<string, any> = (await req.json()) || {};

const title = body.title?.trim() || '';

if (title.trim().length < 2) {
return $res({ errors: { name: 'Invalid task name !' } });
}

const activeTeam = getActiveTeamIdCookie({ req, res });

await createTaskRequest({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function GET(req: Request) {
const { $res, user, tenantId, organizationId, access_token } = await authenticatedGuard(req, res);
if (!user) return $res('Unauthorized');

const { data } = await tasksTimesheetStatisticsRequest(
const response = await tasksTimesheetStatisticsRequest(
{
tenantId,
organizationId,
Expand All @@ -17,5 +17,5 @@ export async function GET(req: Request) {
access_token
);

return $res(data);
return $res(response.data);
}
1 change: 1 addition & 0 deletions apps/web/app/hooks/features/useAuthenticateUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const useAuthenticateUser = (defaultUser?: IUser) => {
}, []);

return {
$user,
user: $user.current,
setUser,
isTeamManager,
Expand Down
6 changes: 3 additions & 3 deletions apps/web/app/hooks/features/useOrganizationTeams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function useCreateOrganizationTeam() {
const [teams, setTeams] = useRecoilState(organizationTeamsState);
const teamsRef = useSyncRef(teams);
const setActiveTeamId = useSetRecoilState(activeTeamIdState);
const { refreshToken } = useAuthenticateUser();
const { refreshToken, $user } = useAuthenticateUser();
const [isTeamMember, setIsTeamMember] = useRecoilState(isTeamMemberState);

const createOrganizationTeam = useCallback(
Expand All @@ -83,11 +83,11 @@ function useCreateOrganizationTeam() {
const $name = name.trim();
const exits = teams.find((t) => t.name.toLowerCase() === $name.toLowerCase());

if (exits || $name.length < 2) {
if (exits || $name.length < 2 || !$user.current) {
return Promise.reject(new Error('Invalid team name !'));
}

return queryCall($name).then(async (res) => {
return queryCall($name, $user.current).then(async (res) => {
const dt = res.data?.items || [];
setTeams(dt);
const created = dt.find((t) => t.name === $name);
Expand Down
39 changes: 21 additions & 18 deletions apps/web/app/hooks/features/useTeamTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { useAuthenticateUser } from './useAuthenticateUser';

export function useTeamTasks() {
const { updateOrganizationTeamEmployeeActiveTask } = useOrganizationEmployeeTeams();
const { user } = useAuthenticateUser();
const { user, $user } = useAuthenticateUser();

const setAllTasks = useSetRecoilState(teamTasksState);
const tasks = useRecoilValue(tasksByTeamState);
Expand Down Expand Up @@ -230,23 +230,26 @@ export function useTeamTasks() {
},
members?: { id: string }[]
) => {
return createQueryCall({
title: taskName,
issueType,
status,
priority,
size,
tags,
// Set Project Id to cookie
// TODO: Make it dynamic when we add Dropdown in Navbar
...(activeTeam?.projects && activeTeam?.projects.length > 0
? {
projectId: activeTeam.projects[0].id
}
: {}),
...(description ? { description: `<p>${description}</p>` } : {}),
...(members ? { members } : {})
}).then((res) => {
return createQueryCall(
{
title: taskName,
issueType,
status,
priority,
size,
tags,
// Set Project Id to cookie
// TODO: Make it dynamic when we add Dropdown in Navbar
...(activeTeam?.projects && activeTeam?.projects.length > 0
? {
projectId: activeTeam.projects[0].id
}
: {}),
...(description ? { description: `<p>${description}</p>` } : {}),
...(members ? { members } : {})
},
$user.current
).then((res) => {
deepCheckAndUpdateTasks(res?.data?.items || [], true);
return res;
});
Expand Down
13 changes: 7 additions & 6 deletions apps/web/app/hooks/useInfinityFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ import React from 'react';
export const getPartData = ({ offset = 0, limit = 10, arr = [] }: { offset?: number; limit?: number; arr: any[] }) =>
arr.slice(0, offset * limit + limit);

export const useInfinityScrolling = (arr: any) => {
export const useInfinityScrolling = <T>(arr: T[], lim?: number) => {
const limit = lim ?? 10;
const [offset, setOffset] = React.useState(0);
const [data, setData] = React.useState<any[]>(arr);
const [data, setData] = React.useState<T[]>(arr);

const getSomeTasks = React.useCallback(
(offset: number) => {
setData(getPartData({ arr, limit: 10, offset }));
setData(getPartData({ arr, limit, offset }));
},
[arr]
[arr, limit]
);

const nextOffset = React.useCallback(() => {
setOffset((prev) => prev + 1);
setData((prev) => getPartData({ arr: prev, limit: 10, offset }));
}, [offset]);
setData((prev) => getPartData({ arr: prev, limit, offset }));
}, [limit, offset]);

React.useEffect(() => {
console.log({ offset });
Expand Down
1 change: 1 addition & 0 deletions apps/web/app/services/client/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ export * from './organization-projects';
export * from './activity/time-slots';
export * from './activity/activity';
export * from './default';
export * from './projects';
Loading
Loading