Skip to content

Commit

Permalink
Merge pull request #7054 from Avarjana/master
Browse files Browse the repository at this point in the history
Fix state update issue in SMS Templates UI
  • Loading branch information
Avarjana authored Oct 28, 2024
2 parents 4ddfe12 + aa3156e commit 8fcd3af
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/khaki-kings-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wso2is/console": patch
"@wso2is/admin.sms-templates.v1": patch
---

Fix state update issue in SMS Templates.
12 changes: 11 additions & 1 deletion features/admin.sms-templates.v1/pages/sms-customization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ const SMSCustomizationPage: FunctionComponent<SMSCustomizationPageInterface> = (
error: smsTemplatesListError
} = useGetSmsTemplatesList();

const { data: smsTemplate, isLoading: isSmsTemplateLoading, error: smsTemplateError } = useGetSmsTemplate(
const {
data: smsTemplate,
isLoading: isSmsTemplateLoading,
error: smsTemplateError,
mutate: mutateSmsTemplate
} = useGetSmsTemplate(
selectedSmsTemplateId,
selectedLocale,
isSystemTemplate,
Expand Down Expand Up @@ -208,6 +213,7 @@ const SMSCustomizationPage: FunctionComponent<SMSCustomizationPageInterface> = (
availableSmsTemplatesList?.find((template: SMSTemplateType) => template.id === templateId)?.description
);
setShouldFetch(true);
mutateSmsTemplate();
};

const handleTemplateChange = (updatedTemplateAttributes: Partial<SMSTemplate>): void => {
Expand All @@ -224,6 +230,7 @@ const SMSCustomizationPage: FunctionComponent<SMSCustomizationPageInterface> = (
setIsSystemTemplate(false);
setSelectedLocale(locale);
setShouldFetch(true);
mutateSmsTemplate();
};

const handleSubmit = (): void => {
Expand All @@ -245,6 +252,7 @@ const SMSCustomizationPage: FunctionComponent<SMSCustomizationPageInterface> = (
);
setIsSystemTemplate(false);
setShouldFetch(true);
mutateSmsTemplate();
})
.catch(() => {
dispatch(
Expand All @@ -267,6 +275,7 @@ const SMSCustomizationPage: FunctionComponent<SMSCustomizationPageInterface> = (
);
setIsSystemTemplate(false);
setShouldFetch(true);
mutateSmsTemplate();
})
.catch(() => {
dispatch(
Expand Down Expand Up @@ -297,6 +306,7 @@ const SMSCustomizationPage: FunctionComponent<SMSCustomizationPageInterface> = (
setSelectedLocale(SMSTemplateConstants.DEAFULT_LOCALE);
setIsSystemTemplate(false);
setShouldFetch(true);
mutateSmsTemplate();
})
.catch(() => {
dispatch(
Expand Down

0 comments on commit 8fcd3af

Please sign in to comment.