2023-09-29 12:29:22 +00:00
|
|
|
'use client';
|
2023-01-11 01:18:59 +00:00
|
|
|
import { Form, FormRow } from 'react-basics';
|
2023-10-03 23:05:17 +00:00
|
|
|
import TimezoneSetting from 'app/(main)/settings/profile/TimezoneSetting';
|
|
|
|
|
import DateRangeSetting from 'app/(main)/settings/profile/DateRangeSetting';
|
|
|
|
|
import LanguageSetting from 'app/(main)/settings/profile/LanguageSetting';
|
|
|
|
|
import ThemeSetting from 'app/(main)/settings/profile/ThemeSetting';
|
2023-03-23 23:33:10 +00:00
|
|
|
import PasswordChangeButton from './PasswordChangeButton';
|
2024-01-29 02:33:40 +00:00
|
|
|
import { useUser } from 'components/hooks';
|
|
|
|
|
import { useMessages } from 'components/hooks';
|
2023-07-07 06:02:16 +00:00
|
|
|
import { ROLES } from 'lib/constants';
|
2022-12-27 00:57:59 +00:00
|
|
|
|
2023-09-29 12:29:22 +00:00
|
|
|
export function ProfileSettings() {
|
2023-01-11 16:33:43 +00:00
|
|
|
const { user } = useUser();
|
2023-03-22 04:28:36 +00:00
|
|
|
const { formatMessage, labels } = useMessages();
|
2023-08-28 02:56:44 +00:00
|
|
|
const cloudMode = Boolean(process.env.cloudMode);
|
2022-12-27 00:57:59 +00:00
|
|
|
|
|
|
|
|
if (!user) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-11 01:18:59 +00:00
|
|
|
const { username, role } = user;
|
2022-12-27 00:57:59 +00:00
|
|
|
|
2023-07-07 06:02:16 +00:00
|
|
|
const renderRole = value => {
|
|
|
|
|
if (value === ROLES.user) {
|
|
|
|
|
return formatMessage(labels.user);
|
|
|
|
|
}
|
|
|
|
|
if (value === ROLES.admin) {
|
|
|
|
|
return formatMessage(labels.admin);
|
|
|
|
|
}
|
|
|
|
|
if (value === ROLES.viewOnly) {
|
|
|
|
|
return formatMessage(labels.viewOnly);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return formatMessage(labels.unknown);
|
|
|
|
|
};
|
|
|
|
|
|
2022-12-27 00:57:59 +00:00
|
|
|
return (
|
2023-01-11 01:18:59 +00:00
|
|
|
<Form>
|
2023-01-25 15:42:46 +00:00
|
|
|
<FormRow label={formatMessage(labels.username)}>{username}</FormRow>
|
2023-07-07 06:02:16 +00:00
|
|
|
<FormRow label={formatMessage(labels.role)}>{renderRole(role)}</FormRow>
|
2023-03-23 23:33:10 +00:00
|
|
|
{!cloudMode && (
|
|
|
|
|
<FormRow label={formatMessage(labels.password)}>
|
|
|
|
|
<PasswordChangeButton />
|
|
|
|
|
</FormRow>
|
|
|
|
|
)}
|
2023-01-31 05:44:07 +00:00
|
|
|
<FormRow label={formatMessage(labels.defaultDateRange)}>
|
|
|
|
|
<DateRangeSetting />
|
|
|
|
|
</FormRow>
|
2023-01-28 05:53:13 +00:00
|
|
|
<FormRow label={formatMessage(labels.language)}>
|
2023-01-11 01:18:59 +00:00
|
|
|
<LanguageSetting />
|
|
|
|
|
</FormRow>
|
2023-01-28 05:53:13 +00:00
|
|
|
<FormRow label={formatMessage(labels.timezone)}>
|
2023-01-11 01:18:59 +00:00
|
|
|
<TimezoneSetting />
|
|
|
|
|
</FormRow>
|
2023-01-25 15:42:46 +00:00
|
|
|
<FormRow label={formatMessage(labels.theme)}>
|
2023-01-11 01:18:59 +00:00
|
|
|
<ThemeSetting />
|
|
|
|
|
</FormRow>
|
|
|
|
|
</Form>
|
2022-12-27 00:57:59 +00:00
|
|
|
);
|
|
|
|
|
}
|
2023-04-21 15:00:42 +00:00
|
|
|
|
2023-09-29 12:29:22 +00:00
|
|
|
export default ProfileSettings;
|