refactor(Project): split out components into their own files
This commit is contained in:
13
frontend/src/shared/hooks/useStateWithLocalStorage.ts
Normal file
13
frontend/src/shared/hooks/useStateWithLocalStorage.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import React from 'react';
|
||||
|
||||
const useStateWithLocalStorage = (localStorageKey: string): [string, React.Dispatch<React.SetStateAction<string>>] => {
|
||||
const [value, setValue] = React.useState<string>(localStorage.getItem(localStorageKey) || '');
|
||||
|
||||
React.useEffect(() => {
|
||||
localStorage.setItem(localStorageKey, value);
|
||||
}, [value]);
|
||||
|
||||
return [value, setValue];
|
||||
};
|
||||
|
||||
export default useStateWithLocalStorage;
|
5
frontend/src/shared/utils/email.ts
Normal file
5
frontend/src/shared/utils/email.ts
Normal file
@ -0,0 +1,5 @@
|
||||
const RFC2822_EMAIL = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
|
||||
|
||||
export default function isValidEmail(target: string) {
|
||||
return RFC2822_EMAIL.test(target);
|
||||
}
|
5
frontend/src/shared/utils/localStorage.ts
Normal file
5
frontend/src/shared/utils/localStorage.ts
Normal file
@ -0,0 +1,5 @@
|
||||
const localStorage = {
|
||||
CARD_LABEL_VARIANT_STORAGE_KEY: 'card_label_variant',
|
||||
};
|
||||
|
||||
export default localStorage;
|
Reference in New Issue
Block a user