Skip to content

Commit

Permalink
fix: Save button is not working on the app install configuration step (
Browse files Browse the repository at this point in the history
…#17176)

* fix: Save button is not working on the app install configuration step

* update

---------

Co-authored-by: Somay Chauhan <somaychauhan98@gmail.com>
  • Loading branch information
anikdhabal and SomayChauhan authored Oct 21, 2024
1 parent 3e0d532 commit b0e3e4c
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions apps/web/components/apps/installation/ConfigureStepCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const EventTypeGroup = ({
}: ConfigureStepCardProps & {
groupIndex: number;
setUpdatedEventTypesStatus: Dispatch<SetStateAction<TUpdatedEventTypesStatus>>;
submitRefs: Array<React.RefObject<HTMLButtonElement>>;
submitRefs: React.MutableRefObject<(HTMLButtonElement | null)[]>;
}) => {
const { control } = useFormContext<TEventTypesForm>();
const { fields, update } = useFieldArray({
Expand Down Expand Up @@ -174,7 +174,9 @@ const EventTypeGroup = ({
return res;
});
}}
ref={submitRefs[index]}
ref={(el) => {
submitRefs.current[index] = el;
}}
{...props}
/>
)
Expand All @@ -193,17 +195,8 @@ export const ConfigureStepCard: FC<ConfigureStepCardProps> = (props) => {
keyName: "fieldId",
});
const eventTypeGroups = watch("eventTypeGroups");
const submitRefs = useRef<Array<Array<React.RefObject<HTMLButtonElement>>>>([]);
const submitRefs = useRef<(HTMLButtonElement | null)[]>([]);

submitRefs.current = eventTypeGroups.reduce(
(arr: Array<Array<React.RefObject<HTMLButtonElement>>>, field) => {
const res = field.eventTypes
.filter((eventType) => eventType.selected)
.map((_ref) => React.createRef<HTMLButtonElement>());
return [...arr, res];
},
[]
);
const mainForSubmitRef = useRef<HTMLButtonElement>(null);
const [updatedEventTypesStatus, setUpdatedEventTypesStatus] = useState<TUpdatedEventTypesStatus>(
eventTypeGroups.reduce((arr: Array<{ id: number; updated: boolean }[]>, field) => {
Expand Down Expand Up @@ -245,7 +238,7 @@ export const ConfigureStepCard: FC<ConfigureStepCardProps> = (props) => {
<EventTypeGroup
groupIndex={groupIndex}
setUpdatedEventTypesStatus={setUpdatedEventTypesStatus}
submitRefs={submitRefs.current[groupIndex]}
submitRefs={submitRefs}
{...props}
/>
</div>
Expand All @@ -258,7 +251,7 @@ export const ConfigureStepCard: FC<ConfigureStepCardProps> = (props) => {
type="button"
data-testid="configure-step-save"
onClick={() => {
submitRefs.current.map((group) => group?.map((ref) => ref.current?.click()));
submitRefs.current.forEach((ref) => ref?.click());
setSubmit(true);
}}
loading={loading}>
Expand Down

0 comments on commit b0e3e4c

Please sign in to comment.