From 2524e47d670c0c67e259d33a383e4643516fdcfa Mon Sep 17 00:00:00 2001 From: Drew Lyton Date: Mon, 30 Sep 2024 11:29:46 +0200 Subject: [PATCH] fix: submit requestedRole as name not title --- .../RequestPermissionDialog.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/sanity/src/structure/components/requestPermissionDialog/RequestPermissionDialog.tsx b/packages/sanity/src/structure/components/requestPermissionDialog/RequestPermissionDialog.tsx index 1029cf54742..8391bcec081 100644 --- a/packages/sanity/src/structure/components/requestPermissionDialog/RequestPermissionDialog.tsx +++ b/packages/sanity/src/structure/components/requestPermissionDialog/RequestPermissionDialog.tsx @@ -58,13 +58,13 @@ export function RequestPermissionDialog({ const [hasTooManyRequests, setHasTooManyRequests] = useState(false) const [hasBeenDenied, setHasBeenDenied] = useState(false) - const requestedRole$: Observable<'Administrator' | 'Editor'> = useMemo(() => { - const adminRole = 'Administrator' as const + const requestedRole$: Observable<'administrator' | 'editor'> = useMemo(() => { + const adminRole = 'administrator' as const if (!projectId || !client) return of(adminRole) return client.observable.request({url: `/projects/${projectId}/roles`}).pipe( map((roles) => { const hasEditor = roles.find((role) => role.name === 'editor') - return hasEditor ? 'Editor' : adminRole + return hasEditor ? 'editor' : adminRole }), startWith(adminRole), catchError(() => of(adminRole)), @@ -73,7 +73,7 @@ export function RequestPermissionDialog({ const requestedRole = useObservable(requestedRole$) - const onConfirm = () => { + const onSubmit = () => { setIsSubmitting(true) client .request({ @@ -128,7 +128,7 @@ export function RequestPermissionDialog({ disabled: hasTooManyRequests || hasBeenDenied, text: t('request-permission-dialog.confirm-button.text'), tone: 'primary', - onClick: onConfirm, + type: 'submit', }, }} onClose={onClose} @@ -154,7 +154,7 @@ export function RequestPermissionDialog({ placeholder={t('request-permission-dialog.note-input.placeholder.text')} disabled={isSubmitting} onKeyDown={(e) => { - if (e.key === 'Enter') onConfirm() + if (e.key === 'Enter') onSubmit() }} maxLength={MAX_NOTE_LENGTH} value={note}