|
| 1 | +import React from 'react'; |
| 2 | +import Modal from '../Modal'; |
| 3 | +import { color, fontSize, bp } from '../../variables'; |
| 4 | +import withLogic from './logic'; |
| 5 | + |
| 6 | +const DeleteConfirm = ({ |
| 7 | + deleteType, |
| 8 | + deleteName, |
| 9 | + onDelete, |
| 10 | + inputValue, |
| 11 | + setInputValue, |
| 12 | + open, |
| 13 | + openModal, |
| 14 | + closeModal |
| 15 | +}) => { |
| 16 | + return ( |
| 17 | + <React.Fragment> |
| 18 | + <button className="button--page" onClick={openModal}> |
| 19 | + Delete |
| 20 | + </button> |
| 21 | + <Modal |
| 22 | + isOpen={open} |
| 23 | + onRequestClose={closeModal} |
| 24 | + contentLabel={`Confirm delete ${deleteType}`} |
| 25 | + > |
| 26 | + <React.Fragment> |
| 27 | + <p> |
| 28 | + This will delete all resources associated with the {deleteType}{' '} |
| 29 | + <span className="delete-name">{deleteName}</span> and cannot be |
| 30 | + undone. Make sure this is something you really want to do! |
| 31 | + </p> |
| 32 | + <p>Type the name of the {deleteType} to confirm.</p> |
| 33 | + <div className="form-input"> |
| 34 | + <input type="text" value={inputValue} onChange={setInputValue} /> |
| 35 | + <a href="#" className="hover-state" onClick={closeModal}> |
| 36 | + cancel |
| 37 | + </a> |
| 38 | + <button |
| 39 | + className="button--modal" |
| 40 | + disabled={inputValue !== deleteName} |
| 41 | + onClick={() => onDelete()} |
| 42 | + > |
| 43 | + Delete |
| 44 | + </button> |
| 45 | + </div> |
| 46 | + </React.Fragment> |
| 47 | + </Modal> |
| 48 | + <style jsx>{` |
| 49 | + input { |
| 50 | + margin-right: 10px; |
| 51 | + width: 100%; |
| 52 | + } |
| 53 | + button { |
| 54 | + margin-right: 10px; |
| 55 | + cursor: pointer; |
| 56 | + } |
| 57 | + a.hover-state { |
| 58 | + margin-right: 10px; |
| 59 | + color: ${color.blue}; |
| 60 | + } |
| 61 | + .delete-name { |
| 62 | + font-weight: bold; |
| 63 | + color: ${color.lightBlue}; |
| 64 | + } |
| 65 | + .form-input { |
| 66 | + display: flex; |
| 67 | + } |
| 68 | + .button--page { |
| 69 | + align-self: flex-end; |
| 70 | + background-color: ${color.midGrey}; |
| 71 | + border: none; |
| 72 | + border-radius: 20px; |
| 73 | + color: ${color.darkGrey}; |
| 74 | + font-family: 'source-code-pro', sans-serif; |
| 75 | + ${fontSize(13)}; |
| 76 | + padding: 3px 20px 2px; |
| 77 | + text-transform: uppercase; |
| 78 | + @media ${bp.tinyUp} { |
| 79 | + align-self: auto; |
| 80 | + } |
| 81 | + } |
| 82 | + .button--modal { |
| 83 | + align-self: flex-end; |
| 84 | + background-color: ${color.lightestGrey}; |
| 85 | + border: none; |
| 86 | + border-radius: 20px; |
| 87 | + color: ${color.darkGrey}; |
| 88 | + font-family: 'source-code-pro', sans-serif; |
| 89 | + ${fontSize(13)}; |
| 90 | + padding: 3px 20px 2px; |
| 91 | + text-transform: uppercase; |
| 92 | + @media ${bp.tinyUp} { |
| 93 | + align-self: auto; |
| 94 | + } |
| 95 | +
|
| 96 | + &:disabled { |
| 97 | + color: ${color.grey}; |
| 98 | + cursor: default; |
| 99 | + } |
| 100 | + } |
| 101 | + `}</style> |
| 102 | + </React.Fragment> |
| 103 | + ); |
| 104 | +}; |
| 105 | + |
| 106 | +export default withLogic(DeleteConfirm); |
0 commit comments