{"id":2105,"date":"2025-05-09T18:20:26","date_gmt":"2025-05-09T16:20:26","guid":{"rendered":"https:\/\/wakacje-we-francji.pl\/?page_id=2105"},"modified":"2025-05-15T16:35:08","modified_gmt":"2025-05-15T14:35:08","slug":"rezerwacje","status":"publish","type":"page","link":"https:\/\/wakacje-we-francji.pl\/en\/rezerwacje\/","title":{"rendered":"Rezerwacje"},"content":{"rendered":"<style>\n  \/* kontener formularza i wynik\u00f3w *\/\n  .reservation-box { \/* ...jak wcze\u015bniej...*\/ }\n  .results { margin-top: 30px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }\n  .card { background:#fff; border-radius:8px; padding:16px; box-shadow:0 4px 8px rgba(0,0,0,0.1); }\n  .card h3 { margin:0 0 8px; color:#4A628A; font-size:1.1rem; }\n  .card p { margin:0 0 12px; color:#333; }\n  .card button { background:#7AB2D3; color:#fff; border:none; padding:8px; width:100%; border-radius:6px; cursor:pointer; }\n  .card button:hover { background:#4A628A; }\n<\/style>\n\n<div class=\"reservation-box\">\n  <h2>Sprawd\u017a dost\u0119pno\u015b\u0107<\/h2>\n  <form id=\"search-form\" action=\"\">\n    <!-- pola jak wcze\u015bniej bez kodu rezerwacji i kwoty -->\n    <input id=\"lokalizacja\" placeholder=\"Lokalizacja\" required>\n    <input id=\"przyjazd\" type=\"date\" required>\n    <input id=\"wyjazd\"  type=\"date\" required>\n    <button type=\"submit\">Wyszukaj<\/button>\n  <input type=\"hidden\" name=\"trp-form-language\" value=\"en\"\/><\/form>\n\n  <div id=\"results\" class=\"results\"><\/div>\n<\/div>\n\n<script>\n  document.getElementById('search-form').addEventListener('submit', async e => {\n    e.preventDefault();\n    const loc  = e.target.lokalizacja.value;\n    const inD  = e.target.przyjazd.value;\n    const outD = e.target.wyjazd.value;\n    const resContainer = document.getElementById('results');\n    resContainer.innerHTML = '\u0141aduj\u0119\u2026';\n\n    try {\n      const resp = await fetch('https:\/\/odalys-backend.onrender.com\/availability', {\n        method: 'POST',\n        headers: {'Content-Type':'application\/json'},\n        body: JSON.stringify({ lokalizacja: loc, przyjazd: inD, wyjazd: outD })\n      });\n      const { options } = await resp.json();\n      if (!options || options.length === 0) {\n        resContainer.innerHTML = '<p>Brak dost\u0119pnych opcji dla wybranych termin\u00f3w.<\/p>';\n        return;\n      }\n      resContainer.innerHTML = options.map(opt => `\n        <div class=\"card\">\n          <h3>${opt.title}<\/h3>\n          <p>Price: ${opt.price}<\/p>\n          <button onclick=\"reserve('${opt.id}')\">Rezerwuj<\/button>\n        <\/div>\n      `).join('');\n\n    } catch (err) {\n      console.error(err);\n      resContainer.innerHTML = '<p>Wyst\u0105pi\u0142 b\u0142\u0105d podczas wyszukiwania.<\/p>';\n    }\n  });\n\n  async function reserve(id) {\n    const email = prompt('Podaj sw\u00f3j e-mail:');\n    if (!email) return;\n    \/\/ tutaj mo\u017cesz rozbudowa\u0107 payload o e-mail i inne dane\n    const resp = await fetch('https:\/\/odalys-backend.onrender.com\/rezerwacja', {\n      method:'POST',\n      headers:{'Content-Type':'application\/json'},\n      body: JSON.stringify({\n        lokalizacja: document.getElementById('lokalizacja').value,\n        przyjazd: document.getElementById('przyjazd').value,\n        wyjazd: document.getElementById('wyjazd').value,\n        osoby: 2,            \/\/ mo\u017cesz pobra\u0107 z additional input\n        email,               \/\/ z prompt\n        kod: id              \/\/ u\u017cyj ID opcji jako kod rezerwacji\n      })\n    });\n    const { message } = await resp.json();\n    alert(message);\n  }\n<\/script>\n\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>","protected":false},"excerpt":{"rendered":"<p>Sprawd\u017a dost\u0119pno\u015b\u0107 Wyszukaj<\/p>","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","footnotes":""},"class_list":["post-2105","page","type-page","status-publish","hentry"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"trp-custom-language-flag":false},"uagb_author_info":{"display_name":"janusz","author_link":"https:\/\/wakacje-we-francji.pl\/en\/author\/janusz\/"},"uagb_comment_info":0,"uagb_excerpt":"Sprawd\u017a dost\u0119pno\u015b\u0107 Wyszukaj","_links":{"self":[{"href":"https:\/\/wakacje-we-francji.pl\/en\/wp-json\/wp\/v2\/pages\/2105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wakacje-we-francji.pl\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/wakacje-we-francji.pl\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/wakacje-we-francji.pl\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wakacje-we-francji.pl\/en\/wp-json\/wp\/v2\/comments?post=2105"}],"version-history":[{"count":4,"href":"https:\/\/wakacje-we-francji.pl\/en\/wp-json\/wp\/v2\/pages\/2105\/revisions"}],"predecessor-version":[{"id":2283,"href":"https:\/\/wakacje-we-francji.pl\/en\/wp-json\/wp\/v2\/pages\/2105\/revisions\/2283"}],"wp:attachment":[{"href":"https:\/\/wakacje-we-francji.pl\/en\/wp-json\/wp\/v2\/media?parent=2105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}