Persisting admin credentials in session storage
This commit is contained in:
parent
81ff27fd0c
commit
57e0b32082
|
@ -1,7 +1,13 @@
|
|||
import { createForm } from '@felte/solid';
|
||||
import reporter from '@felte/reporter-tippy';
|
||||
import { Button, Dialog, TextField } from '@kobalte/core';
|
||||
import { Component, createSignal, JSXElement, Show } from 'solid-js';
|
||||
import {
|
||||
Component,
|
||||
createEffect,
|
||||
createSignal,
|
||||
JSXElement,
|
||||
Show,
|
||||
} from 'solid-js';
|
||||
import 'tippy.js/dist/tippy.css';
|
||||
|
||||
interface CredentialsType {
|
||||
|
@ -17,6 +23,13 @@ export { adminCredentials };
|
|||
interface Props {}
|
||||
|
||||
const Credentials: Component<Props> = (props) => {
|
||||
createEffect(() => {
|
||||
const storedAdminCredentials = sessionStorage.getItem('adminCredentials');
|
||||
if (storedAdminCredentials) {
|
||||
setAdminCredentials(JSON.parse(storedAdminCredentials));
|
||||
}
|
||||
});
|
||||
|
||||
const validationHandler = async (values: any) => {
|
||||
const { database, username, password } = values;
|
||||
let errors: any = {};
|
||||
|
@ -84,6 +97,7 @@ const Credentials: Component<Props> = (props) => {
|
|||
context,
|
||||
});
|
||||
setAdminCredentials(values);
|
||||
sessionStorage.setItem('adminCredentials', JSON.stringify(values));
|
||||
};
|
||||
|
||||
let { form, data } = createForm({
|
||||
|
|
Loading…
Reference in New Issue