Skip to content

Commit

Permalink
DPG-2197: Adhoc session fixes (#476)
Browse files Browse the repository at this point in the history
Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>
  • Loading branch information
nabeelmd-eGov and nabeelmd-eGov authored Feb 2, 2024
1 parent 9d24c55 commit 84f5216
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,16 @@ const Create = () => {

const CreateAdhocTestSession = Digit.Hooks.useSessionStorage("CREATE_ADHOC_TEST", {});
const [sessionFormData,setSessionFormData, clearSessionFormData] = CreateAdhocTestSession;

const [formSession, setFormSession] = useState(sessionFormData);

useEffect(() => {
setFormSession(sessionFormData)
},[sessionFormData])

const onFormValueChange = (setValue, formData, formState, reset, setError, clearErrors, trigger, getValues) => {
if (!_.isEqual(sessionFormData, formData)) {
const temp = JSON.parse(sessionStorage.getItem("Digit.CREATE_ADHOC_TEST"))
if(!temp && _.isEmpty(formData?.TestStandard)) return;
if (!_.isEqual(temp?.value, formData)) {
if(Object.keys(sessionFormData)?.length===0){
setSessionFormData({ ...formData });
}else{
Expand Down Expand Up @@ -112,7 +119,7 @@ const Create = () => {

};
})}
defaultValues={sessionFormData}
defaultValues={formSession}
onSubmit={onSubmit}
fieldStyle={{ marginRight: 0 }}
noBreakLine={true}
Expand Down

0 comments on commit 84f5216

Please sign in to comment.