File size: 8,218 Bytes
bfe0820 | 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 | import React, { useState } from "react";
import { ShieldAlert, Upload, MessageSquare } from "lucide-react";
import { Card } from "../ui/Card";
import { Button } from "../ui/Button";
import { Textarea, Dropdown } from "../ui/Input";
import { toast } from "sonner";
export function ScamInputForm({ onAnalyze, loading }) {
const [message, setMessage] = useState("");
const [source, setSource] = useState("whatsapp");
const [stockSymbol, setStockSymbol] = useState("");
const [error, setError] = useState("");
const sampleMessages = {
whatsapp: "๐จ URGENT BUY CALL! RELIANCE 100% Guaranteed 5000 Target by Friday!! Heavy Operator Buying. Join VIP Group for 10x Returns ๐๐",
telegram: "โก INSIDER STOCK ALERT โก TATAMOTORS Upper Circuit Expected Tomorrow! Buy Immediately before news breaks. NO LOSS GUARANTEE! ๐",
sms: "FREE TIP: Buy INFY at market price. Target 2200. Multibagger stock recommendation from SEBI reg advisor. Call 9876543210 immediately.",
email: "Exclusive Private Placement Opportunity: 300% Return in 30 Days guaranteed. Click http://suspicious-trade-fund.biz to invest now.",
};
const handlePastePreset = (key) => {
setMessage(sampleMessages[key]);
setSource(key);
setError("");
toast.success(`Loaded sample ${key.toUpperCase()} message.`);
};
const handleTextChange = (e) => {
setMessage(e.target.value);
if (e.target.value.trim().length >= 5) {
setError("");
}
};
const handleSubmit = (e) => {
e.preventDefault();
if (!message || message.trim().length < 5) {
setError("Please enter at least 5 characters to analyze.");
toast.error("Message must be at least 5 characters long.");
return;
}
onAnalyze({
message: message.trim(),
source,
stock_symbol: stockSymbol.trim() || undefined,
});
};
const handleScreenshotDrop = (e) => {
const file = e.target.files?.[0];
if (file) {
toast.success(`OCR Scan complete for screenshot "${file.name}". Extracting text...`);
setTimeout(() => {
setMessage("๐ฅ URGENT STOCK TIP: BUY RELIANCE TODAY TARGET 3200 GUARANTEED RETURN BY OPERATOR GROUP!!");
toast.success("Text extracted from image successfully!");
}, 500);
}
};
return (
<Card style={{ marginBottom: "24px", padding: "24px" }}>
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
flexWrap: "wrap",
gap: "12px",
marginBottom: "16px",
}}
>
<div>
<h3 style={{ fontSize: "16px", fontWeight: 700, color: "var(--text-primary)", margin: 0 }}>
SCAM & FRAUD INVESTIGATION INPUT
</h3>
<p style={{ fontSize: "12.5px", color: "var(--text-muted)", margin: "3px 0 0 0" }}>
Paste any suspicious stock tip, WhatsApp message, Telegram signal, SMS, or Email.
</p>
</div>
{/* Preset Sample Buttons */}
<div style={{ display: "flex", alignItems: "center", gap: "6px", flexWrap: "wrap" }}>
<span style={{ fontSize: "11px", color: "var(--text-muted)", fontWeight: 600, textTransform: "uppercase" }}>
PASTE SAMPLES:
</span>
<button type="button" className="sd-preset-pill" onClick={() => handlePastePreset("whatsapp")}>
<MessageSquare size={12} color="var(--success)" /> WhatsApp
</button>
<button type="button" className="sd-preset-pill" onClick={() => handlePastePreset("telegram")}>
<MessageSquare size={12} color="var(--accent-blue)" /> Telegram
</button>
<button type="button" className="sd-preset-pill" onClick={() => handlePastePreset("sms")}>
<MessageSquare size={12} color="var(--color-gold)" /> SMS
</button>
<button type="button" className="sd-preset-pill" onClick={() => handlePastePreset("email")}>
<MessageSquare size={12} color="var(--danger)" /> Email
</button>
</div>
</div>
<form onSubmit={handleSubmit}>
{/* Textarea Input */}
<div style={{ position: "relative", marginBottom: "16px" }}>
<Textarea
rows={5}
value={message}
onChange={handleTextChange}
placeholder="Paste suspicious investment message here... e.g. 'BUY RELIANCE TODAY 100% GUARANTEED 10X RETURN BY VIP GROUP'"
error={error}
/>
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
marginTop: "6px",
fontSize: "11px",
color: "var(--text-muted)",
fontFamily: "var(--font-mono)",
}}
>
<span>Min 5 characters required</span>
<span>{message.length} characters</span>
</div>
</div>
{/* Source & Stock Symbol Controls */}
<div
style={{
display: "grid",
gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))",
gap: "12px",
marginBottom: "20px",
}}
>
{/* Source Dropdown */}
<Dropdown
label="MESSAGE ORIGIN SOURCE"
value={source}
onChange={(e) => setSource(e.target.value)}
options={[
{ value: "whatsapp", label: "WhatsApp Chat / Group" },
{ value: "telegram", label: "Telegram Channel" },
{ value: "sms", label: "SMS Alert" },
{ value: "email", label: "Email Recommendation" },
{ value: "twitter", label: "Twitter / Social Media" },
{ value: "other", label: "Other Source" },
]}
/>
{/* Optional Stock Symbol */}
<div>
<label style={{ display: "block", fontSize: "12px", fontWeight: 600, color: "var(--text-secondary)", marginBottom: "6px" }}>
OPTIONAL STOCK SYMBOL
</label>
<input
type="text"
value={stockSymbol}
onChange={(e) => setStockSymbol(e.target.value)}
placeholder="e.g. RELIANCE, TCS"
style={{
width: "100%",
background: "var(--bg-surface)",
border: "1px solid var(--border)",
borderRadius: "var(--radius-input)",
padding: "10px 14px",
color: "var(--text-primary)",
fontSize: "14px",
outline: "none",
}}
/>
</div>
</div>
{/* Submit CTA */}
<div style={{ display: "flex", justifyContent: "flex-end" }}>
<Button
type="submit"
variant="danger"
size="lg"
loading={loading}
icon={ShieldAlert}
style={{ paddingLeft: "32px", paddingRight: "32px" }}
>
Investigate Message
</Button>
</div>
</form>
{/* Drag & Drop Screenshot UI Only Upload */}
<div style={{ marginTop: "20px", paddingTop: "16px", borderTop: "1px solid var(--border-subtle)" }}>
<div className="pd-dropzone" style={{ padding: "18px 16px" }}>
<input
type="file"
accept="image/*"
onChange={handleScreenshotDrop}
id="screenshot-upload-input"
style={{ display: "none" }}
/>
<label htmlFor="screenshot-upload-input" style={{ cursor: "pointer", display: "block" }}>
<Upload size={22} color="var(--danger)" style={{ marginBottom: "6px" }} />
<div style={{ fontSize: "12.5px", fontWeight: 700, color: "var(--text-primary)" }}>
Drag & Drop Screenshot for AI OCR Analysis (UI Only)
</div>
<div style={{ fontSize: "11px", color: "var(--text-muted)", marginTop: "2px" }}>
Upload WhatsApp or Telegram chat screenshot to extract text automatically
</div>
</label>
</div>
</div>
</Card>
);
}
export default ScamInputForm;
|