Spaces:
Sleeping
Sleeping
File size: 8,251 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 | <script lang="ts">
import { previousRfps, nextStep, clearUploadedRfps } from '../stores/appStore'
import { onMount } from 'svelte'
let dragActive = false
let uploadedFiles: File[] = []
let hasStoredData = false
onMount(() => {
// Check if we have stored data on component mount
hasStoredData = $previousRfps.length > 0
})
async function handleFileUpload(event: Event) {
const target = event.target as HTMLInputElement
if (target.files) {
uploadedFiles = Array.from(target.files)
previousRfps.update(current => [
...current,
...uploadedFiles.map(file => ({
id: `rfp-${Date.now()}-${Math.random()}`,
name: file.name,
content: '',
size: file.size,
uploadDate: new Date().toISOString(),
pageCount: 1,
quality: 'Good',
keyTopics: [],
wordCount: 1000
}))
])
}
}
async function loadSampleRfps() {
const sampleRfps = [
{
id: 'sample-1',
name: 'IT Services Project Response.md',
content: '',
size: 4500,
uploadDate: new Date().toISOString(),
pageCount: 3,
quality: 'Excellent',
keyTopics: ['Technical Approach', 'Security', 'Timeline', 'Team'],
wordCount: 850
},
{
id: 'sample-2',
name: 'Cloud Migration Project Response.md',
content: '',
size: 5200,
uploadDate: new Date().toISOString(),
pageCount: 4,
quality: 'Excellent',
keyTopics: ['Cloud Strategy', 'Migration', 'Security', 'Compliance'],
wordCount: 950
}
]
previousRfps.update(current => [...current, ...sampleRfps])
}
function proceedToNextStep() {
if ($previousRfps.length > 0) {
nextStep()
}
}
function removeDocument(id: string) {
previousRfps.update(current => current.filter(doc => doc.id !== id))
}
function clearAllDocuments() {
if (confirm('Are you sure you want to clear all uploaded documents? This will also remove them from storage.')) {
clearUploadedRfps()
hasStoredData = false
}
}
</script>
<div class="space-y-6">
<div class="bg-blue-500/10 border border-blue-500/20 rounded-lg p-6">
<h3 class="text-lg font-semibold text-blue-300 mb-2">Upload Previous RFPs</h3>
<p class="text-blue-300/80">Upload your previous RFP documents for reference and maximum accuracy.</p>
</div>
<div class="bg-gray-800 rounded-lg border-2 border-dashed border-gray-600 hover:border-blue-500/50 transition-colors">
<div class="relative p-8 text-center">
<input
type="file"
multiple
accept=".pdf,.docx,.doc,.txt"
on:change={handleFileUpload}
class="absolute inset-0 opacity-0 cursor-pointer"
/>
<div class="flex flex-col items-center space-y-3">
<div class="w-16 h-16 bg-gradient-to-r from-blue-500 to-blue-600 rounded-lg flex items-center justify-center text-white">
<svg class="w-8 h-8" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z" clip-rule="evenodd"></path>
</svg>
</div>
<div>
<h3 class="text-lg font-semibold text-gray-200 mb-2">Upload Previous RFPs</h3>
<p class="text-gray-300 mb-2">Click to browse or drag and drop files</p>
<p class="text-sm text-gray-400">Supports PDF, DOCX, DOC, and TXT files</p>
</div>
</div>
</div>
</div>
{#if $previousRfps.length > 0}
<div class="bg-gray-800 rounded-lg border border-gray-600">
<div class="bg-gray-700 p-4">
<div class="flex items-center justify-between">
<div>
<div class="flex items-center space-x-3">
<h3 class="text-lg font-semibold text-white">Uploaded Documents</h3>
{#if hasStoredData}
<span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium text-blue-300 bg-blue-600/20">
Restored from storage
</span>
{/if}
</div>
<p class="text-gray-300 text-sm">{$previousRfps.length} documents ready for AI processing</p>
</div>
<div class="flex items-center space-x-3">
<button
on:click={clearAllDocuments}
class="bg-gray-600 hover:bg-gray-700 text-gray-300 px-4 py-2 rounded-lg font-medium transition-colors text-sm"
title="Clear all documents and storage"
>
Clear All
</button>
<button
on:click={proceedToNextStep}
class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg font-medium transition-colors"
>
Continue to Questions →
</button>
</div>
</div>
</div>
<div class="p-4 space-y-3">
{#each $previousRfps as doc, index}
<div class="border border-gray-600 bg-gray-700/30 rounded-lg p-3">
<div class="flex items-start justify-between">
<div class="flex-1">
<div class="flex items-center space-x-3 mb-2">
<div class="w-6 h-6 bg-blue-500/20 rounded flex items-center justify-center text-blue-300 text-sm font-medium">
{index + 1}
</div>
<h4 class="font-medium text-gray-200">{doc.name}</h4>
<span class="inline-flex items-center px-2 py-1 rounded text-xs font-medium text-green-300 bg-green-600/20">
{doc.quality}
</span>
</div>
<div class="grid grid-cols-3 gap-4 text-sm">
<div>
<span class="text-gray-400">Size:</span>
<span class="font-semibold text-gray-200">{(doc.size / 1024 / 1024).toFixed(1)} MB</span>
</div>
<div>
<span class="text-gray-400">Pages:</span>
<span class="font-semibold text-gray-200">{doc.pageCount}</span>
</div>
<div>
<span class="text-gray-400">Words:</span>
<span class="font-semibold text-gray-200">{doc.wordCount?.toLocaleString()}</span>
</div>
</div>
</div>
<button
on:click={() => removeDocument(doc.id)}
class="ml-4 w-8 h-8 bg-red-500/20 hover:bg-red-500/30 rounded-lg flex items-center justify-center text-red-400 transition-colors"
title="Remove document"
>
×
</button>
</div>
</div>
{/each}
</div>
</div>
{/if}
<div class="bg-gray-700/50 rounded-lg p-4 border border-gray-600">
<h3 class="text-base font-medium text-gray-200 mb-3">Tips for Best Results</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-sm text-gray-300">
<div>
<h4 class="font-medium mb-2 text-gray-200">Best Documents Include:</h4>
<ul class="space-y-1">
<li>• Complete question-answer pairs</li>
<li>• Technical specifications</li>
<li>• Company methodologies</li>
<li>• Previous winning proposals</li>
</ul>
</div>
<div>
<h4 class="font-medium mb-2 text-gray-200">For Optimal Results:</h4>
<ul class="space-y-1">
<li>• Upload 3-5 comprehensive RFPs</li>
<li>• Include recent proposals (last 2 years)</li>
<li>• Ensure documents are well-formatted</li>
<li>• Mix different industry sectors</li>
</ul>
</div>
</div>
</div>
</div>
|