- 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>
596 lines
26 KiB
JavaScript
596 lines
26 KiB
JavaScript
import { useCallback, useState } from "react";
|
||
import CloseIcon from "../components/icons/CloseIcon";
|
||
import RulesModal from "./RulesModal";
|
||
import { EMPTY_FORM, CATEGORIES } from "../config/feedConstants";
|
||
import { useTranslation } from 'react-i18next';
|
||
import { usePostMutation } from "../hooks/usePostMutation";
|
||
import { useImageUpload, ACCEPT, MAX_SOURCE_SIZE_MB } from "../hooks/useImageUpload";
|
||
import { validatePostForm } from "../utils/validatePostForm";
|
||
import { formatPhone } from "../utils/formatPhone";
|
||
import MapModal from "./MapModal";
|
||
import ClearableField from "../components/ClearableField";
|
||
import AddressAutocomplete from "../components/AddressAutocomplete";
|
||
import { useIsDesktop } from "../hooks/useIsDesktop";
|
||
import { useFileDropZone } from "../hooks/useFileDropZone";
|
||
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"];
|
||
/**
|
||
* CreateUpdatePost — модальная форма создания и редактирования объявления.
|
||
*
|
||
* @param {function} onClose — закрыть модалку без сохранения
|
||
* @param {function} onSuccess — колбэк после успешного сохранения (перезагружает ленту)
|
||
* @param {object} [initialData] — если передан, форма работает в режиме редактирования
|
||
* @param {boolean} [adminMode] — правка чужого объявления из админ-панели:
|
||
* сохранение уходит в PUT /api/v1/admin/posts/{id}
|
||
*/
|
||
export default function CreateUpdatePost({ onClose, onSuccess, initialData, adminMode = false }) {
|
||
const isEdit = !!initialData;
|
||
const { t } = useTranslation();
|
||
const isDesktop = useIsDesktop();
|
||
const { user } = useAuthContext();
|
||
// Телефон из профиля подставляем, чтобы не вводить его в каждом объявлении.
|
||
// В админ-режиме правится чужое объявление — телефон админа туда не нужен.
|
||
const profilePhone = !adminMode && user?.phone ? formatPhone(user.phone) : "";
|
||
|
||
const [form, setForm] = useState(() => (
|
||
isEdit
|
||
? {
|
||
type: (initialData.type || "loss").toLowerCase(),
|
||
title: initialData.title || "",
|
||
description: initialData.description || "",
|
||
category: initialData.category || "",
|
||
date: initialData.date || "",
|
||
phone: initialData.phone || profilePhone,
|
||
phoneVisible: !!initialData.phoneVisible,
|
||
address: initialData.address || initialData.city || "",
|
||
rulesAccepted: true,
|
||
reward: initialData.reward ?? false,
|
||
rewardText: initialData.rewardText
|
||
|| (initialData.reward ? t('post.rewardDefault') : ""),
|
||
verificationQuestions: initialData.verificationQuestions?.length
|
||
? [...initialData.verificationQuestions] : [""],
|
||
}
|
||
: { ...EMPTY_FORM, phone: profilePhone }
|
||
));
|
||
|
||
const [rulesModalOpen, setRulesModalOpen] = useState(false);
|
||
const [mapModalOpen, setMapModalOpen] = useState(false);
|
||
const [errors, setErrors] = useState({});
|
||
const [step, setStep] = useState(1); // 1 — первая часть, 2 — вторая часть
|
||
|
||
const {
|
||
images: uploadedImages,
|
||
imgError,
|
||
compressing,
|
||
fileInputRef,
|
||
handleFileChange,
|
||
addFiles,
|
||
removeImage,
|
||
getFilesForUpload,
|
||
getExistingUrlsToKeep,
|
||
} = useImageUpload(isEdit ? initialData.images : []);
|
||
|
||
// Перетаскивание фото (drag & drop) — только на десктопе
|
||
const { dragOver, zoneProps: dropZoneHandlers, strayDropProps: blockStrayDrop } = useFileDropZone({
|
||
enabled: isDesktop,
|
||
busy: compressing,
|
||
onFiles: addFiles,
|
||
});
|
||
|
||
const { save, loading: saving, error: apiError } = usePostMutation({ adminMode });
|
||
|
||
const [resultModal, setResultModal] = useState(null); // null | "success" | "blocked"
|
||
|
||
const initialCoords = isEdit && initialData.latitude && initialData.longitude
|
||
? { latitude: initialData.latitude, longitude: initialData.longitude }
|
||
: null;
|
||
|
||
// Точка на карте. Адрес лежит в form.address; точку задаёт выбор подсказки
|
||
// в поле «Адрес» или выбор места в окне карты.
|
||
const [coords, setCoords] = useState(initialCoords);
|
||
|
||
const loading = saving || compressing;
|
||
|
||
/** Обновляет одно поле формы и сбрасывает его ошибку валидации. */
|
||
const set = useCallback((key, value) => {
|
||
setForm(prev => ({ ...prev, [key]: value }));
|
||
setErrors(prev => ({ ...prev, [key]: "" }));
|
||
}, []);
|
||
|
||
/** Переход ко второму шагу — только если поля первого шага заполнены. */
|
||
const handleNextStep = () => {
|
||
const validationErrors = validatePostForm(form);
|
||
const stepOneErrors = Object.fromEntries(
|
||
Object.entries(validationErrors).filter(([key]) => STEP_ONE_FIELDS.includes(key))
|
||
);
|
||
if (Object.keys(stepOneErrors).length) {
|
||
setErrors(prev => ({ ...prev, ...stepOneErrors }));
|
||
return;
|
||
}
|
||
setStep(2);
|
||
};
|
||
|
||
/** Собирает FormData и отправляет запрос на создание или обновление. */
|
||
const handleSubmit = async () => {
|
||
const validationErrors = validatePostForm(form);
|
||
if (Object.keys(validationErrors).length) {
|
||
setErrors(validationErrors);
|
||
// Иначе ошибка поля первого шага не видна, а кнопка «ничего не делает»
|
||
if (STEP_ONE_FIELDS.some(key => validationErrors[key])) setStep(1);
|
||
return;
|
||
}
|
||
|
||
const data = new FormData();
|
||
data.append("type", form.type.toUpperCase());
|
||
data.append("title", form.title.trim());
|
||
data.append("description", form.description.trim());
|
||
data.append("category", form.category);
|
||
// Без согласия номер не отправляем: бэкенд его и не сохранит.
|
||
// Админ согласие не меняет — правит только номер, если автор его показывает
|
||
const phoneVisible = adminMode ? !!initialData?.phoneVisible : form.phoneVisible;
|
||
if (!adminMode) data.append("phoneVisible", phoneVisible ? "true" : "false");
|
||
if (phoneVisible) data.append("phone", form.phone.trim());
|
||
// У находки вознаграждения нет: галочка, оставшаяся от типа «Потеря», не уходит
|
||
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();
|
||
files.forEach(f => data.append("images", f));
|
||
|
||
if (isEdit) {
|
||
// Пустой массив — явное «старые фото удалены» (бэкенд трактует так же
|
||
// и отсутствие поля, но так намерение видно в запросе)
|
||
data.append("existingImages", JSON.stringify(getExistingUrlsToKeep()));
|
||
}
|
||
|
||
if (coords) {
|
||
data.append("latitude", coords.latitude);
|
||
data.append("longitude", coords.longitude);
|
||
data.append("address", form.address.trim());
|
||
}
|
||
|
||
if (!coords && form.address.trim()) {
|
||
data.append("address", form.address.trim());
|
||
}
|
||
|
||
data.append("rulesAccepted", form.rulesAccepted ? "true" : "false");
|
||
|
||
const result = await save(isEdit ? initialData.id : null, data);
|
||
if (!result) return;
|
||
|
||
if (result.blocked) {
|
||
setResultModal("blocked");
|
||
return;
|
||
}
|
||
if (result.ok) {
|
||
setResultModal("success");
|
||
}
|
||
};
|
||
|
||
return (
|
||
<>
|
||
<div
|
||
className="f-modal-bg"
|
||
// На десктопе форма закрывается только крестиком: случайный клик мимо
|
||
// окна не должен терять заполненные поля
|
||
onClick={e => !isDesktop && e.target === e.currentTarget && !loading && onClose()}
|
||
{...blockStrayDrop}
|
||
>
|
||
<div className="f-modal">
|
||
|
||
<div className="f-modal-head">
|
||
<span className="f-modal-title">
|
||
{adminMode
|
||
? t('adminPanel.postEditTitle')
|
||
: isEdit ? t('post.editTitle') : t('post.newTitle')}
|
||
</span>
|
||
<button className="f-close-btn" type="button" onClick={onClose}>
|
||
<CloseIcon />
|
||
</button>
|
||
</div>
|
||
|
||
{step === 1 && (
|
||
<>
|
||
{/* Тип: Потеря / Находка */}
|
||
<div className="f-m-group">
|
||
<label className="f-m-label">{t('post.typeLabel')}</label>
|
||
<div className="f-type-toggle">
|
||
<button
|
||
type="button"
|
||
className={`f-type-opt${form.type === "loss" ? " loss" : ""}`}
|
||
onClick={() => set("type", "loss")}
|
||
>
|
||
{t('post.loss')}
|
||
</button>
|
||
<button
|
||
type="button"
|
||
className={`f-type-opt${form.type === "found" ? " found" : ""}`}
|
||
onClick={() => set("type", "found")}
|
||
>
|
||
{t('post.found')}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
{/* Название */}
|
||
<div className="f-m-group">
|
||
<label className="f-m-label">{t('post.titleLabel')}</label>
|
||
<ClearableField onClear={() => set("title", "")} visible={!!form.title}>
|
||
<input
|
||
className={`f-m-field${errors.title ? " err" : ""}`}
|
||
type="text"
|
||
placeholder={t('post.titlePlaceholder')}
|
||
maxLength={TITLE_MAX_LENGTH}
|
||
value={form.title}
|
||
onChange={e => set("title", e.target.value)}
|
||
/>
|
||
</ClearableField>
|
||
{errors.title && <p className="f-err-msg">{errors.title}</p>}
|
||
</div>
|
||
|
||
{/* Описание */}
|
||
<div className="f-m-group">
|
||
<label className="f-m-label">{t('post.descriptionLabel')}</label>
|
||
<ClearableField onClear={() => set("description", "")} visible={!!form.description}>
|
||
<textarea
|
||
className={`f-m-field${errors.description ? " err" : ""}`}
|
||
rows={3}
|
||
placeholder={t('post.descriptionPlaceholder')}
|
||
value={form.description}
|
||
onChange={e => set("description", e.target.value)}
|
||
/>
|
||
</ClearableField>
|
||
{errors.description && <p className="f-err-msg">{errors.description}</p>}
|
||
</div>
|
||
|
||
{/* Фотографии: на десктопе вся группа — зона для перетаскивания */}
|
||
<div
|
||
className={`f-m-group${isDesktop ? " f-img-drop-zone" : ""}${dragOver ? " is-dragover" : ""}`}
|
||
{...dropZoneHandlers}
|
||
>
|
||
<label className="f-m-label">{t('post.photosLabel')}</label>
|
||
|
||
{uploadedImages.length > 0 && (
|
||
<div className="f-img-grid">
|
||
{uploadedImages.map(img => (
|
||
<div key={img.id} className="f-img-grid-item">
|
||
<img src={img.preview} alt="" className="f-img-grid-preview" />
|
||
<button
|
||
className="f-img-remove"
|
||
onClick={() => removeImage(img.id)}
|
||
type="button"
|
||
aria-label={t('post.deletePhoto')}
|
||
>
|
||
<CloseIcon />
|
||
</button>
|
||
</div>
|
||
))}
|
||
</div>
|
||
)}
|
||
|
||
<label className="f-img-upload-label">
|
||
<input
|
||
ref={fileInputRef}
|
||
type="file"
|
||
accept={ACCEPT}
|
||
multiple
|
||
onChange={handleFileChange}
|
||
className="f-img-input"
|
||
disabled={compressing}
|
||
/>
|
||
{compressing ? (
|
||
<span>{t('post.processing')}</span>
|
||
) : dragOver ? (
|
||
<span>{t('post.dropRelease')}</span>
|
||
) : (
|
||
<span className="f-img-upload-text">
|
||
<span>{uploadedImages.length > 0 ? t('post.addMore') : t('post.addPhoto')}</span>
|
||
{isDesktop && <span className="f-img-upload-sub">{t('post.dropHint')}</span>}
|
||
</span>
|
||
)}
|
||
</label>
|
||
|
||
{imgError && <p className="f-err-msg">{imgError}</p>}
|
||
<p className="f-hint">{t('post.photoHint', { maxSize: MAX_SOURCE_SIZE_MB })}</p>
|
||
</div>
|
||
|
||
<button
|
||
className="f-m-submit"
|
||
type="button"
|
||
disabled={loading}
|
||
onClick={handleNextStep}
|
||
>
|
||
<div className="f-m-submit-row">{t('post.nextStep')}</div>
|
||
</button>
|
||
</>
|
||
)}
|
||
|
||
{step === 2 && (
|
||
<>
|
||
{/* Категория */}
|
||
<div className="f-m-group">
|
||
<label className="f-m-label">{t('post.categoryLabel')}</label>
|
||
<select
|
||
className={`f-m-field${errors.category ? " err" : ""}`}
|
||
value={form.category}
|
||
onChange={e => set("category", e.target.value)}
|
||
>
|
||
<option value="">{t('categories.select')}</option>
|
||
{CATEGORIES.map(c => (
|
||
<option key={c.value} value={c.value}>{t(c.labelKey)}</option>
|
||
))}
|
||
</select>
|
||
{errors.category && <p className="f-err-msg">{errors.category}</p>}
|
||
</div>
|
||
|
||
{/* Адрес + карта: связаны в обе стороны, как на Яндекс Картах */}
|
||
<div className="f-m-group">
|
||
<label className="f-m-label">{t('post.addressLabel')}</label>
|
||
<AddressAutocomplete
|
||
value={form.address}
|
||
onChange={text => {
|
||
// Адрес правят вручную — старая точка ему уже не соответствует
|
||
set("address", text);
|
||
setCoords(null);
|
||
}}
|
||
onSelect={({ address: picked, coords: [lat, lng] }) => {
|
||
set("address", picked);
|
||
setCoords({ latitude: lat, longitude: lng });
|
||
}}
|
||
getCenter={() => (coords ? [coords.latitude, coords.longitude] : null)}
|
||
placeholder={t('post.addressPlaceholder')}
|
||
invalid={!!errors.address}
|
||
/>
|
||
{errors.address && <p className="f-err-msg">{errors.address}</p>}
|
||
|
||
<button
|
||
className="f-map-pick f-map-open"
|
||
type="button"
|
||
onClick={() => setMapModalOpen(true)}
|
||
>
|
||
📍 {t('post.openMap')}
|
||
</button>
|
||
{!coords && <p className="f-hint">{t('post.mapHint')}</p>}
|
||
{errors.map && <p className="f-err-msg">{errors.map}</p>}
|
||
</div>
|
||
|
||
{/* Телефон: по умолчанию связь только через чат. Номер — персональные
|
||
данные (152-ФЗ), показываем его только с явного согласия автора */}
|
||
{!adminMode && (
|
||
<div className="f-m-group">
|
||
<label className="f-reward-checkbox">
|
||
<input
|
||
type="checkbox"
|
||
checked={form.phoneVisible}
|
||
onChange={e => set("phoneVisible", e.target.checked)}
|
||
/>
|
||
<span className="f-reward-checkmark"/>
|
||
<span className="f-reward-text">{t('post.phoneConsentCheckbox')}</span>
|
||
</label>
|
||
<p className="f-hint">
|
||
{form.phoneVisible ? t('post.phoneConsentHint') : t('post.chatOnlyHint')}
|
||
</p>
|
||
</div>
|
||
)}
|
||
|
||
{(adminMode ? !!initialData?.phoneVisible : form.phoneVisible) && (
|
||
<div className="f-m-group">
|
||
<label className="f-m-label">{t('post.phoneLabel')}</label>
|
||
<ClearableField onClear={() => set("phone", "")} visible={!!form.phone}>
|
||
<input
|
||
className={`f-m-field${errors.phone ? " err" : ""}`}
|
||
type="tel"
|
||
placeholder={t('post.phonePlaceholder')}
|
||
value={form.phone}
|
||
onChange={e => set("phone", formatPhone(e.target.value))}
|
||
/>
|
||
</ClearableField>
|
||
{errors.phone && <p className="f-err-msg">{errors.phone}</p>}
|
||
</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">
|
||
<label className="f-reward-checkbox">
|
||
<input
|
||
type="checkbox"
|
||
checked={form.reward}
|
||
onChange={e => {
|
||
const checked = e.target.checked;
|
||
set("reward", checked);
|
||
if (checked && !(form.rewardText || "").trim()) {
|
||
set("rewardText", t('post.rewardDefault'));
|
||
}
|
||
}}
|
||
/>
|
||
|
||
<span className="f-reward-checkmark"/>
|
||
|
||
<span className="f-reward-text">
|
||
{t("post.rewardCheckbox")}
|
||
</span>
|
||
</label>
|
||
</div>
|
||
)}
|
||
|
||
{form.reward && form.type !== "found" && (
|
||
<div className="f-m-group">
|
||
<label className="f-m-label">{t('post.rewardLabel')}</label>
|
||
<ClearableField onClear={() => set("rewardText", "")} visible={!!form.rewardText}>
|
||
<input
|
||
className="f-m-field"
|
||
type="text"
|
||
placeholder={t('post.rewardDefault')}
|
||
maxLength={REWARD_TEXT_MAX_LENGTH}
|
||
value={form.rewardText}
|
||
onChange={e => set("rewardText", e.target.value)}
|
||
/>
|
||
</ClearableField>
|
||
</div>
|
||
)}
|
||
|
||
{/* Чекбокс согласия с правилами */}
|
||
<div className="f-m-group">
|
||
<label className="f-rules-checkbox">
|
||
<input
|
||
type="checkbox"
|
||
className="f-rules-input"
|
||
checked={form.rulesAccepted}
|
||
onChange={e => set("rulesAccepted", e.target.checked)}
|
||
/>
|
||
<span className="f-rules-checkmark" />
|
||
<span className="f-rules-text">
|
||
{t('post.rulesCheckboxPrefix')}{' '}
|
||
<span
|
||
className="f-rules-link"
|
||
onClick={e => {
|
||
e.preventDefault();
|
||
setRulesModalOpen(true);
|
||
}}
|
||
>
|
||
{t('post.rulesLinkText')}
|
||
</span>
|
||
</span>
|
||
</label>
|
||
{errors.rulesAccepted && <p className="f-err-msg">{errors.rulesAccepted}</p>}
|
||
</div>
|
||
|
||
{apiError && <p className="f-err-msg">{apiError}</p>}
|
||
|
||
<button className="f-m-back" type="button" onClick={() => setStep(1)} disabled={loading}>
|
||
{t('post.backStep')}
|
||
</button>
|
||
|
||
<button className="f-m-submit" type="button" onClick={handleSubmit} disabled={loading}>
|
||
<div className="f-m-submit-row">
|
||
{loading && <div className="f-m-spinner" />}
|
||
{isEdit ? t('post.saveChanges') : t('post.publish')}
|
||
</div>
|
||
</button>
|
||
</>
|
||
)}
|
||
|
||
</div>
|
||
</div>
|
||
|
||
{rulesModalOpen && (
|
||
<RulesModal onClose={() => setRulesModalOpen(false)} />
|
||
)}
|
||
|
||
{mapModalOpen && (
|
||
<MapModal
|
||
initialCoords={coords}
|
||
initialAddress={form.address}
|
||
onClose={() => setMapModalOpen(false)}
|
||
onPick={({ address: picked, coords: point }) => {
|
||
set("address", picked);
|
||
setCoords(point);
|
||
setErrors(prev => ({ ...prev, map: "" }));
|
||
setMapModalOpen(false);
|
||
}}
|
||
/>
|
||
)}
|
||
|
||
{resultModal && (
|
||
<div
|
||
className="f-modal-bg"
|
||
onClick={e => {
|
||
if (e.target === e.currentTarget) {
|
||
if (resultModal === "success") onSuccess?.();
|
||
onClose();
|
||
}
|
||
}}
|
||
>
|
||
<div className="f-modal f-modal-result">
|
||
<div className={`f-result-icon ${resultModal === "blocked" ? "blocked" : "success"}`}>
|
||
{resultModal === "blocked" ? "✕" : "✓"}
|
||
</div>
|
||
<h3 className="f-result-title">
|
||
{resultModal === "blocked"
|
||
? t('post.blockedTitle')
|
||
: adminMode ? t('adminPanel.postUpdatedModal') : t('post.successTitle')}
|
||
</h3>
|
||
<p className="f-result-text">
|
||
{resultModal === "blocked"
|
||
? t('post.blockedText')
|
||
: adminMode ? t('adminPanel.postUpdatedModalSub') : t('post.successText')}
|
||
</p>
|
||
<button
|
||
className={`f-result-btn ${resultModal === "blocked" ? "err" : "ok"}`}
|
||
type="button"
|
||
onClick={() => {
|
||
if (resultModal === "success") onSuccess?.();
|
||
onClose();
|
||
}}
|
||
>
|
||
{t('post.resultClose')}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
)}
|
||
</>
|
||
);
|
||
} |