tomzarai commited on
Commit
5269e5c
·
verified ·
1 Parent(s): 6c6ae77

Upload components/DeviceActionModal.jsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/DeviceActionModal.jsx +138 -0
components/DeviceActionModal.jsx ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+
3
+ const DeviceActionModal = ({ device, action, onClose, onConfirm }) => {
4
+ if (!device || !action) return null;
5
+
6
+ const getActionIcon = (name) => {
7
+ switch (name) {
8
+ case 'Sync':
9
+ return (
10
+ <svg xmlns="http://www.w3.org/2000/svg" className="h-12 w-12 text-blue-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
11
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
12
+ </svg>
13
+ );
14
+ case 'Backup':
15
+ return (
16
+ <svg xmlns="http://www.w3.org/2000/svg" className="h-12 w-12 text-green-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
17
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M8 7v8a2 2 0 002 2h6M8 7V5a2 2 0 012-2h4.586a1 1 0 01.707.293l4.414 4.414a1 1 0 01.293.707V15a2 2 0 01-2 2h-2M8 7H6a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2v-2" />
18
+ </svg>
19
+ );
20
+ case 'Restore':
21
+ return (
22
+ <svg xmlns="http://www.w3.org/2000/svg" className="h-12 w-12 text-red-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
23
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
24
+ </svg>
25
+ );
26
+ case 'Erase':
27
+ return (
28
+ <svg xmlns="http://www.w3.org/2000/svg" className="h-12 w-12 text-red-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
29
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
30
+ </svg>
31
+ );
32
+ case 'Update':
33
+ return (
34
+ <svg xmlns="http://www.w3.org/2000/svg" className="h-12 w-12 text-purple-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
35
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
36
+ </svg>
37
+ );
38
+ case 'Unlock':
39
+ return (
40
+ <svg xmlns="http://www.w3.org/2000/svg" className="h-12 w-12 text-yellow-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
41
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
42
+ </svg>
43
+ );
44
+ default:
45
+ return (
46
+ <svg xmlns="http://www.w3.org/2000/svg" className="h-12 w-12 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
47
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
48
+ </svg>
49
+ );
50
+ }
51
+ };
52
+
53
+ const getActionTitle = (name) => {
54
+ switch (name) {
55
+ case 'Sync': return 'Sync Device';
56
+ case 'Backup': return 'Create Backup';
57
+ case 'Restore': return 'Restore Device';
58
+ case 'Erase': return 'Erase All Content';
59
+ case 'Update': return 'Update Software';
60
+ case 'Unlock': return 'Unlock Device';
61
+ default: return name;
62
+ }
63
+ };
64
+
65
+ const getActionDescription = (name) => {
66
+ switch (name) {
67
+ case 'Sync': return `Sync data with ${device.name} including photos, music, and contacts.`;
68
+ case 'Backup': return `Create a full backup of ${device.name} with all settings and data.`;
69
+ case 'Restore': return `Restore ${device.name} to factory settings. This will erase all data.`;
70
+ case 'Erase': return `Erase all content and settings from ${device.name}. This cannot be undone.`;
71
+ case 'Update': return `Check for and install the latest software updates for ${device.name}.`;
72
+ case 'Unlock': return `Unlock ${device.name} if it's locked or requires a passcode.`;
73
+ default: return `Perform ${name} operation on ${device.name}.`;
74
+ }
75
+ };
76
+
77
+ return (
78
+ <div className="fixed inset-0 z-50 overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true">
79
+ <div className="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
80
+ <div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" aria-hidden="true" onClick={onClose}></div>
81
+ <span className="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span>
82
+
83
+ <div className="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg w-full">
84
+ <div className="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
85
+ <div className="sm:flex sm:items-start">
86
+ <div className="mt-3 text-center sm:mt-0 sm:text-left w-full">
87
+ <div className="flex justify-center mb-4">
88
+ {getActionIcon(action.name)}
89
+ </div>
90
+
91
+ <h3 className="text-lg leading-6 font-medium text-gray-900 text-center" id="modal-title">
92
+ {getActionTitle(action.name)}
93
+ </h3>
94
+
95
+ <div className="mt-4">
96
+ <p className="text-sm text-gray-500 text-center">
97
+ {getActionDescription(action.name)}
98
+ </p>
99
+ <p className="text-sm text-gray-700 mt-2 text-center font-medium">
100
+ Device: <span className="font-bold">{device.name}</span>
101
+ </p>
102
+ </div>
103
+
104
+ {action.danger && (
105
+ <div className="mt-6 bg-red-50 border border-red-200 rounded-lg p-4">
106
+ <div className="flex">
107
+ <div className="flex-shrink-0">
108
+ <svg className="h-5 w-5 text-red-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
109
+ <path fillRule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clipRule="evenodd" />
110
+ </svg>
111
+ </div>
112
+ <div className="ml-3">
113
+ <p className="text-sm text-red-700">
114
+ <span className="font-bold">Warning: </span>
115
+ {action.name === 'Erase'
116
+ ? 'This will permanently delete all data on the device. Make sure you have a backup first.'
117
+ : 'This action may cause data loss. Proceed with caution.'}
118
+ </p>
119
+ </div>
120
+ </div>
121
+ </div>
122
+ )}
123
+ </div>
124
+ </div>
125
+ </div>
126
+ <div className="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
127
+ <button
128
+ type="button"
129
+ className={`w-full inline-flex justify-center rounded-md border shadow-sm px-4 py-2 text-base font-medium text-white focus:outline-none sm:ml-3 sm:w-auto sm:text-sm ${
130
+ action.danger
131
+ ? 'bg-red-600 hover:bg-red-700 focus:ring-red-500'
132
+ : 'bg-blue-600 hover:bg-blue-700 focus:ring-blue-500'
133
+ }`}
134
+ onClick={() => onConfirm(device, action.name)}
135
+ >
136
+ Confirm {getActionTitle(action.name)}
137
+ </button>
138
+ <button