Skip to content

Commit

Permalink
Merge pull request #2501 from ever-co/tiny-improvements
Browse files Browse the repository at this point in the history
Tiny improvements
  • Loading branch information
evereq authored May 8, 2024
2 parents 6202ea3 + 5890c42 commit 9a33e9e
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 131 deletions.
2 changes: 2 additions & 0 deletions apps/web/app/api/auth/register/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export async function POST(req: Request) {
const password = generateToken(8);
const names = body.name.split(' ');

console.log('Random password: ', password);

// Register user
const { data: user } = await registerUserRequest({
password: password,
Expand Down
7 changes: 6 additions & 1 deletion apps/web/app/hooks/auth/useAuthenticationPasscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ export function useAuthenticationPasscode() {
[queryCall]
);

const signInToWorkspaceRequest = (params: { email: string; token: string; selectedTeam: string; code: string }) => {
const signInToWorkspaceRequest = (params: {
email: string;
token: string;
selectedTeam: string;
code?: string;
}) => {
signInWorkspaceQueryCall(params)
.then(() => {
setAuthenticated(true);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/hooks/auth/useAuthenticationPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function useAuthenticationPassword() {
token: string;
selectedTeam: string;
}) => {
signInWorkspaceQueryCall({ email, token, selectedTeam, code: '' })
signInWorkspaceQueryCall({ email, token, selectedTeam })
.then(() => {
setAuthenticated(true);
router.push('/');
Expand Down
1 change: 1 addition & 0 deletions apps/web/app/hooks/features/useTaskEstimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export function useTaskEstimation(task?: Nullable<ITeamTask>) {
if (updateLoading || !editableMode) return;
handleSubmit();
}, [updateLoading, editableMode, handleSubmit]);

const { targetEl, ignoreElementRef } = useOutsideClick<HTMLDivElement>(handleOutsideClick);

return {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/services/client/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export async function signInEmailConfirmAPI(email: string, code: string) {
});
}

export const signInWorkspaceAPI = (params: { email: string; token: string; selectedTeam: string; code: string }) => {
export const signInWorkspaceAPI = (params: { email: string; token: string; selectedTeam: string; code?: string }) => {
if (GAUZY_API_BASE_SERVER_URL.value) {
return signInWorkspaceGauzy({
email: params.email,
Expand Down
18 changes: 8 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 @@ -31,11 +31,7 @@ export function verifyInviteCodeAPI(params: IInviteVerifyCode) {
* @param params - Parameters including tenantId, userId, and token for authentication.
* @returns A promise that resolves to a pagination response of user organizations.
*/
export function getUserOrganizationsRequest(params: {
tenantId: string;
userId: string;
token: string
}) {
export function getUserOrganizationsRequest(params: { tenantId: string; userId: string; token: string }) {
// Create a new instance of URLSearchParams for query string construction
const query = new URLSearchParams();

Expand All @@ -54,7 +50,7 @@ export function getUserOrganizationsRequest(params: {
tenantId: params.tenantId,
headers: {
Authorization: `Bearer ${params.token}`
},
}
});
}

Expand Down Expand Up @@ -221,11 +217,13 @@ export async function signInEmailConfirmGauzy(email: string, code: string) {
/**
* @param params
*/
export async function signInWorkspaceGauzy(params: { email: string; token: string; teamId: string; code: string }) {
const loginResponse = await signInEmailCodeConfirmGauzy(params.email, params.code);
export async function signInWorkspaceGauzy(params: { email: string; token: string; teamId: string; code?: string }) {
if (params.code) {
const loginResponse = await signInEmailCodeConfirmGauzy(params.email, params.code);

if (loginResponse) {
return loginResponse;
if (loginResponse) {
return loginResponse;
}
}

const data = await signInWorkspaceAPI(params.email, params.token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export function getPublicOrganizationTeamsAPI(profile_link: string, team_id: str
'tasks.teams',
'tasks.tags',
'members',
// 'members.role',
'members.employee',
'members.employee.user'
];
Expand Down
38 changes: 13 additions & 25 deletions apps/web/components/pages/task/title-block/task-title-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ITeamTask } from '@app/interfaces';
import { detailedTaskState } from '@app/stores';
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@components/ui/hover-card';
import { useToast } from '@components/ui/use-toast';
import { Button, Tooltip } from 'lib/components';
import { Button, CopyTooltip } from 'lib/components';
import { ActiveTaskIssuesDropdown } from 'lib/features';
import Image from 'next/image';
import { CheckSimpleIcon, CopyRoundIcon } from 'assets/svg';
Expand All @@ -30,7 +30,6 @@ const TaskTitleBlock = () => {

//States
const [edit, setEdit] = useState<boolean>(false);
const [copied, setCopied] = useState<boolean>(false);
const [task] = useRecoilState(detailedTaskState);
const [title, setTitle] = useState<string>('');

Expand Down Expand Up @@ -97,16 +96,6 @@ const TaskTitleBlock = () => {
titleDOM.current?.style.setProperty('height', titleDOM.current.scrollHeight + 'px');
};

const copyTitle = () => {
navigator.clipboard.writeText(title);
setCopied(true);
setTimeout(() => setCopied(false), 1500);
};

const copyTaskNumber = () => {
task && navigator.clipboard.writeText(task?.taskNumber);
};

const handleTaskTitleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
setTitle(event.target.value);
};
Expand All @@ -124,7 +113,7 @@ const TaskTitleBlock = () => {
value={title}
disabled={!edit}
ref={titleDOM}
></textarea>
/>

{edit ? (
<div className="flex flex-col justify-start gap-1 transition-all">
Expand All @@ -144,7 +133,7 @@ const TaskTitleBlock = () => {
</button>
</div>
) : (
<div className="flex flex-col justify-start gap-1">
<div className="flex flex-col justify-start items-center gap-2">
<button ref={editButton} onClick={() => setEdit(true)}>
<Image
src="/assets/svg/edit-header-pencil.svg"
Expand All @@ -156,8 +145,8 @@ const TaskTitleBlock = () => {
/>
</button>

<button className="text-[#B1AEBC]" onClick={copyTitle}>
<Tooltip label={copied ? 'Copied' : 'Copy Title'} enabled>
<CopyTooltip text={title} defaultTooltipText="Copy Title">
<button className="text-[#B1AEBC]">
<Image
src="/assets/svg/copy.svg"
alt="edit header"
Expand All @@ -166,8 +155,8 @@ const TaskTitleBlock = () => {
style={{ height: '17px' }}
className="mr-1 cursor-pointer"
/>
</Tooltip>
</button>
</button>
</CopyTooltip>
</div>
)}
</div>
Expand Down Expand Up @@ -223,13 +212,12 @@ const TaskTitleBlock = () => {
</div>
</div>

<button
className="flex gap-1 items-center text-[#B1AEBC] text-[0.5rem] 3xl:text-xs 3xl:py-2"
onClick={copyTaskNumber}
>
<CopyRoundIcon className="text-[#B1AEBC] w-2.5 h-2.5" />
{t('pages.settingsTeam.COPY_NUMBER')}
</button>
<CopyTooltip text={task?.taskNumber || ''}>
<button className="flex gap-1 items-center text-[#B1AEBC] text-[0.5rem] 3xl:text-xs 3xl:py-2">
<CopyRoundIcon className="text-[#B1AEBC] w-2.5 h-2.5" />
{t('pages.settingsTeam.COPY_NUMBER')}
</button>
</CopyTooltip>
</div>
</div>
);
Expand Down
29 changes: 29 additions & 0 deletions apps/web/lib/components/copy-tooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { cn } from 'lib/utils';
import { Tooltip } from './tooltip';
import { useState, PropsWithChildren } from 'react';

type Props = {
text: string;
className?: string;
copiedTooltipText?: string;
defaultTooltipText?: string;
};

export function CopyTooltip(props: PropsWithChildren<Props>) {
const { copiedTooltipText = 'Copied', defaultTooltipText = 'Copy' } = props;
const [copied, setCopied] = useState(false);

const copyTitle = () => {
navigator.clipboard.writeText(props.text);
setCopied(true);
setTimeout(() => setCopied(false), 1500);
};

return (
<Tooltip label={copied ? copiedTooltipText : defaultTooltipText} enabled>
<div className={cn('copy-tooltip', props.className)} onClick={copyTitle}>
{props.children}
</div>
</Tooltip>
);
}
1 change: 1 addition & 0 deletions apps/web/lib/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ export * from './inputs/input';
export * from './inputs/auth-code-input';

export * from './services/recaptcha';
export * from './copy-tooltip';
12 changes: 7 additions & 5 deletions apps/web/lib/features/task/task-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,9 @@ export function TaskInput(props: Props) {
task={inputTask}
forParentChildRelationship={true}
taskStatusClassName={clsxm(
`${
inputTask && inputTask.issueType === 'Bug'
? '!px-[0.3312rem] py-[0.2875rem] rounded-sm'
: '!px-[0.375rem] py-[0.375rem] rounded-sm'
} `,
inputTask && inputTask.issueType === 'Bug'
? '!px-[0.3312rem] py-[0.2875rem] rounded-sm'
: '!px-[0.375rem] py-[0.375rem] rounded-sm',
'border-none'
)}
/>
Expand Down Expand Up @@ -425,6 +423,7 @@ function TaskCard({
forParentChildRelationship?: boolean;
updatedTaskList?: ITeamTask[];
}) {
const [, setCount] = useState(0);
const t = useTranslations();
const activeTaskEl = useRef<HTMLLIElement | null>(null);
const { taskLabels: taskLabelsData } = useTaskLabels();
Expand Down Expand Up @@ -480,6 +479,7 @@ function TaskCard({
if (v && taskStatus) {
taskStatus.current = v;
}
setCount((c) => c + 1);
}}
defaultValue={taskStatus?.current as ITaskStatus}
task={null}
Expand All @@ -492,6 +492,7 @@ function TaskCard({
if (v && taskPriority) {
taskPriority.current = v;
}
setCount((c) => c + 1);
}}
defaultValue={taskPriority?.current as ITaskPriority}
task={null}
Expand All @@ -504,6 +505,7 @@ function TaskCard({
if (v && taskSize) {
taskSize.current = v;
}
setCount((c) => c + 1);
}}
defaultValue={taskSize?.current as ITaskSize}
task={null}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/lib/settings/team-setting-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ export const TeamSettingForm = () => {
</div>

{/* Team Color */}
<div className="z-50 flex flex-col lg:flex-row items-center justify-between w-full gap-1 lg:gap-12 ">
<div className="flex flex-col lg:flex-row items-center justify-between w-full gap-1 lg:gap-12 ">
<Text className="flex-none flex-grow-0 w-full lg:w-1/5 mb-2 text-lg font-normal text-gray-400">
{t('pages.settingsTeam.TEAM_COLOR')}
</Text>
<div className="flex flex-row items-center justify-between flex-grow-0 w-full lg:w-4/5">
<div className="z-50 flex flex-row items-center justify-between flex-grow-0 w-full lg:w-4/5">
<ColorPicker
defaultColor={activeTeam?.color}
onChange={(color: any | null) => {
Expand Down
Loading

0 comments on commit 9a33e9e

Please sign in to comment.