Repository navigation
Expand file tree
/
Copy patheditEmail.ts
More file actions
65 lines (57 loc) · 1.76 KB
/
Copy patheditEmail.ts
File metadata and controls
65 lines (57 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { IntervalActionHandler } from '../..'
import { fakeDb, getImageUrl } from '../utils/helpers'
const editEmailForUser: IntervalActionHandler = async io => {
console.log("Let's say hello...")
type User = Awaited<ReturnType<typeof fakeDb['find']>>[0]
const resp = await io.group([
io.display.heading('Edit email address for user'),
io.search<User>('Find a user', {
placeholder: 'Search by name...',
onSearch: async query => {
return fakeDb.find(query)
},
renderResult: user => ({
label: `${user.first_name} ${user.last_name}`,
description: user.email,
imageUrl: getImageUrl(user),
}),
}),
io.select.single('Choose role', {
options: [
{ label: 'Admin', value: 'a' },
{ label: 'Editor', value: 'b' },
{ label: 'Viewer', value: 'c' },
],
}),
io.input.text('Enter their new name'),
io.input.email('Enter their new email', { placeholder: 'you@example.com' }),
io.input.number('Enter an amount', {
currency: 'USD',
}),
io.input.boolean('Are you sure?'),
io.select.single('Select an opt', {
options: [
{ label: 'A', value: 'a' },
{ label: 'B', value: 'b' },
],
}),
io.select.multiple('Select some opts', {
options: [
{ label: 'A', value: 'a' },
{ label: 'B', value: 'b' },
],
}),
io.select.table('Select from this table', {
data: [
{ label: 'A', value: 'a' },
{ label: 'B', value: 'b', otherExtraData: 'ok' },
{ label: 'C', value: 'c', extraData: true },
],
}),
])
const found = resp[1]
console.log(found)
await io.display.object('Response', { data: resp })
console.log('Resp', resp)
}
export default editEmailForUser