Skip to content

Commit

Permalink
fix parsing size in the widget
Browse files Browse the repository at this point in the history
  • Loading branch information
theolemague committed Dec 18, 2024
1 parent d4af0ef commit 6c1ce74
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions widget-benevolat/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export const getServerSideProps = async (context) => {
try {
const q = context.query.widget ? `id=${context.query.widget}` : `name=${context.query.widgetName}`;
const response = await fetch(`${API_URL}/iframe/widget?${q}`).then((e) => e.json());
if (!response.ok) throw response;
widget = response.data;
} catch (e) {
console.error("error", e);
Expand All @@ -174,11 +175,11 @@ export const getServerSideProps = async (context) => {
});
}
if (context.query.remote) JSON.parse(context.query.remote).forEach((item) => searchParams.append("remote", item));
if (context.query.size) searchParams.append("size", context.query.size);
if (context.query.from) searchParams.append("from", context.query.from);
if (context.query.size) searchParams.append("size", parseInt(context.query.size, 10));
if (context.query.from) searchParams.append("from", parseInt(context.query.from, 10));
if (context.query.lat && context.query.lon) {
searchParams.append("lat", context.query.lat);
searchParams.append("lon", context.query.lon);
searchParams.append("lat", parseFloat(context.query.lat));
searchParams.append("lon", parseFloat(context.query.lon));
}

const response = await fetch(`${API_URL}/iframe/widget/${widget._id}/msearch?${searchParams.toString()}`).then((res) => res.json());
Expand Down
9 changes: 5 additions & 4 deletions widget-volontariat/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export const getServerSideProps = async (context) => {
try {
const q = context.query.widget ? `id=${context.query.widget}` : `name=${context.query.widgetName}`;
const response = await fetch(`${API_URL}/iframe/widget?${q}`).then((e) => e.json());
if (!response.ok) throw response;
widget = response.data;
} catch (e) {
console.error("error", e);
Expand All @@ -200,11 +201,11 @@ export const getServerSideProps = async (context) => {
if (context.query.country) JSON.parse(context.query.country).forEach((item) => searchParams.append("country", item));
if (context.query.start) searchParams.append("start", context.query.start);
if (context.query.duration) searchParams.append("duration", context.query.duration);
if (context.query.size) searchParams.append("size", context.query.size);
if (context.query.from) searchParams.append("from", context.query.from);
if (context.query.size) searchParams.append("size", parseInt(context.query.size, 10));
if (context.query.from) searchParams.append("from", parseInt(context.query.from, 10));
if (context.query.lat && context.query.lon) {
searchParams.append("lat", context.query.lat);
searchParams.append("lon", context.query.lon);
searchParams.append("lat", parseFloat(context.query.lat));
searchParams.append("lon", parseFloat(context.query.lon));
}

const response = await fetch(`${API_URL}/iframe/widget/${widget._id}/msearch?${searchParams.toString()}`).then((res) => res.json());
Expand Down

0 comments on commit 6c1ce74

Please sign in to comment.