Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add field validation to resolve the Update Profile Issue #8809

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7fff299
Add field validation to resolve the Update Profile Issue
JavidSumra Oct 17, 2024
5fee85e
refactor(profile): migrated change detection from useMemo to useEffec…
JavidSumra Oct 17, 2024
7b775a3
Discard package-lock.json file
JavidSumra Oct 17, 2024
391dcab
fix: prevent isDirty from updating on load due to phone number valida…
JavidSumra Oct 17, 2024
e39adc5
removed unnecessary console logging
JavidSumra Oct 17, 2024
34f6bbb
Merge branch 'develop' into issues/8804/profile-update-validation
JavidSumra Oct 17, 2024
1c3c769
fix: removed 'useEffect' from 'PhoneNumberFormField.tsx' Component
JavidSumra Oct 17, 2024
b2735fc
Merge branch 'issues/8804/profile-update-validation' of github.com:Ja…
JavidSumra Oct 17, 2024
217ae44
Merge branch 'develop' into issues/8804/profile-update-validation
nihal467 Oct 18, 2024
4ebc283
Merge branch 'develop' of github.com:JavidSumra/care_fe into issues/8…
JavidSumra Oct 18, 2024
03d2271
Merge branch 'ohcnetwork:develop' into issues/8804/profile-update-val…
JavidSumra Oct 21, 2024
f1422d8
Merge branch 'issues/8804/profile-update-validation' of github.com:Ja…
JavidSumra Oct 21, 2024
7b07e3b
Merge branch 'ohcnetwork:develop' into issues/8804/profile-update-val…
JavidSumra Oct 21, 2024
cf1fd70
Merge branch 'develop' into issues/8804/profile-update-validation
JavidSumra Oct 21, 2024
7700550
fix: Update a condition to check falsy value
JavidSumra Oct 21, 2024
1a2b837
Merge branch 'issues/8804/profile-update-validation' of github.com:Ja…
JavidSumra Oct 21, 2024
e0d75dd
fix correct test cases according to current implementation
JavidSumra Oct 22, 2024
00963b2
Merge Conflict's fixed
JavidSumra Oct 22, 2024
555811e
Merge branch 'develop' into issues/8804/profile-update-validation
JavidSumra Oct 23, 2024
c98af74
Merge branch 'develop' of github.com:JavidSumra/care_fe into issues/8…
JavidSumra Oct 23, 2024
5efa3cd
Merge branch 'issues/8804/profile-update-validation' of github.com:Ja…
JavidSumra Oct 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 3 additions & 135 deletions package-lock.json
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 19 additions & 2 deletions src/Components/Users/UserProfile.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useReducer, FormEvent } from "react";
import { useState, useReducer, FormEvent, useEffect } from "react";
import { GENDER_TYPES } from "../../Common/constants";
import { validateEmailAddress } from "../../Common/validation";
import * as Notification from "../../Utils/Notifications.js";
Expand Down Expand Up @@ -117,6 +117,8 @@ export default function UserProfile() {
isChecking: false,
isUpdateAvailable: false,
});
const [hasChanges, setHasChanges] = useState<boolean>(false);
const [isFieldLoaded, setIsFieldLoaded] = useState<boolean>(false);

rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
const authUser = useAuthUser();

Expand Down Expand Up @@ -172,6 +174,7 @@ export default function UserProfile() {
type: "set_form",
form: formData,
});
setHasChanges(false);
},
});

Expand Down Expand Up @@ -324,8 +327,18 @@ export default function UserProfile() {
type: "set_form",
form: { ...states.form, [event.name]: event.value },
});
setIsFieldLoaded(true);
};

useEffect(() => {
if (showEdit && isFieldLoaded) {
setHasChanges(true);
} else {
setIsFieldLoaded(false);
setHasChanges(false);
}
}, [handleFieldChange]);

const getDate = (value: any) =>
value && dayjs(value).isValid() && dayjs(value).toDate();

Expand Down Expand Up @@ -788,7 +801,11 @@ export default function UserProfile() {
</div>
</div>
<div className="bg-secondary-50 px-4 py-3 text-right sm:px-6">
<Submit onClick={handleSubmit} label={t("update")} />
<Submit
onClick={handleSubmit}
label={t("update")}
disabled={!hasChanges}
/>
</div>
</div>
</form>
Expand Down
Loading