Spaces:
Sleeping
Sleeping
File size: 11,914 Bytes
d8635c9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | <script lang="ts">
import { questions, nextStep } from '../stores/appStore'
let searchTerm = ''
let selectedPriority = 'all'
let sortBy = 'order'
$: filteredQuestions = $questions.filter(q => {
const matchesSearch = q.text.toLowerCase().includes(searchTerm.toLowerCase())
const matchesPriority = selectedPriority === 'all' || q.priority === selectedPriority
return matchesSearch && matchesPriority
}).sort((a, b) => {
if (sortBy === 'priority') {
const priorityOrder = { high: 0, medium: 1, low: 2 }
return priorityOrder[a.priority] - priorityOrder[b.priority]
}
return 0 // Keep original order
})
$: selectedCount = $questions.filter(q => q.selected).length
function toggleQuestion(id: string) {
questions.update(current =>
current.map(q =>
q.id === id ? { ...q, selected: !q.selected } : q
)
)
}
function updatePriority(id: string, priority: 'high' | 'medium' | 'low') {
questions.update(current =>
current.map(q =>
q.id === id ? { ...q, priority } : q
)
)
}
function selectAll() {
questions.update(current =>
current.map(q => ({ ...q, selected: true }))
)
}
function deselectAll() {
questions.update(current =>
current.map(q => ({ ...q, selected: false }))
)
}
function proceedToNextStep() {
if (selectedCount > 0) {
nextStep()
}
}
function getPriorityColor(priority: string) {
switch (priority) {
case 'high': return 'from-red-500 to-orange-500'
case 'medium': return 'from-yellow-500 to-orange-500'
case 'low': return 'from-green-500 to-blue-500'
default: return 'from-gray-500 to-gray-600'
}
}
function getPriorityBadgeColor(priority: string) {
switch (priority) {
case 'high': return 'bg-red-100 text-red-800 border-red-200'
case 'medium': return 'bg-yellow-100 text-yellow-800 border-yellow-200'
case 'low': return 'bg-green-100 text-green-800 border-green-200'
default: return 'bg-gray-100 text-gray-800 border-gray-200'
}
}
</script>
<div class="space-y-8">
<!-- Control Panel -->
<div class="bg-gradient-to-r from-white/80 to-purple-50/80 backdrop-blur-sm rounded-3xl p-8 border border-purple-200/50 shadow-xl">
<div class="flex items-center justify-between mb-6">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 bg-gradient-to-r from-purple-500 to-pink-600 rounded-xl flex items-center justify-center text-white text-xl">
π
</div>
<div>
<h3 class="text-xl font-bold text-slate-800">Question Selection</h3>
<p class="text-slate-600">Choose questions to process with AI</p>
</div>
</div>
<div class="text-right">
<div class="text-2xl font-bold text-purple-600">{selectedCount}</div>
<div class="text-sm text-slate-600">Selected</div>
</div>
</div>
<!-- Search and Filters -->
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
<!-- Search -->
<div class="col-span-2">
<label class="block text-sm font-medium text-slate-700 mb-2">Search Questions</label>
<div class="relative">
<input
type="text"
bind:value={searchTerm}
placeholder="Search by keyword..."
class="w-full pl-10 pr-4 py-3 border border-slate-300 rounded-xl focus:ring-2 focus:ring-purple-500 focus:border-purple-500 bg-white/70 backdrop-blur-sm"
/>
<div class="absolute left-3 top-1/2 transform -translate-y-1/2 text-slate-400">
π
</div>
</div>
</div>
<!-- Priority Filter -->
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">Filter by Priority</label>
<select
bind:value={selectedPriority}
class="w-full py-3 px-4 border border-slate-300 rounded-xl focus:ring-2 focus:ring-purple-500 focus:border-purple-500 bg-white/70 backdrop-blur-sm"
>
<option value="all">All Priorities</option>
<option value="high">High Priority</option>
<option value="medium">Medium Priority</option>
<option value="low">Low Priority</option>
</select>
</div>
<!-- Sort -->
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">Sort By</label>
<select
bind:value={sortBy}
class="w-full py-3 px-4 border border-slate-300 rounded-xl focus:ring-2 focus:ring-purple-500 focus:border-purple-500 bg-white/70 backdrop-blur-sm"
>
<option value="order">Original Order</option>
<option value="priority">Priority Level</option>
</select>
</div>
</div>
<!-- Bulk Actions -->
<div class="flex space-x-4">
<button
on:click={selectAll}
class="flex-1 bg-gradient-to-r from-green-500 to-emerald-600 text-white py-3 px-6 rounded-xl font-semibold hover:from-green-600 hover:to-emerald-700 transition-all duration-300 shadow-lg hover:shadow-xl"
>
Select All
</button>
<button
on:click={deselectAll}
class="flex-1 bg-gradient-to-r from-gray-500 to-gray-600 text-white py-3 px-6 rounded-xl font-semibold hover:from-gray-600 hover:to-gray-700 transition-all duration-300 shadow-lg hover:shadow-xl"
>
Deselect All
</button>
</div>
</div>
<!-- Questions List -->
<div class="space-y-4">
{#each filteredQuestions as question, index}
<div class="bg-white/70 backdrop-blur-sm rounded-2xl border border-slate-200/50 shadow-lg hover:shadow-xl transition-all duration-300 overflow-hidden {
question.selected ? 'ring-2 ring-purple-400 ring-opacity-50' : ''
}">
<div class="p-6">
<div class="flex items-start space-x-4">
<!-- Selection Checkbox -->
<div class="flex-shrink-0 pt-1">
<button
on:click={() => toggleQuestion(question.id)}
class="w-6 h-6 rounded-md border-2 flex items-center justify-center transition-all duration-200 {
question.selected
? 'bg-purple-500 border-purple-500 text-white'
: 'border-slate-300 hover:border-purple-400'
}"
>
{#if question.selected}
β
{/if}
</button>
</div>
<!-- Question Content -->
<div class="flex-1 min-w-0">
<div class="flex items-center justify-between mb-3">
<div class="flex items-center space-x-3">
<span class="inline-flex items-center justify-center w-8 h-8 bg-purple-100 text-purple-600 rounded-lg text-sm font-bold">
{index + 1}
</span>
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium border {getPriorityBadgeColor(question.priority)}">
{question.priority.toUpperCase()} PRIORITY
</span>
</div>
<!-- Priority Selector -->
<select
value={question.priority}
on:change={(e) => updatePriority(question.id, e.target.value)}
class="text-sm border border-slate-300 rounded-lg px-3 py-1 bg-white/80 focus:ring-2 focus:ring-purple-500 focus:border-purple-500"
>
<option value="high">High</option>
<option value="medium">Medium</option>
<option value="low">Low</option>
</select>
</div>
<p class="text-slate-700 leading-relaxed text-lg">{question.text}</p>
<!-- Question Stats -->
<div class="mt-4 flex items-center space-x-6 text-sm text-slate-500">
<div class="flex items-center space-x-1">
<span>π</span>
<span>Estimated AI Processing: 30-45 seconds</span>
</div>
<div class="flex items-center space-x-1">
<span>π―</span>
<span>Will generate 2-3 citations</span>
</div>
</div>
</div>
</div>
</div>
<!-- Selected Indicator -->
{#if question.selected}
<div class="bg-gradient-to-r {getPriorityColor(question.priority)} px-6 py-3">
<div class="flex items-center justify-between text-white">
<div class="flex items-center space-x-2">
<span>β¨</span>
<span class="font-semibold">Selected for AI Processing</span>
</div>
<div class="text-sm opacity-80">
{question.priority} priority
</div>
</div>
</div>
{/if}
</div>
{/each}
</div>
<!-- Continue Button -->
{#if selectedCount > 0}
<div class="bg-gradient-to-r from-white/80 to-green-50/80 backdrop-blur-sm rounded-3xl p-8 border border-green-200/50 shadow-xl">
<div class="flex items-center justify-between">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 bg-gradient-to-r from-green-500 to-emerald-600 rounded-xl flex items-center justify-center text-white text-xl">
β
</div>
<div>
<h3 class="text-xl font-bold text-slate-800">Ready to Process</h3>
<p class="text-slate-600">{selectedCount} questions selected for AI generation</p>
</div>
</div>
<button
on:click={proceedToNextStep}
class="bg-gradient-to-r from-green-500 to-emerald-600 text-white px-8 py-4 rounded-2xl font-bold text-lg hover:from-green-600 hover:to-emerald-700 transition-all duration-300 shadow-lg hover:shadow-xl"
>
<div class="flex items-center space-x-2">
<span>π</span>
<span>Start AI Processing</span>
</div>
</button>
</div>
<!-- Processing Preview -->
<div class="mt-6 grid grid-cols-1 md:grid-cols-3 gap-4">
<div class="bg-white/60 rounded-xl p-4 text-center">
<div class="text-2xl font-bold text-green-600">{selectedCount}</div>
<div class="text-sm text-slate-600">Questions to Process</div>
</div>
<div class="bg-white/60 rounded-xl p-4 text-center">
<div class="text-2xl font-bold text-blue-600">{Math.ceil(selectedCount * 0.75)}</div>
<div class="text-sm text-slate-600">Estimated Minutes</div>
</div>
<div class="bg-white/60 rounded-xl p-4 text-center">
<div class="text-2xl font-bold text-purple-600">{selectedCount * 3}</div>
<div class="text-sm text-slate-600">Expected Citations</div>
</div>
</div>
</div>
{:else}
<div class="bg-gradient-to-r from-white/80 to-orange-50/80 backdrop-blur-sm rounded-3xl p-8 border border-orange-200/50 shadow-xl text-center">
<div class="w-16 h-16 bg-gradient-to-r from-orange-500 to-red-500 rounded-2xl flex items-center justify-center text-white text-3xl mx-auto mb-4">
β οΈ
</div>
<h3 class="text-xl font-bold text-slate-800 mb-2">No Questions Selected</h3>
<p class="text-slate-600">Please select at least one question to proceed with AI processing.</p>
</div>
{/if}
</div>
|