From 3143a774c77bb8d3625fdcd8d6be4201be3f2560 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Wed, 2 Apr 2025 20:08:59 -0400 Subject: [PATCH] feat: oops commit the user role change page --- app/components/RadioGroup.tsx | 67 ++++++++++++++ app/routes/users/components/menu.tsx | 14 ++- app/routes/users/components/user-row.tsx | 2 +- app/routes/users/dialogs/reassign-user.tsx | 101 +++++++++++++++++++++ app/routes/users/user-actions.ts | 62 +++++++++++-- app/server/web/sessions.ts | 39 +++++++- 6 files changed, 271 insertions(+), 14 deletions(-) create mode 100644 app/components/RadioGroup.tsx create mode 100644 app/routes/users/dialogs/reassign-user.tsx diff --git a/app/components/RadioGroup.tsx b/app/components/RadioGroup.tsx new file mode 100644 index 0000000..e649d44 --- /dev/null +++ b/app/components/RadioGroup.tsx @@ -0,0 +1,67 @@ +import React, { createContext, useContext, useRef } from 'react'; +import { + AriaRadioGroupProps, + AriaRadioProps, + VisuallyHidden, + useFocusRing, +} from 'react-aria'; +import { RadioGroupState } from 'react-stately'; +import cn from '~/utils/cn'; + +import { useRadio, useRadioGroup } from 'react-aria'; +import { useRadioGroupState } from 'react-stately'; + +interface RadioGroupProps extends AriaRadioGroupProps { + children: React.ReactElement[]; + className?: string; +} + +const RadioContext = createContext(null); + +function RadioGroup({ children, label, className, ...props }: RadioGroupProps) { + const state = useRadioGroupState(props); + const { radioGroupProps, labelProps } = useRadioGroup(props, state); + + return ( +
+ + {label} + + {children} +
+ ); +} + +interface RadioProps extends AriaRadioProps { + className?: string; +} + +function Radio({ children, className, ...props }: RadioProps) { + const state = useContext(RadioContext); + const ref = useRef(null); + const { inputProps, isSelected, isDisabled } = useRadio(props, state!, ref); + const { isFocusVisible, focusProps } = useFocusRing(); + + return ( +