"chore: update frontend dev script to include lint checks and add ESLint config file"

This commit is contained in:
louiscklaw
2025-06-04 02:35:32 +08:00
parent c0fad42f0a
commit 22fb620eef
48 changed files with 3315 additions and 97 deletions

View File

@@ -0,0 +1,32 @@
/**
* Custom hook to manage state with utility functions to set state, set a specific field, and reset state.
*
* @param {T} initialState - The initial state value.
*
* @returns {UseSetStateReturn<T>} - An object containing:
* - `state`: The current state.
* - `resetState`: A function to reset the state to the initial value.
* - `setState`: A function to update the state.
* - `setField`: A function to update a specific field in the state.
*
* @example
* const { state, setState, setField, resetState } = useSetState({ name: '', age: 0 });
*
* return (
* <div>
* <p>Name: {state.name}</p>
* <p>Age: {state.age}</p>
* <button onClick={() => setField('name', 'John')}>Set Name</button>
* <button onClick={resetState}>Reset</button>
* </div>
* );
*/
type UseSetStateReturn<T> = {
state: T;
resetState: (defaultState?: T) => void;
setState: (updateState: T | Partial<T>) => void;
setField: (name: keyof T, updateValue: T[keyof T]) => void;
};
declare function useSetState<T>(initialState?: T): UseSetStateReturn<T>;
export { type UseSetStateReturn, useSetState };