Skip to content

Commit

Permalink
navigate from router
Browse files Browse the repository at this point in the history
  • Loading branch information
Ko71k committed Dec 17, 2024
1 parent d445377 commit 4e9ec49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 2 additions & 5 deletions public/src/components/EventCreateForm/EventCreateForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,12 @@ export class EventCreateForm {
reader.readAsDataURL(file);
}
});
console.log(eventData);
if (eventData != null) {
console.log('editevent');
img.src = `${endpoint}/${eventData.image}`;
img.width = fileInput.width;
const submitButton = this.form.querySelector('.event-create-form__submit-btn');
submitButton.innerHTML = 'Сохранить';
submitButton.addEventListener('click', (event) => handleCreateEventEdit(event, '/events/my', navigate));
submitButton.addEventListener('click', (event) => handleCreateEventEdit(event, `events/${eventData.id}`));
const mapping = {
title: 'eventNameEntry',
image: 'imageInput',
Expand Down Expand Up @@ -226,9 +224,8 @@ export class EventCreateForm {
mock_data = { latitude: eventData.Latitude, longitude: eventData.Longitude, zoom: 17, needMark: true};
}
else {
console.log('edeitdevent');
const submitButton = this.form.querySelector('.event-create-form__submit-btn');
submitButton.addEventListener('click', (event) => handleCreateEventSubmit(event, '/events/my', navigate));
submitButton.addEventListener('click', (event) => handleCreateEventSubmit(event, '/events/my'));
}

// Инициализация карты
Expand Down
5 changes: 3 additions & 2 deletions public/src/modules/handleEventsActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @import {function} removeDangerous - Removes dangerous characters from a string
*/
import { isValidUsername, isValidPassword, isValidEmail, removeDangerous } from './FormValidation.js';
import { navigate } from './router.js';
/**
* Import the endpoint configuration from the config.js file
* @import {string} endpoint - The API endpoint URL
Expand Down Expand Up @@ -88,7 +89,7 @@ export async function loadEvent(eventId) {
return;
}

export async function handleCreateEventEdit(event, id, navigate) {
export async function handleCreateEventEdit(event, id) {
event.preventDefault();
loadCategories();
// Get form data
Expand Down Expand Up @@ -147,7 +148,7 @@ export async function handleCreateEventEdit(event, id, navigate) {
//navigate(pageToCome); //debug
}

export async function handleCreateEventSubmit(event, pageToCome, navigate) {
export async function handleCreateEventSubmit(event, pageToCome) {
event.preventDefault();
loadCategories();
// Get form data
Expand Down

0 comments on commit 4e9ec49

Please sign in to comment.