Skip to content

Commit

Permalink
refactor: #1327 Refactor Admin Dev Management using react-redux hooks (
Browse files Browse the repository at this point in the history
  • Loading branch information
Trường An authored Jun 2, 2020
1 parent fdef34b commit c34899b
Show file tree
Hide file tree
Showing 28 changed files with 1,121 additions and 241 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/aml-checklist/src/tests/badges/badge-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-functions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-statements.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/elements/src/utils/query-params/query-params.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { isEmptyObject } from '../validators/validate-object'

export const setQueryParams = (params: Object) => {
if (isEmptyObject(params)) return ''
return Object.keys(params)
.filter(key => params[key] !== undefined && params[key] !== null && params[key] !== '')
.map(key => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { isEmptyObject } from '../validate-object'

describe('isEmptyObject', () => {
it('should return true', () => {
expect(isEmptyObject({})).toBe(true)
expect(isEmptyObject([])).toBe(true)
})

it('should return false', () => {
expect(isEmptyObject({ a: 'a' })).toBe(false)
expect(isEmptyObject(['1'])).toBe(false)
})
})
1 change: 1 addition & 0 deletions packages/elements/src/utils/validators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export { isNumberOnly } from './validate-number'
export { validateRequire, fieldValidateRequire, dropdownSelectFieldValidateRequire } from './validate-require'
export { validateURI } from './validate-uri'
export { validatePassword, isValidPassword } from './validate-password'
export { isEmptyObject } from './validate-object'
8 changes: 8 additions & 0 deletions packages/elements/src/utils/validators/validate-object.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function isEmptyObject(value: Object): boolean {
return (
value === undefined ||
value === null ||
(typeof value === 'object' && Object.keys(value).length === 0) ||
(typeof value === 'string' && value.trim().length === 0)
)
}
2 changes: 1 addition & 1 deletion packages/geo-diary/src/tests/badges/badge-functions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c34899b

Please sign in to comment.