mirror of
https://github.com/idanoo/autobrr
synced 2025-07-24 01:09:13 +00:00
refactor(web): update to react 18 and other deps (#285)
* Started refactoring codebase for React 18. * Migrated to react-router v6 fully * Removed useless test setup along with relevant packages. * Removed leftover console.log statement * feat: use status forbidden for onboarding * refactor(web): use react hook form on login * fix: comply with r18 shenanigans * chore: update packages
This commit is contained in:
parent
d065fee16b
commit
4d753b76ed
24 changed files with 2252 additions and 2145 deletions
|
@ -65,3 +65,21 @@ export function slugify(str: string) {
|
|||
.trim()
|
||||
.replace(/[-\s]+/g, "-");
|
||||
}
|
||||
|
||||
// WARNING: This is not a drop in replacement solution and
|
||||
// it might not work for some edge cases. Test your code!
|
||||
export const get = <T> (obj: T, path: string|Array<any>, defValue?: string) => {
|
||||
// If path is not defined or it has false value
|
||||
if (!path)
|
||||
return undefined;
|
||||
// Check if path is string or array. Regex : ensure that we do not have '.' and brackets.
|
||||
// Regex explained: https://regexr.com/58j0k
|
||||
const pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
|
||||
// Find value
|
||||
const result = pathArray && pathArray.reduce(
|
||||
(prevObj, key) => prevObj && prevObj[key],
|
||||
obj
|
||||
);
|
||||
// If found value is undefined return default value; otherwise return the value
|
||||
return result === undefined ? defValue : result;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue