Доски желаний и политика награждения
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m0s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m0s
This commit is contained in:
@@ -9,7 +9,7 @@ const TASKS_API_URL = '/api/tasks'
|
||||
const PROJECTS_API_URL = '/projects'
|
||||
const WISHLIST_FORM_STATE_KEY = 'wishlistFormPendingState'
|
||||
|
||||
function WishlistForm({ onNavigate, wishlistId, editConditionIndex, newTaskId }) {
|
||||
function WishlistForm({ onNavigate, wishlistId, editConditionIndex, newTaskId, boardId }) {
|
||||
const { authFetch } = useAuth()
|
||||
const [name, setName] = useState('')
|
||||
const [price, setPrice] = useState('')
|
||||
@@ -496,8 +496,22 @@ function WishlistForm({ onNavigate, wishlistId, editConditionIndex, newTaskId })
|
||||
})),
|
||||
}
|
||||
|
||||
const url = wishlistId ? `${API_URL}/${wishlistId}` : API_URL
|
||||
const method = wishlistId ? 'PUT' : 'POST'
|
||||
let url, method
|
||||
if (wishlistId) {
|
||||
// Редактирование существующего желания
|
||||
url = `${API_URL}/${wishlistId}`
|
||||
method = 'PUT'
|
||||
} else {
|
||||
// Создание нового желания
|
||||
if (boardId) {
|
||||
// Создание на доске
|
||||
url = `/api/wishlist/boards/${boardId}/items`
|
||||
} else {
|
||||
// Старый API для обратной совместимости
|
||||
url = API_URL
|
||||
}
|
||||
method = 'POST'
|
||||
}
|
||||
|
||||
const response = await authFetch(url, {
|
||||
method,
|
||||
@@ -544,7 +558,12 @@ function WishlistForm({ onNavigate, wishlistId, editConditionIndex, newTaskId })
|
||||
}
|
||||
|
||||
resetForm()
|
||||
onNavigate?.('wishlist')
|
||||
// Возвращаемся на доску, если она была указана
|
||||
if (boardId) {
|
||||
onNavigate?.('wishlist', { boardId })
|
||||
} else {
|
||||
onNavigate?.('wishlist')
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
@@ -554,7 +573,12 @@ function WishlistForm({ onNavigate, wishlistId, editConditionIndex, newTaskId })
|
||||
|
||||
const handleCancel = () => {
|
||||
resetForm()
|
||||
onNavigate?.('wishlist')
|
||||
// Возвращаемся на доску, если она была указана
|
||||
if (boardId) {
|
||||
onNavigate?.('wishlist', { boardId })
|
||||
} else {
|
||||
onNavigate?.('wishlist')
|
||||
}
|
||||
}
|
||||
|
||||
if (loadingWishlist) {
|
||||
|
||||
Reference in New Issue
Block a user