@@ -32,11 +32,12 @@ import {
3232 TAX_ID_AGREEMENT_TEXT ,
3333 TAX_ID_HELPER_TEXT ,
3434} from 'src/features/Billing/constants' ;
35- import { useRestrictedGlobalGrantCheck } from 'src/hooks/useRestrictedGlobalGrantCheck ' ;
35+ import { usePermissions } from 'src/features/IAM/ hooks/usePermissions ' ;
3636import { getErrorMap } from 'src/utilities/errorUtils' ;
3737
3838import type { Account } from '@linode/api-v4' ;
3939import type { SelectOption } from '@linode/ui' ;
40+
4041interface Props {
4142 focusEmail : boolean ;
4243 onClose : ( ) => void ;
@@ -58,11 +59,13 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
5859 const { isTaxIdEnabled } = useIsTaxIdEnabled ( ) ;
5960 const isChildUser = profile ?. user_type === 'child' ;
6061 const isParentUser = profile ?. user_type === 'parent' ;
61- const isReadOnly =
62- useRestrictedGlobalGrantCheck ( {
63- globalGrantType : 'account_access' ,
64- permittedGrantLevel : 'read_write' ,
65- } ) || isChildUser ;
62+ const { data : permissions } = usePermissions ( 'account' , [
63+ 'acknowledge_account_agreement' ,
64+ 'update_account' ,
65+ ] ) ;
66+ const isAccountReadOnly = ! permissions . update_account || isChildUser ;
67+ const isAcknowledgeAgreementDisabled =
68+ ! permissions . acknowledge_account_agreement || isChildUser ;
6669
6770 const formik = useFormik ( {
6871 enableReinitialize : true ,
@@ -260,7 +263,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
260263 data-qa-update-contact
261264 spacing = { 0 }
262265 >
263- { isReadOnly && (
266+ { isAccountReadOnly && (
264267 < Grid size = { 12 } >
265268 < Notice
266269 text = { getRestrictedResourceText ( {
@@ -279,7 +282,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
279282 < Grid size = { 12 } >
280283 < TextField
281284 data-qa-contact-email
282- disabled = { isReadOnly }
285+ disabled = { isAccountReadOnly }
283286 errorText = { errorMap . email }
284287 helperTextPosition = "top"
285288 inputRef = { emailRef }
@@ -300,7 +303,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
300303 >
301304 < TextField
302305 data-qa-contact-first-name
303- disabled = { isReadOnly }
306+ disabled = { isAccountReadOnly }
304307 errorText = { errorMap . first_name }
305308 label = "First Name"
306309 name = "first_name"
@@ -316,7 +319,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
316319 >
317320 < TextField
318321 data-qa-contact-last-name
319- disabled = { isReadOnly }
322+ disabled = { isAccountReadOnly }
320323 errorText = { errorMap . last_name }
321324 label = "Last Name"
322325 name = "last_name"
@@ -327,7 +330,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
327330 < Grid size = { 12 } >
328331 < TextField
329332 data-qa-company
330- disabled = { isReadOnly || isParentUser }
333+ disabled = { isAccountReadOnly || isParentUser }
331334 errorText = { errorMap . company }
332335 label = "Company Name"
333336 name = "company"
@@ -338,7 +341,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
338341 < Grid size = { 12 } >
339342 < TextField
340343 data-qa-contact-address-1
341- disabled = { isReadOnly }
344+ disabled = { isAccountReadOnly }
342345 errorText = { errorMap . address_1 }
343346 label = "Address"
344347 name = "address_1"
@@ -349,7 +352,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
349352 < Grid size = { 12 } >
350353 < TextField
351354 data-qa-contact-address-2
352- disabled = { isReadOnly }
355+ disabled = { isAccountReadOnly }
353356 errorText = { errorMap . address_2 }
354357 label = "Address 2"
355358 name = "address_2"
@@ -366,7 +369,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
366369 >
367370 < Autocomplete
368371 disableClearable
369- disabled = { isReadOnly }
372+ disabled = { isAccountReadOnly }
370373 errorText = { errorMap . country }
371374 keepSearchEnabledOnMobile
372375 label = "Country"
@@ -393,7 +396,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
393396 { formik . values . country === 'US' || formik . values . country == 'CA' ? (
394397 < Autocomplete
395398 disableClearable
396- disabled = { isReadOnly }
399+ disabled = { isAccountReadOnly }
397400 errorText = { errorMap . state }
398401 keepSearchEnabledOnMobile
399402 label = { `${ formik . values . country === 'US' ? 'State' : 'Province' } ` }
@@ -421,7 +424,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
421424 ) : (
422425 < TextField
423426 data-qa-contact-state-province
424- disabled = { isReadOnly }
427+ disabled = { isAccountReadOnly }
425428 errorText = { errorMap . state }
426429 label = "State / Province"
427430 name = "state"
@@ -440,7 +443,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
440443 >
441444 < TextField
442445 data-qa-contact-city
443- disabled = { isReadOnly }
446+ disabled = { isAccountReadOnly }
444447 errorText = { errorMap . city }
445448 label = "City"
446449 name = "city"
@@ -456,7 +459,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
456459 >
457460 < TextField
458461 data-qa-contact-post-code
459- disabled = { isReadOnly }
462+ disabled = { isAccountReadOnly }
460463 errorText = { errorMap . zip }
461464 label = "Postal Code"
462465 name = "zip"
@@ -467,7 +470,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
467470 < Grid size = { 12 } >
468471 < TextField
469472 data-qa-contact-phone
470- disabled = { isReadOnly }
473+ disabled = { isAccountReadOnly }
471474 errorText = { errorMap . phone }
472475 label = "Phone"
473476 name = "phone"
@@ -479,7 +482,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
479482 < Grid size = { 12 } >
480483 < TextField
481484 data-qa-contact-tax-id
482- disabled = { isReadOnly }
485+ disabled = { isAccountReadOnly }
483486 errorText = { errorMap . tax_id }
484487 helperText = { nonUSCountry && TAX_ID_HELPER_TEXT }
485488 label = "Tax ID"
@@ -500,6 +503,7 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
500503 < Checkbox
501504 checked = { billingAgreementChecked }
502505 data-testid = "tax-id-checkbox"
506+ disabled = { isAcknowledgeAgreementDisabled }
503507 id = "taxIdAgreementCheckbox"
504508 onChange = { ( ) =>
505509 setBillingAgreementChecked ( ! billingAgreementChecked )
@@ -522,7 +526,8 @@ const UpdateContactInformationForm = ({ focusEmail, onClose }: Props) => {
522526 className = { classes . actions }
523527 primaryButtonProps = { {
524528 'data-testid' : 'save-contact-info' ,
525- disabled : isReadOnly || ( nonUSCountry && ! billingAgreementChecked ) ,
529+ disabled :
530+ isAccountReadOnly || ( nonUSCountry && ! billingAgreementChecked ) ,
526531 label : 'Save Changes' ,
527532 loading : isPending ,
528533 type : 'submit' ,
0 commit comments