mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
dev: user timezone select option (#2002)
This commit is contained in:
parent
90cf39cf59
commit
38a5623c43
2386
apps/app/constants/timezones.ts
Normal file
2386
apps/app/constants/timezones.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,14 @@ import SettingsNavbar from "layouts/settings-navbar";
|
|||||||
// components
|
// components
|
||||||
import { ImagePickerPopover, ImageUploadModal } from "components/core";
|
import { ImagePickerPopover, ImageUploadModal } from "components/core";
|
||||||
// ui
|
// ui
|
||||||
import { CustomSelect, DangerButton, Input, SecondaryButton, Spinner } from "components/ui";
|
import {
|
||||||
|
CustomSearchSelect,
|
||||||
|
CustomSelect,
|
||||||
|
DangerButton,
|
||||||
|
Input,
|
||||||
|
SecondaryButton,
|
||||||
|
Spinner,
|
||||||
|
} from "components/ui";
|
||||||
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
||||||
// icons
|
// icons
|
||||||
import { UserIcon } from "@heroicons/react/24/outline";
|
import { UserIcon } from "@heroicons/react/24/outline";
|
||||||
@ -23,6 +30,7 @@ import type { NextPage } from "next";
|
|||||||
import type { IUser } from "types";
|
import type { IUser } from "types";
|
||||||
// constants
|
// constants
|
||||||
import { USER_ROLES } from "constants/workspace";
|
import { USER_ROLES } from "constants/workspace";
|
||||||
|
import { TIME_ZONES } from "constants/timezones";
|
||||||
|
|
||||||
const defaultValues: Partial<IUser> = {
|
const defaultValues: Partial<IUser> = {
|
||||||
avatar: "",
|
avatar: "",
|
||||||
@ -31,6 +39,7 @@ const defaultValues: Partial<IUser> = {
|
|||||||
last_name: "",
|
last_name: "",
|
||||||
email: "",
|
email: "",
|
||||||
role: "Product / Project Manager",
|
role: "Product / Project Manager",
|
||||||
|
user_timezone: "Asia/Kolkata",
|
||||||
};
|
};
|
||||||
|
|
||||||
const Profile: NextPage = () => {
|
const Profile: NextPage = () => {
|
||||||
@ -72,6 +81,7 @@ const Profile: NextPage = () => {
|
|||||||
cover_image: formData.cover_image,
|
cover_image: formData.cover_image,
|
||||||
role: formData.role,
|
role: formData.role,
|
||||||
display_name: formData.display_name,
|
display_name: formData.display_name,
|
||||||
|
user_timezone: formData.user_timezone,
|
||||||
};
|
};
|
||||||
|
|
||||||
await userService
|
await userService
|
||||||
@ -128,6 +138,12 @@ const Profile: NextPage = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const timeZoneOptions = TIME_ZONES.map((timeZone) => ({
|
||||||
|
value: timeZone.value,
|
||||||
|
query: timeZone.label + " " + timeZone.value,
|
||||||
|
content: timeZone.label,
|
||||||
|
}));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WorkspaceAuthorizationLayout
|
<WorkspaceAuthorizationLayout
|
||||||
breadcrumbs={
|
breadcrumbs={
|
||||||
@ -348,6 +364,35 @@ const Profile: NextPage = () => {
|
|||||||
{errors.role && <span className="text-xs text-red-500">Please select a role</span>}
|
{errors.role && <span className="text-xs text-red-500">Please select a role</span>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
||||||
|
<div className="col-span-12 sm:col-span-6">
|
||||||
|
<h4 className="text-lg font-semibold text-custom-text-100">Timezone</h4>
|
||||||
|
<p className="text-sm text-custom-text-200">Select a timezone</p>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-12 sm:col-span-6">
|
||||||
|
<Controller
|
||||||
|
name="user_timezone"
|
||||||
|
control={control}
|
||||||
|
rules={{ required: "This field is required" }}
|
||||||
|
render={({ field: { value, onChange } }) => (
|
||||||
|
<CustomSearchSelect
|
||||||
|
value={value}
|
||||||
|
label={
|
||||||
|
value
|
||||||
|
? TIME_ZONES.find((t) => t.value === value)?.label ?? value
|
||||||
|
: "Select a timezone"
|
||||||
|
}
|
||||||
|
options={timeZoneOptions}
|
||||||
|
onChange={onChange}
|
||||||
|
verticalPosition="top"
|
||||||
|
optionsClassName="w-full"
|
||||||
|
input
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
{errors.role && <span className="text-xs text-red-500">Please select a role</span>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div className="sm:text-right">
|
<div className="sm:text-right">
|
||||||
<SecondaryButton type="submit" loading={isSubmitting}>
|
<SecondaryButton type="submit" loading={isSubmitting}>
|
||||||
{isSubmitting ? "Updating..." : "Update profile"}
|
{isSubmitting ? "Updating..." : "Update profile"}
|
||||||
|
1
apps/app/types/users.d.ts
vendored
1
apps/app/types/users.d.ts
vendored
@ -36,6 +36,7 @@ export interface IUser {
|
|||||||
theme: ICustomTheme;
|
theme: ICustomTheme;
|
||||||
updated_at: readonly Date;
|
updated_at: readonly Date;
|
||||||
username: string;
|
username: string;
|
||||||
|
user_timezone: string;
|
||||||
|
|
||||||
[...rest: string]: any;
|
[...rest: string]: any;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user