Commit a2a1771 1 parent 1d8838c commit a2a1771 Copy full SHA for a2a1771
File tree 5 files changed +28
-16
lines changed
5 files changed +28
-16
lines changed Original file line number Diff line number Diff line change
1
+ type RecordItem = {
2
+ name : string
3
+ }
4
+
5
+ export function sortRecordsByName < T extends RecordItem > ( record : T [ ] ) : T [ ] {
6
+ return record . sort ( ( a , b ) => a . name . localeCompare ( b . name ) )
7
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 10
10
} from ' @resplice/components'
11
11
import connectionStore from ' $modules/connection/connection.store'
12
12
import inviteStores from ' $modules/invite/invite.store'
13
- import { connectionsList } from ' $modules/connection/connection.helpers '
13
+ import { sortRecordsByName } from ' $common/utils '
14
14
import SearchHeader from ' $common/components/SearchHeader.svelte'
15
15
import ConnectionList from ' $modules/connection/components/ConnectionList.svelte'
16
16
import PendingConnectionList from ' $modules/invite/components/PendingConnectionList.svelte'
20
20
21
21
const inviteStore = inviteStores .invites
22
22
const pendingConnectionStore = inviteStores .pendingConnections
23
- $ : connections = connectionsList ( $connectionStore )
24
- $ : invites = Array .from ($inviteStore .values ())
25
- $ : pendingConnections = Array .from ($pendingConnectionStore .values ())
23
+ $ : connections = sortRecordsByName ( Array . from ( $connectionStore . values ()) )
24
+ $ : invites = sortRecordsByName ( Array .from ($inviteStore .values () ))
25
+ $ : pendingConnections = sortRecordsByName ( Array .from ($pendingConnectionStore .values () ))
26
26
27
27
onMount (() => {
28
28
// Get scroll position
Original file line number Diff line number Diff line change 1
1
<script lang =" ts" >
2
- import { AttributeActionIcon , Button , toast } from ' @resplice/components '
2
+ import { parsePhoneNumber } from ' libphonenumber-js '
3
3
import { AttributeAction } from ' @resplice/utils'
4
+ import { AttributeActionIcon , Button , toast } from ' @resplice/components'
4
5
import useProtocol from ' $common/protocol/useProtocol'
5
6
import type {
6
7
ProviderContact ,
14
15
export let attribute: ProviderContactAttribute
15
16
let isInviting = false
16
17
17
- function providerAttributeToAction(value : ProviderContactAttribute ): AttributeAction {
18
- switch (value .type ) {
18
+ function providerAttributeToAction(attribute : ProviderContactAttribute ): AttributeAction {
19
+ switch (attribute .type ) {
19
20
case ' email' :
20
21
return AttributeAction .Email
21
22
case ' phone' :
25
26
}
26
27
}
27
28
29
+ function providerAttributeValue(attribute : ProviderContactAttribute ): string {
30
+ switch (attribute .type ) {
31
+ case ' phone' :
32
+ return parsePhoneNumber (attribute .value , ' US' ).formatNational ()
33
+ default :
34
+ return attribute .value
35
+ }
36
+ }
37
+
28
38
async function invite(contact : ProviderContact , attribute : ProviderContactAttribute ) {
29
39
try {
30
40
isInviting = true
60
70
<p class =" font-semibold text-gray-800 truncate h-6 capitalize" >
61
71
{attribute .name }
62
72
</p >
63
- <p class ="truncate" >{attribute . value }</p >
73
+ <p class ="truncate" >{providerAttributeValue ( attribute ) }</p >
64
74
</div >
65
75
</div >
66
76
<Button
Original file line number Diff line number Diff line change 9
9
import type { ProviderContact , InviteState } from ' $modules/invite/services/contactProviders'
10
10
import { type Invite } from ' $modules/invite/invite.types'
11
11
import ContactImportAttribute from ' $modules/invite/components/ContactImportAttribute.svelte'
12
+ import { sortRecordsByName } from ' $common/utils'
12
13
13
14
const inviteStore = inviteStores .invites
14
15
39
40
40
41
$ : {
41
42
const connectionAttributeValues = $connectionAttributeValuesStore
42
- const invites = [ ... $inviteStore .values ()]
43
+ const invites = Array . from ( $inviteStore .values ())
43
44
44
45
contacts = contacts .map ((contact ) => ({
45
46
... contact ,
49
50
</script >
50
51
51
52
{#if contacts .length }
52
- {#each contacts as contact , idx }
53
+ {#each sortRecordsByName ( contacts ) as contact , idx }
53
54
<div class =" flex flex-col bg-white rounded-lg shadow-lg mb-4 divide-y-2" >
54
55
<div class =" w-full py-2 pr-4 flex items-center" >
55
56
<div class =" flex-1 overflow-hidden" >
You can’t perform that action at this time.
0 commit comments