| 
									
										
										
										
											2023-01-03 11:55:46 -08:00
										 |  |  | // Copyright 2018 Signal Messenger, LLC
 | 
					
						
							| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-09 14:29:13 -07:00
										 |  |  | import React from 'react'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-26 16:51:55 -04:00
										 |  |  | import { Button, ButtonSize, ButtonVariant } from '../Button'; | 
					
						
							| 
									
										
										
										
											2021-09-07 14:55:03 -05:00
										 |  |  | import { SystemMessage } from './SystemMessage'; | 
					
						
							| 
									
										
										
										
											2018-07-09 14:29:13 -07:00
										 |  |  | import { ContactName } from './ContactName'; | 
					
						
							|  |  |  | import { Intl } from '../Intl'; | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { LocalizerType } from '../../types/Util'; | 
					
						
							| 
									
										
										
										
											2018-07-09 14:29:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-14 12:07:05 -06:00
										 |  |  | export type ContactType = { | 
					
						
							| 
									
										
										
										
											2019-03-15 15:18:00 -07:00
										 |  |  |   id: string; | 
					
						
							| 
									
										
										
										
											2020-07-23 18:35:32 -07:00
										 |  |  |   title: string; | 
					
						
							| 
									
										
										
										
											2021-01-14 12:07:05 -06:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2018-07-09 14:29:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-20 10:42:28 -07:00
										 |  |  | export type PropsData = { | 
					
						
							| 
									
										
										
										
											2018-07-09 14:29:13 -07:00
										 |  |  |   isGroup: boolean; | 
					
						
							| 
									
										
										
										
											2019-03-15 15:18:00 -07:00
										 |  |  |   contact: ContactType; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type PropsHousekeeping = { | 
					
						
							| 
									
										
										
										
											2019-01-14 13:49:58 -08:00
										 |  |  |   i18n: LocalizerType; | 
					
						
							| 
									
										
										
										
											2019-03-15 15:18:00 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type PropsActions = { | 
					
						
							| 
									
										
										
										
											2022-12-09 00:53:19 -05:00
										 |  |  |   toggleSafetyNumberModal: (id: string) => void; | 
					
						
							| 
									
										
										
										
											2019-03-15 15:18:00 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-26 07:30:31 -07:00
										 |  |  | export type Props = PropsData & PropsHousekeeping & PropsActions; | 
					
						
							| 
									
										
										
										
											2018-07-09 14:29:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function SafetyNumberNotification({ | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   contact, | 
					
						
							|  |  |  |   isGroup, | 
					
						
							|  |  |  |   i18n, | 
					
						
							| 
									
										
										
										
											2022-12-09 00:53:19 -05:00
										 |  |  |   toggleSafetyNumberModal, | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | }: Props): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   const changeKey = isGroup | 
					
						
							|  |  |  |     ? 'safetyNumberChangedGroup' | 
					
						
							|  |  |  |     : 'safetyNumberChanged'; | 
					
						
							| 
									
										
										
										
											2018-07-09 14:29:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2021-09-07 14:55:03 -05:00
										 |  |  |     <SystemMessage | 
					
						
							|  |  |  |       icon="safety-number" | 
					
						
							|  |  |  |       contents={ | 
					
						
							| 
									
										
										
										
											2023-01-05 14:43:33 -08:00
										 |  |  |         // eslint-disable-next-line local-rules/valid-i18n-keys
 | 
					
						
							| 
									
										
										
										
											2021-09-07 14:55:03 -05:00
										 |  |  |         <Intl | 
					
						
							|  |  |  |           id={changeKey} | 
					
						
							|  |  |  |           components={[ | 
					
						
							|  |  |  |             <span | 
					
						
							|  |  |  |               key="external-1" | 
					
						
							|  |  |  |               className="module-safety-number-notification__contact" | 
					
						
							|  |  |  |             > | 
					
						
							|  |  |  |               <ContactName | 
					
						
							|  |  |  |                 title={contact.title} | 
					
						
							|  |  |  |                 module="module-safety-number-notification__contact" | 
					
						
							|  |  |  |               /> | 
					
						
							|  |  |  |             </span>, | 
					
						
							|  |  |  |           ]} | 
					
						
							|  |  |  |           i18n={i18n} | 
					
						
							|  |  |  |         /> | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       button={ | 
					
						
							| 
									
										
										
										
											2021-08-26 16:51:55 -04:00
										 |  |  |         <Button | 
					
						
							|  |  |  |           onClick={() => { | 
					
						
							| 
									
										
										
										
											2022-12-09 00:53:19 -05:00
										 |  |  |             toggleSafetyNumberModal(contact.id); | 
					
						
							| 
									
										
										
										
											2021-08-26 16:51:55 -04:00
										 |  |  |           }} | 
					
						
							|  |  |  |           size={ButtonSize.Small} | 
					
						
							|  |  |  |           variant={ButtonVariant.SystemMessage} | 
					
						
							|  |  |  |         > | 
					
						
							| 
									
										
										
										
											2023-02-03 18:32:17 -08:00
										 |  |  |           {i18n('icu:SafetyNumberNotification__viewSafetyNumber')} | 
					
						
							| 
									
										
										
										
											2021-08-26 16:51:55 -04:00
										 |  |  |         </Button> | 
					
						
							| 
									
										
										
										
											2021-09-07 14:55:03 -05:00
										 |  |  |       } | 
					
						
							|  |  |  |     /> | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } |