You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			59 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			TypeScript
		
	
		
		
			
		
	
	
			59 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			TypeScript
		
	
| 
											4 years ago
										 | import React from 'react'; | ||
| 
											6 years ago
										 | import classNames from 'classnames'; | ||
| 
											4 years ago
										 | import { updateConfirmModal } from '../../state/ducks/modalDialog'; | ||
| 
											4 years ago
										 | import { useDispatch } from 'react-redux'; | ||
| 
											6 years ago
										 | 
 | ||
| 
											4 years ago
										 | type Props = { | ||
| 
											6 years ago
										 |   active: boolean; | ||
| 
											4 years ago
										 |   onClick: () => void; | ||
| 
											6 years ago
										 |   confirmationDialogParams?: any | undefined; | ||
| 
											4 years ago
										 | }; | ||
| 
											4 years ago
										 | 
 | ||
| 
											4 years ago
										 | export const SessionToggle = (props: Props) => { | ||
|  |   const dispatch = useDispatch(); | ||
| 
											6 years ago
										 | 
 | ||
| 
											4 years ago
										 |   const clickHandler = (event: any) => { | ||
| 
											6 years ago
										 |     const stateManager = (e: any) => { | ||
| 
											4 years ago
										 |       e.stopPropagation(); | ||
|  |       props.onClick(); | ||
| 
											6 years ago
										 |     }; | ||
|  | 
 | ||
| 
											4 years ago
										 |     if (props.confirmationDialogParams && props.confirmationDialogParams.shouldShowConfirm) { | ||
| 
											6 years ago
										 |       // If item needs a confirmation dialog to turn ON, render it
 | ||
| 
											4 years ago
										 |       const closeConfirmModal = () => { | ||
| 
											4 years ago
										 |         dispatch(updateConfirmModal(null)); | ||
| 
											4 years ago
										 |       }; | ||
| 
											4 years ago
										 | 
 | ||
| 
											4 years ago
										 |       dispatch( | ||
|  |         updateConfirmModal({ | ||
|  |           onClickOk: () => { | ||
|  |             stateManager(event); | ||
|  |             closeConfirmModal(); | ||
|  |           }, | ||
|  |           onClickClose: () => { | ||
|  |             updateConfirmModal(null); | ||
|  |           }, | ||
|  |           ...props.confirmationDialogParams, | ||
|  |           updateConfirmModal, | ||
|  |         }) | ||
|  |       ); | ||
| 
											6 years ago
										 | 
 | ||
|  |       return; | ||
| 
											6 years ago
										 |     } | ||
| 
											6 years ago
										 | 
 | ||
|  |     stateManager(event); | ||
| 
											4 years ago
										 |   }; | ||
|  | 
 | ||
|  |   return ( | ||
| 
											4 years ago
										 |     <div className="session-settings-item__selection"> | ||
|  |       <div | ||
|  |         className={classNames('session-toggle', props.active ? 'active' : '')} | ||
|  |         role="button" | ||
|  |         onClick={clickHandler} | ||
|  |       > | ||
|  |         <div className="knob" /> | ||
|  |       </div> | ||
| 
											4 years ago
										 |     </div> | ||
|  |   ); | ||
|  | }; |