Skip to content

Commit

Permalink
Merge pull request #136 from AkshataKatwal16/admin
Browse files Browse the repository at this point in the history
Issue feat: add chanages for create user upon click on  send credential button
  • Loading branch information
itsvick authored Aug 14, 2024
2 parents a6b5c02 + fddbbc5 commit 3ea3891
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/components/CommonUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ const CommonUserModal: React.FC<UserModalProps> = ({
const setSubmittedButtonStatus = useSubmittedButtonStore(
(state: any) => state.setSubmittedButtonStatus
);
const noError = useSubmittedButtonStore(
(state: any) => state.noError);

const userEnteredEmail = useSubmittedButtonStore(
(state: any) => state.userEnteredEmail
);
Expand Down Expand Up @@ -457,11 +460,16 @@ const CommonUserModal: React.FC<UserModalProps> = ({
onClick={() => {

setSubmittedButtonStatus(true);
if(userType!==FormContextType.STUDENT && !isEditModal && submittedButtonStatus)
{
setOpenModal(true)

}
// if (userType !== FormContextType.STUDENT && !isEditModal && noError) {
// setOpenModal(true);
// }
// console.log(submittedButtonStatus)
setTimeout(() => {
console.log(noError)
if (userType !== FormContextType.STUDENT && !isEditModal && noError) {
setOpenModal(true);
}
}, 100);
console.log("Submit button was clicked");
}}
>
Expand Down
11 changes: 10 additions & 1 deletion src/components/DynamicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ const DynamicForm: React.FC<DynamicFormProps> = ({
const setUserEnteredEmail = useSubmittedButtonStore(
(state: any) => state.setUserEnteredEmail
);
const setNoError= useSubmittedButtonStore(
(state: any) => state.setNoError
);

const widgets: any = {
MultiSelectDropdown: MultiSelectDropdown,
Expand All @@ -62,6 +65,10 @@ const DynamicForm: React.FC<DynamicFormProps> = ({
};

const handleError = (errors: any) => {
if (errors.length === 0) {
console.log("No errors");
// You can perform any additional action here when there are no errors
}
console.log("handle error1");
if (errors.length > 0) {
const property = errors[0].property?.replace(/^root\./, "");
Expand Down Expand Up @@ -115,6 +122,8 @@ const DynamicForm: React.FC<DynamicFormProps> = ({

const transformErrors = (errors: any) => {
console.log("errors", errors);
errors.length===0? setNoError(true): setNoError(false)

console.log("schema", schema);

return errors?.map((error: any) => {
Expand Down Expand Up @@ -231,7 +240,7 @@ const DynamicForm: React.FC<DynamicFormProps> = ({
});
};
useEffect(() => {
setSubmittedButtonStatus(false);
// setSubmittedButtonStatus(false);
}, []);
return (
<div>
Expand Down
4 changes: 4 additions & 0 deletions src/utils/useSharedState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ const useSubmittedButtonStore = create((set) => ({
setAdminInformation: (data: any) => set({ adminInformation: data }),
// setSubmittedButtonStatus: (status: boolean) => set({ submittedButtonStatus: status }),
userEnteredEmail:"",
noError:false,
setNoError:(data: boolean) => set({ noError: data }),
setUserEnteredEmail: (status: string) => set({ userEnteredEmail: status }),
shouldFetch:true,
setShouldFetch:(data: boolean) => set({ shouldFetch: data }),

}));

Expand Down

0 comments on commit 3ea3891

Please sign in to comment.