Krishya | dbfadaa | 2025-06-09 20:33:15 +0800 | [diff] [blame^] | 1 | import React from 'react'; |
| 2 | |
| 3 | const CreatePromotionDialog = ({ |
| 4 | showCreateDialog, |
| 5 | formData, |
| 6 | handleInputChange, |
| 7 | closeCreateDialog, |
| 8 | handleCreatePromotion, |
| 9 | fetchPromoColdTorrents, |
| 10 | showPromoColdTable, |
| 11 | coldTorrents, |
| 12 | handlePromoTorrentSelection |
| 13 | }) => { |
| 14 | return ( |
| 15 | showCreateDialog && ( |
| 16 | <div className="dialog-overlay"> |
| 17 | <div className="dialog"> |
| 18 | <h3>创建冷门资源促销</h3> |
| 19 | <div className="form-item"> |
| 20 | <label>促销名称:</label> |
| 21 | <input |
| 22 | type="text" |
| 23 | name="name" |
| 24 | value={formData.name} |
| 25 | onChange={handleInputChange} |
| 26 | placeholder="请输入促销名称" |
| 27 | /> |
| 28 | </div> |
| 29 | <div className="form-item"> |
| 30 | <label>开始时间:</label> |
| 31 | <input |
| 32 | type="datetime-local" |
| 33 | name="startTime" |
| 34 | value={formData.startTime} |
| 35 | onChange={handleInputChange} |
| 36 | /> |
| 37 | </div> |
| 38 | <div className="form-item"> |
| 39 | <label>结束时间:</label> |
| 40 | <input |
| 41 | type="datetime-local" |
| 42 | name="endTime" |
| 43 | value={formData.endTime} |
| 44 | onChange={handleInputChange} |
| 45 | /> |
| 46 | </div> |
| 47 | <div className="form-item"> |
| 48 | <label>折扣百分比:</label> |
| 49 | <input |
| 50 | type="number" |
| 51 | name="discountPercentage" |
| 52 | value={formData.discountPercentage} |
| 53 | onChange={handleInputChange} |
| 54 | placeholder="正数表示上传加成,负数表示下载折扣" |
| 55 | step="0.1" |
| 56 | /> |
| 57 | </div> |
| 58 | <div className="form-item"> |
| 59 | <label>适用种子:</label> |
| 60 | <button |
| 61 | className="cold-btn small" |
| 62 | onClick={fetchPromoColdTorrents} |
| 63 | > |
| 64 | 选择冷门资源 <span>(点击加载列表)</span> |
| 65 | </button> |
| 66 | |
| 67 | {showPromoColdTable && ( |
| 68 | <div className="torrent-table-container"> |
| 69 | <table className="torrent-selection-table"> |
| 70 | <thead> |
| 71 | <tr> |
| 72 | <th>选择</th> |
| 73 | <th>序号</th> |
| 74 | <th>资源名称</th> |
| 75 | <th>资源ID</th> |
| 76 | <th>分类</th> |
| 77 | <th>下载用户数</th> |
| 78 | <th>浏览次数</th> |
| 79 | </tr> |
| 80 | </thead> |
| 81 | <tbody> |
| 82 | {coldTorrents.map((torrent, index) => ( |
| 83 | <tr key={torrent.id}> |
| 84 | <td> |
| 85 | <input |
| 86 | type="checkbox" |
| 87 | checked={formData.applicableTorrentIds.includes(torrent.id)} |
| 88 | onChange={(e) => handlePromoTorrentSelection(torrent.id, e.target.checked)} |
| 89 | /> |
| 90 | </td> |
| 91 | <td>{index + 1}</td> |
| 92 | <td>{torrent.title}</td> |
| 93 | <td>{torrent.id}</td> |
| 94 | <td>{torrent.category || '未分类'}</td> |
| 95 | <td>{torrent.leechers || 0}</td> |
| 96 | <td>{torrent.views || 0}</td> |
| 97 | </tr> |
| 98 | ))} |
| 99 | </tbody> |
| 100 | </table> |
| 101 | </div> |
| 102 | )} |
| 103 | </div> |
| 104 | |
| 105 | <div className="dialog-buttons"> |
| 106 | <button onClick={handleCreatePromotion}>确定</button> |
| 107 | <button onClick={closeCreateDialog}>取消</button> |
| 108 | </div> |
| 109 | </div> |
| 110 | </div> |
| 111 | ) |
| 112 | ); |
| 113 | }; |
| 114 | |
| 115 | export default CreatePromotionDialog; |