From 3437d7f3d7e82e7c5d49f0eac12f55c571f69694 Mon Sep 17 00:00:00 2001 From: rammohan-y <37395033+rammohan-y@users.noreply.github.com> Date: Tue, 1 Apr 2025 18:59:26 +0530 Subject: [PATCH] Feat/371 view only user checkbox (#478) * feat/371 added read-only checkbox * wip * wip-2 * renamed is_read_only to is_view_only --- src/api/types.ts | 2 ++ src/containers/internal/views/users/form.tsx | 28 ++++++++++++++++++++ src/router/auth.tsx | 2 -- src/store/index.tsx | 1 - src/store/types.ts | 1 + 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/api/types.ts b/src/api/types.ts index 0e4f232..ef5a9fc 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -143,6 +143,7 @@ export interface User { name: string; email: string; is_active: boolean; + is_view_only: boolean; force_change: boolean; account_sid: string | null; account_name?: string | null; @@ -174,6 +175,7 @@ export interface UserUpdatePayload { name: string; force_change: boolean; is_active: boolean; + is_view_only: boolean; service_provider_sid: string | null; account_sid: string | null; } diff --git a/src/containers/internal/views/users/form.tsx b/src/containers/internal/views/users/form.tsx index 4a822de..1182247 100644 --- a/src/containers/internal/views/users/form.tsx +++ b/src/containers/internal/views/users/form.tsx @@ -61,6 +61,7 @@ export const UserForm = ({ user }: UserFormProps) => { const [forceChange, setForceChange] = useState(true); const [modal, setModal] = useState(false); const [accountSid, setAccountSid] = useState(""); + const [isViewOnly, setIsViewOnly] = useState(false); const handleCancel = () => { setModal(false); @@ -115,6 +116,7 @@ export const UserForm = ({ user }: UserFormProps) => { initial_password: initialPassword, force_change: forceChange, is_active: isActive, + is_view_only: isViewOnly, service_provider_sid: scope === USER_ADMIN && currentUser?.scope === USER_ADMIN ? null @@ -145,6 +147,7 @@ export const UserForm = ({ user }: UserFormProps) => { initial_password: initialPassword || null, force_change: forceChange, is_active: isActive, + is_view_only: isViewOnly, service_provider_sid: scope === USER_ADMIN && currentUser?.scope === USER_ADMIN ? null @@ -172,6 +175,7 @@ export const UserForm = ({ user }: UserFormProps) => { setName(user.data.name); setForceChange(!!user.data.force_change); setIsActive(!!user.data.is_active); + setIsViewOnly(!!user.data.is_view_only); setEmail(user.data.email); setScope(getUserScope(user.data)); if (user.data.account_sid) { @@ -253,6 +257,16 @@ export const UserForm = ({ user }: UserFormProps) => { />
User is active
+ )}
@@ -283,6 +297,20 @@ export const UserForm = ({ user }: UserFormProps) => { onChange={(e) => setEmail(e.target.value)} />
+ {!user && ( +
+ +
+ )}