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:
@@ -17,6 +17,9 @@ import { useAuthContext } from "../context/AuthContext";
|
||||
// Ограничения полей бэкенда (PostFieldLimits): длиннее — 400
|
||||
const TITLE_MAX_LENGTH = 255;
|
||||
const REWARD_TEXT_MAX_LENGTH = 255;
|
||||
// Контрольные вопросы находки (PostFieldLimits): не больше 3, до 200 символов
|
||||
const MAX_VERIFY_QUESTIONS = 3;
|
||||
const VERIFY_QUESTION_MAX_LENGTH = 200;
|
||||
// Поля первого шага формы: ошибку в них нужно показывать на шаге 1
|
||||
const STEP_ONE_FIELDS = ["title", "description"];
|
||||
/**
|
||||
@@ -51,7 +54,9 @@ export default function CreateUpdatePost({ onClose, onSuccess, initialData, admi
|
||||
rulesAccepted: true,
|
||||
reward: initialData.reward ?? false,
|
||||
rewardText: initialData.rewardText
|
||||
|| (initialData.reward ? t('post.rewardDefault') : "")
|
||||
|| (initialData.reward ? t('post.rewardDefault') : ""),
|
||||
verificationQuestions: initialData.verificationQuestions?.length
|
||||
? [...initialData.verificationQuestions] : [""],
|
||||
}
|
||||
: { ...EMPTY_FORM, phone: profilePhone }
|
||||
));
|
||||
@@ -137,6 +142,12 @@ export default function CreateUpdatePost({ onClose, onSuccess, initialData, admi
|
||||
const reward = form.reward && form.type !== "found";
|
||||
data.append("reward", reward ? "true" : "false");
|
||||
if (reward) data.append("rewardText", (form.rewardText || "").trim());
|
||||
// Шлём всегда, даже пустой массив: так удаление вопросов при правке сохранится.
|
||||
// Админ их не правит: его эндпоинт поле не принимает
|
||||
if (!adminMode) {
|
||||
const questions = (form.verificationQuestions || []).map(q => q.trim()).filter(Boolean);
|
||||
data.append("verificationQuestions", JSON.stringify(questions));
|
||||
}
|
||||
if (form.date) data.append("date", form.date);
|
||||
|
||||
const files = getFilesForUpload();
|
||||
@@ -394,6 +405,52 @@ export default function CreateUpdatePost({ onClose, onSuccess, initialData, admi
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Как не попасться мошенникам: главная схема — «нашёл, оплатите доставку» */}
|
||||
{!adminMode && (
|
||||
<div className="f-m-group f-safety-note" role="note">
|
||||
<div className="f-safety-title">🛡️ {t('post.safetyTitle')}</div>
|
||||
<p className="f-safety-text">{t('post.safetyText')}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Контрольные вопросы: у потери отсекают «нашёл, оплатите доставку» от тех,
|
||||
кто вещь в руках не держал, у находки — «это моё» по одному фото */}
|
||||
{!adminMode && (
|
||||
<div className="f-m-group">
|
||||
<label className="f-m-label">{t('post.verifyQuestionsLabel')}</label>
|
||||
<p className="f-hint">
|
||||
{form.type === "found" ? t('post.verifyQuestionsHint') : t('post.verifyQuestionsHintLoss')}
|
||||
</p>
|
||||
{(form.verificationQuestions || [""]).map((question, i) => (
|
||||
<div key={i} className="f-verify-question">
|
||||
<ClearableField
|
||||
onClear={() => set("verificationQuestions", form.verificationQuestions.length > 1
|
||||
? form.verificationQuestions.filter((_, j) => j !== i)
|
||||
: [""])}
|
||||
visible={!!question || form.verificationQuestions.length > 1}
|
||||
>
|
||||
<input
|
||||
className="f-m-field"
|
||||
type="text"
|
||||
placeholder={form.type === "found"
|
||||
? t('post.verifyQuestionPlaceholder') : t('post.verifyQuestionPlaceholderLoss')}
|
||||
maxLength={VERIFY_QUESTION_MAX_LENGTH}
|
||||
value={question}
|
||||
onChange={e => set("verificationQuestions",
|
||||
form.verificationQuestions.map((q, j) => (j === i ? e.target.value : q)))}
|
||||
/>
|
||||
</ClearableField>
|
||||
</div>
|
||||
))}
|
||||
{(form.verificationQuestions || []).length < MAX_VERIFY_QUESTIONS && (
|
||||
<button type="button" className="f-verify-add"
|
||||
onClick={() => set("verificationQuestions", [...(form.verificationQuestions || []), ""])}>
|
||||
{t('post.verifyQuestionAdd')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Вознаграждение — только для потери */}
|
||||
{form.type !== "found" && (
|
||||
<div className="f-m-group">
|
||||
|
||||
Reference in New Issue
Block a user