Add Docker build and deploy pipeline
Some checks failed
deploy-frontend / deploy (push) Failing after 11s
Some checks failed
deploy-frontend / deploy (push) Failing after 11s
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { useState, useCallback } from "react";
|
||||
import { useDeletePost } from "./useDeletePost";
|
||||
import { usePostStatus } from "./usePostStatus";
|
||||
import { rememberFoundAt, forgetFoundAt } from "../utils/foundAt";
|
||||
|
||||
/**
|
||||
* Объединяет действия над объявлениями (удаление, отметка "найдено")
|
||||
@@ -23,7 +24,7 @@ import { usePostStatus } from "./usePostStatus";
|
||||
*/
|
||||
export function useFeedActions({ refresh, loadMyPosts, onAuthRequired, isAuthenticated, t }) {
|
||||
const { deletePost } = useDeletePost();
|
||||
const { markAsFound } = usePostStatus();
|
||||
const { markAsFound, reopenPost } = usePostStatus();
|
||||
|
||||
const [error, setError] = useState("");
|
||||
|
||||
@@ -54,17 +55,37 @@ export function useFeedActions({ refresh, loadMyPosts, onAuthRequired, isAuthent
|
||||
if (!window.confirm(t('feed.confirmMarkFound'))) return;
|
||||
const result = await markAsFound(postId);
|
||||
if (result.success) {
|
||||
// Бэкенд не отдаёт момент перехода в CLOSED, а карточке нужна дата
|
||||
// («Найдено 3 октября») — запоминаем её на устройстве.
|
||||
rememberFoundAt(postId);
|
||||
afterMutation();
|
||||
} else {
|
||||
setError(result.error);
|
||||
}
|
||||
}, [t, markAsFound, afterMutation, isAuthenticated, onAuthRequired]);
|
||||
|
||||
// Отмена отметки «найдено» (автор нажал «Вернуть в поиск»). Без confirm:
|
||||
// это восстановление, а не разрушительное действие.
|
||||
const handleReopen = useCallback(async (postId) => {
|
||||
if (!isAuthenticated) {
|
||||
onAuthRequired?.();
|
||||
return;
|
||||
}
|
||||
const result = await reopenPost(postId);
|
||||
if (result.success) {
|
||||
forgetFoundAt(postId);
|
||||
afterMutation();
|
||||
} else {
|
||||
setError(result.error);
|
||||
}
|
||||
}, [reopenPost, afterMutation, isAuthenticated, onAuthRequired]);
|
||||
|
||||
const clearError = useCallback(() => setError(""), []);
|
||||
|
||||
return {
|
||||
handleDelete,
|
||||
handleMarkFound,
|
||||
handleReopen,
|
||||
handleNewAd: afterMutation,
|
||||
handleEditSave: afterMutation,
|
||||
error,
|
||||
|
||||
Reference in New Issue
Block a user