Add verification questions, claim flow and scam warnings
- post form: up to 3 verification questions (loss and found) and a "how not to get scammed" note; sent as verificationQuestions JSON - feed card: "I found it" / "It's mine" instead of "Write" for posts with questions; phone shows "after check" until the author approves - chat draft shows ClaimForm; VerificationPanel lets the author approve or reject answers and locks the claimant's input until approval, then offers the author's phone - messages: claim answers card, verification system line, fraudSignal warnings for the recipient; ChatSafetyNotice with new-account mark - tests, README Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
61
src/components/chat/ChatSafetyNotice.jsx
Normal file
61
src/components/chat/ChatSafetyNotice.jsx
Normal file
@@ -0,0 +1,61 @@
|
||||
import { useState } from "react";
|
||||
|
||||
const STORAGE_KEY = "nakhodka:safetyNoticeHidden";
|
||||
// Аккаунт моложе недели — частый признак мошенника, который заводит новые под каждую схему
|
||||
const NEW_ACCOUNT_DAYS = 7;
|
||||
|
||||
function readHidden() {
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem(STORAGE_KEY) || "[]");
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/** Собеседник зарегистрировался меньше недели назад. */
|
||||
export function isNewAccount(createdAt, now = Date.now()) {
|
||||
if (!createdAt) return false;
|
||||
const created = new Date(createdAt).getTime();
|
||||
return Number.isFinite(created) && now - created < NEW_ACCOUNT_DAYS * 24 * 60 * 60 * 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Плашка над перепиской: не переводить предоплату, не называть коды. Скрыть
|
||||
* можно в каждом чате отдельно; отметку о новом аккаунте собеседника скрыть
|
||||
* нельзя — она про конкретного человека.
|
||||
*/
|
||||
export default function ChatSafetyNotice({ chatId, otherUserCreatedAt, t }) {
|
||||
const [hidden, setHidden] = useState(() => chatId != null && readHidden().includes(String(chatId)));
|
||||
const newAccount = isNewAccount(otherUserCreatedAt);
|
||||
|
||||
const hide = () => {
|
||||
setHidden(true);
|
||||
if (chatId == null) return;
|
||||
try {
|
||||
const ids = [...new Set([...readHidden(), String(chatId)])].slice(-200);
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(ids));
|
||||
} catch {
|
||||
// приватный режим — плашка просто снова появится
|
||||
}
|
||||
};
|
||||
|
||||
if (hidden && !newAccount) return null;
|
||||
|
||||
return (
|
||||
<div className="chat-safety" role="note">
|
||||
{!hidden && (
|
||||
<div className="chat-safety-main">
|
||||
<span className="chat-safety-icon" aria-hidden="true">🛡️</span>
|
||||
<div className="chat-safety-body">
|
||||
<div className="chat-safety-title">{t("chat.safetyTitle")}</div>
|
||||
<div className="chat-safety-text">{t("chat.safetyText")}</div>
|
||||
</div>
|
||||
<button type="button" className="chat-safety-hide" onClick={hide}>
|
||||
{t("chat.safetyHide")}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{newAccount && <div className="chat-safety-new">⚠️ {t("chat.newAccount")}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user