0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00

Merge pull request #1487 from logto-io/charles-log-3546-add-unsaved-changes-warning-in-settings-page

fix(console): add unsaved changes warning in settings page
This commit is contained in:
Charles Zhao 2022-07-08 18:13:21 +08:00 committed by GitHub
commit 650cbd4746
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,7 @@ import CardTitle from '@/components/CardTitle';
import FormField from '@/components/FormField'; import FormField from '@/components/FormField';
import Select from '@/components/Select'; import Select from '@/components/Select';
import TabNav, { TabNavItem } from '@/components/TabNav'; import TabNav, { TabNavItem } from '@/components/TabNav';
import UnsavedChangesAlertModal from '@/components/UnsavedChangesAlertModal';
import useUserPreferences, { UserPreferences } from '@/hooks/use-user-preferences'; import useUserPreferences, { UserPreferences } from '@/hooks/use-user-preferences';
import * as detailsStyles from '@/scss/details.module.scss'; import * as detailsStyles from '@/scss/details.module.scss';
@ -27,7 +28,7 @@ const Settings = () => {
const { const {
handleSubmit, handleSubmit,
control, control,
formState: { isSubmitting }, formState: { isSubmitting, isDirty },
} = useForm<UserPreferences>({ defaultValues: data }); } = useForm<UserPreferences>({ defaultValues: data });
const onSubmit = handleSubmit(async (formData) => { const onSubmit = handleSubmit(async (formData) => {
@ -113,6 +114,7 @@ const Settings = () => {
</div> </div>
</form> </form>
)} )}
<UnsavedChangesAlertModal hasUnsavedChanges={isDirty} />
</Card> </Card>
); );
}; };