forked from b00tc4mp/isdi-bootcamp-202409
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modified class components from to functions, and adapted the logic an…
…d handles acordingly b00tc4mp#173
- Loading branch information
Showing
47 changed files
with
1,319 additions
and
1,858 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
import { storage } from '../data/index.js' | ||
import validate from './helpers/validate.js' | ||
import { validate } from 'com' | ||
|
||
export default userId => { | ||
export default (userId, targetUserId) => { | ||
validate.id(userId, 'userId') | ||
validate.id(targetUserId, 'targetUserId') | ||
|
||
const { users } = storage | ||
const user = users.find(user => user.id === userId) | ||
|
||
if (!user) throw new Error('user nor found') | ||
const found = users.some(({ id }) => id === userId) | ||
|
||
return user.name | ||
if (!found) throw new Error('user not found') | ||
|
||
const user = users.find(({ id }) => id === targetUserId) | ||
|
||
if (!user) throw new Error('target user not found') | ||
|
||
return user.name | ||
} |
Oops, something went wrong.