Skip to content

Commit 079a624

Browse files
feat: add timezone selection to workspace settings (#8248)
* feat: add timezone selection to workspace onboarding, creation and settings * refactor: remove timezone selection from workspace creation and onboarding forms
1 parent 0bfb74d commit 079a624

File tree

24 files changed

+187
-131
lines changed

24 files changed

+187
-131
lines changed

apps/web/app/(all)/create-workspace/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { AuthenticationWrapper } from "@/lib/wrappers/authentication-wrapper";
1818
// plane web helpers
1919
import { getIsWorkspaceCreationDisabled } from "@/plane-web/helpers/instance.helper";
2020

21-
function CreateWorkspacePage() {
21+
const CreateWorkspacePage = observer(function CreateWorkspacePage() {
2222
const { t } = useTranslation();
2323
// router
2424
const router = useAppRouter();
@@ -104,6 +104,6 @@ function CreateWorkspacePage() {
104104
</div>
105105
</AuthenticationWrapper>
106106
);
107-
}
107+
});
108108

109-
export default observer(CreateWorkspacePage);
109+
export default CreateWorkspacePage;

apps/web/core/components/onboarding/steps/workspace/create.tsx

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from "react";
1+
import { useState } from "react";
22
import { observer } from "mobx-react";
33
import { Controller, useForm } from "react-hook-form";
44
import { CircleCheck } from "lucide-react";
@@ -71,47 +71,46 @@ export const WorkspaceCreateStep = observer(function WorkspaceCreateStep({
7171
const handleCreateWorkspace = async (formData: IWorkspace) => {
7272
if (isSubmitting) return;
7373

74-
await workspaceService
75-
.workspaceSlugCheck(formData.slug)
76-
.then(async (res) => {
77-
if (res.status === true && !RESTRICTED_URLS.includes(formData.slug)) {
78-
setSlugError(false);
79-
await createWorkspace(formData)
80-
.then(async (workspaceResponse) => {
81-
setToast({
82-
type: TOAST_TYPE.SUCCESS,
83-
title: t("workspace_creation.toast.success.title"),
84-
message: t("workspace_creation.toast.success.message"),
85-
});
86-
captureSuccess({
87-
eventName: WORKSPACE_TRACKER_EVENTS.create,
88-
payload: { slug: formData.slug },
89-
});
90-
await fetchWorkspaces();
91-
await completeStep(workspaceResponse.id);
92-
onComplete(formData.organization_size === "Just myself");
93-
})
94-
.catch(() => {
95-
captureError({
96-
eventName: WORKSPACE_TRACKER_EVENTS.create,
97-
payload: { slug: formData.slug },
98-
error: new Error("Error creating workspace"),
99-
});
100-
setToast({
101-
type: TOAST_TYPE.ERROR,
102-
title: t("workspace_creation.toast.error.title"),
103-
message: t("workspace_creation.toast.error.message"),
104-
});
105-
});
106-
} else setSlugError(true);
107-
})
108-
.catch(() =>
109-
setToast({
110-
type: TOAST_TYPE.ERROR,
111-
title: t("workspace_creation.toast.error.title"),
112-
message: t("workspace_creation.toast.error.message"),
113-
})
114-
);
74+
try {
75+
const res = (await workspaceService.workspaceSlugCheck(formData.slug)) as { status: boolean };
76+
if (res.status === true && !RESTRICTED_URLS.includes(formData.slug)) {
77+
setSlugError(false);
78+
try {
79+
const workspaceResponse = await createWorkspace(formData);
80+
setToast({
81+
type: TOAST_TYPE.SUCCESS,
82+
title: t("workspace_creation.toast.success.title"),
83+
message: t("workspace_creation.toast.success.message"),
84+
});
85+
captureSuccess({
86+
eventName: WORKSPACE_TRACKER_EVENTS.create,
87+
payload: { slug: formData.slug },
88+
});
89+
await fetchWorkspaces();
90+
await completeStep(workspaceResponse.id);
91+
onComplete(formData.organization_size === "Just myself");
92+
} catch {
93+
captureError({
94+
eventName: WORKSPACE_TRACKER_EVENTS.create,
95+
payload: { slug: formData.slug },
96+
error: new Error("Error creating workspace"),
97+
});
98+
setToast({
99+
type: TOAST_TYPE.ERROR,
100+
title: t("workspace_creation.toast.error.title"),
101+
message: t("workspace_creation.toast.error.message"),
102+
});
103+
}
104+
} else {
105+
setSlugError(true);
106+
}
107+
} catch {
108+
setToast({
109+
type: TOAST_TYPE.ERROR,
110+
title: t("workspace_creation.toast.error.title"),
111+
message: t("workspace_creation.toast.error.message"),
112+
});
113+
}
115114
};
116115

117116
const completeStep = async (workspaceId: string) => {
@@ -136,7 +135,12 @@ export const WorkspaceCreateStep = observer(function WorkspaceCreateStep({
136135
);
137136
}
138137
return (
139-
<form className="flex flex-col gap-10" onSubmit={handleSubmit(handleCreateWorkspace)}>
138+
<form
139+
className="flex flex-col gap-10"
140+
onSubmit={(e) => {
141+
void handleSubmit(handleCreateWorkspace)(e);
142+
}}
143+
>
140144
<CommonOnboardingHeader title="Create your workspace" description="All your work — unified." />
141145
<div className="flex flex-col gap-8">
142146
<div className="flex flex-col gap-2">
@@ -181,6 +185,7 @@ export const WorkspaceCreateStep = observer(function WorkspaceCreateStep({
181185
"border-red-500": errors.name,
182186
}
183187
)}
188+
// eslint-disable-next-line jsx-a11y/no-autofocus
184189
autoFocus
185190
/>
186191
</div>

apps/web/core/components/workspace/create-workspace-form.tsx

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -67,47 +67,46 @@ export const CreateWorkspaceForm = observer(function CreateWorkspaceForm(props:
6767
} = useForm<IWorkspace>({ defaultValues, mode: "onChange" });
6868

6969
const handleCreateWorkspace = async (formData: IWorkspace) => {
70-
await workspaceService
71-
.workspaceSlugCheck(formData.slug)
72-
.then(async (res) => {
73-
if (res.status === true && !RESTRICTED_URLS.includes(formData.slug)) {
74-
setSlugError(false);
70+
try {
71+
const res = (await workspaceService.workspaceSlugCheck(formData.slug)) as { status: boolean };
72+
if (res.status === true && !RESTRICTED_URLS.includes(formData.slug)) {
73+
setSlugError(false);
7574

76-
await createWorkspace(formData)
77-
.then(async (res) => {
78-
captureSuccess({
79-
eventName: WORKSPACE_TRACKER_EVENTS.create,
80-
payload: { slug: formData.slug },
81-
});
82-
setToast({
83-
type: TOAST_TYPE.SUCCESS,
84-
title: t("workspace_creation.toast.success.title"),
85-
message: t("workspace_creation.toast.success.message"),
86-
});
75+
try {
76+
const workspaceResponse = await createWorkspace(formData);
77+
captureSuccess({
78+
eventName: WORKSPACE_TRACKER_EVENTS.create,
79+
payload: { slug: formData.slug },
80+
});
81+
setToast({
82+
type: TOAST_TYPE.SUCCESS,
83+
title: t("workspace_creation.toast.success.title"),
84+
message: t("workspace_creation.toast.success.message"),
85+
});
8786

88-
if (onSubmit) await onSubmit(res);
89-
})
90-
.catch(() => {
91-
captureError({
92-
eventName: WORKSPACE_TRACKER_EVENTS.create,
93-
payload: { slug: formData.slug },
94-
error: new Error("Error creating workspace"),
95-
});
96-
setToast({
97-
type: TOAST_TYPE.ERROR,
98-
title: t("workspace_creation.toast.error.title"),
99-
message: t("workspace_creation.toast.error.message"),
100-
});
101-
});
102-
} else setSlugError(true);
103-
})
104-
.catch(() => {
105-
setToast({
106-
type: TOAST_TYPE.ERROR,
107-
title: t("workspace_creation.toast.error.title"),
108-
message: t("workspace_creation.toast.error.message"),
109-
});
87+
if (onSubmit) await onSubmit(workspaceResponse);
88+
} catch {
89+
captureError({
90+
eventName: WORKSPACE_TRACKER_EVENTS.create,
91+
payload: { slug: formData.slug },
92+
error: new Error("Error creating workspace"),
93+
});
94+
setToast({
95+
type: TOAST_TYPE.ERROR,
96+
title: t("workspace_creation.toast.error.title"),
97+
message: t("workspace_creation.toast.error.message"),
98+
});
99+
}
100+
} else {
101+
setSlugError(true);
102+
}
103+
} catch {
104+
setToast({
105+
type: TOAST_TYPE.ERROR,
106+
title: t("workspace_creation.toast.error.title"),
107+
message: t("workspace_creation.toast.error.message"),
110108
});
109+
}
111110
};
112111

113112
useEffect(
@@ -119,7 +118,12 @@ export const CreateWorkspaceForm = observer(function CreateWorkspaceForm(props:
119118
);
120119

121120
return (
122-
<form className="space-y-6 sm:space-y-9" onSubmit={handleSubmit(handleCreateWorkspace)}>
121+
<form
122+
className="space-y-6 sm:space-y-9"
123+
onSubmit={(e) => {
124+
void handleSubmit(handleCreateWorkspace)(e);
125+
}}
126+
>
123127
<div className="space-y-6 sm:space-y-7">
124128
<div className="space-y-1 text-sm">
125129
<label htmlFor="workspaceName">

0 commit comments

Comments
 (0)