Skip to content

Commit

Permalink
Update packages and fix Sveltekit breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricr committed Jan 3, 2022
1 parent 472177b commit 2a0787d
Show file tree
Hide file tree
Showing 26 changed files with 967 additions and 1,160 deletions.
2,019 changes: 909 additions & 1,110 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/lib/components/ensure-logged-in.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
onMount(() => {
if (!$token) {
goto(`/auth/connexion?next=${encodeURIComponent($page.path)}`);
goto(`/auth/connexion?next=${encodeURIComponent($page.url.pathname)}`);
}
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ensure-staff.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
onMount(() => {
if (!$token) {
goto(`/auth/connexion?next=${encodeURIComponent($page.path)}`);
goto(`/auth/connexion?next=${encodeURIComponent($page.url.pathname)}`);
}
});
</script>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/__layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
});
}
export async function load({ _page, _fetch, _session, _context }) {
export async function load() {
await getUserInfo();
return {};
}
Expand Down Expand Up @@ -46,7 +46,7 @@

<script
defer
data-domain={$page.host}
data-domain={$page.url.hostname}
src="https://plausible.io/js/plausible.outbound-links.js"></script>
<script>
window.plausible =
Expand Down
6 changes: 3 additions & 3 deletions src/routes/_layout/_header-actions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/>
</div>
{:else}
{#if $page.path !== "/auth/inscription"}
{#if $page.url.pathname !== "/auth/inscription"}
<LinkButton
label="Inscription"
icon={loginIcon}
Expand All @@ -40,14 +40,14 @@
to={`/auth/inscription`}
/>
{/if}
{#if $page.path !== "/auth/connexion"}
{#if $page.url.pathname !== "/auth/connexion"}
<LinkButton
label="Connexion"
icon={userSmileIcon}
iconOnLeft
noBackground
nofollow
to={`/auth/connexion?next=${encodeURIComponent($page.path)}`}
to={`/auth/connexion?next=${encodeURIComponent($page.url.pathname)}`}
/>
{/if}
<div class="block md:hidden">
Expand Down
12 changes: 7 additions & 5 deletions src/routes/auth/accepter-invitation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import { getApiURL, defaultAcceptHeader } from "$lib/utils/api.js";
import { disconnect } from "$lib/auth";
export async function load({ page, _fetch, _session, _context }) {
const token = page.query.get("token");
const membership = page.query.get("membership");
const url = `${getApiURL()}/structures/accept-invite/`;
const result = await fetch(url, {
export async function load({ url }) {
const query = url.searchParams;
const token = query.get("token");
const membership = query.get("membership");
const targetUrl = `${getApiURL()}/structures/accept-invite/`;
const result = await fetch(targetUrl, {
method: "POST",
headers: {
Accept: defaultAcceptHeader,
Expand Down
4 changes: 2 additions & 2 deletions src/routes/auth/connexion.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
}
function getNextPage() {
const next = $page.query.get("next");
const next = $page.url.searchParams.get("next");
if (next && next.startsWith("/") && !next.startsWith("/auth/")) return next;
return "/";
}
Expand All @@ -62,7 +62,7 @@
}
onMount(() => {
if ($token && $page.path === "/auth/connexion") {
if ($token && $page.url.pathname === "/auth/connexion") {
goto(getNextPage());
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/routes/auth/inscription.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import StepConfirm from "./registration/_step5-confirm.svelte";
import AuthLayout from "./_auth_layout.svelte";
const siret = $page.query.get("siret");
const siret = $page.url.searchParams.get("siret");
const steps = new Map([
[1, StepTypology],
[2, StepPoleEmploi],
Expand Down
9 changes: 5 additions & 4 deletions src/routes/auth/reinitialiser-mdp.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import { getApiURL, defaultAcceptHeader } from "$lib/utils/api.js";
import { disconnect } from "$lib/auth";
export async function load({ page, _fetch, _session, _context }) {
const token = page.query.get("token");
const url = `${getApiURL()}/auth/token/verify/`;
const result = await fetch(url, {
export async function load({ url }) {
const query = url.searchParams;
const token = query.get("token");
const targetUrl = `${getApiURL()}/auth/token/verify/`;
const result = await fetch(targetUrl, {
method: "POST",
headers: {
Accept: defaultAcceptHeader,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/auth/renvoyer-email-validation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Info from "$lib/components/info.svelte";
import AuthLayout from "./_auth_layout.svelte";
let email = $page.query.get("email") || "";
let email = $page.url.searchParams.get("email") || "";
let success = false;
let requesting = false;
Expand Down
10 changes: 6 additions & 4 deletions src/routes/auth/validation-email.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import { getApiURL, defaultAcceptHeader } from "$lib/utils/api.js";
import { disconnect } from "$lib/auth";
export async function load({ page, _fetch, _session, _context }) {
const token = page.query.get("token");
const url = `${getApiURL()}/auth/registration/validate-email/`;
const result = await fetch(url, {
export async function load({ url }) {
const query = url.searchParams;
const token = query.get("token");
const targetUrl = `${getApiURL()}/auth/registration/validate-email/`;
const result = await fetch(targetUrl, {
method: "POST",
headers: {
Accept: defaultAcceptHeader,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/index.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script context="module">
import { getServicesOptions } from "$lib/services";
export async function load({ _page, _fetch, _session, _context }) {
export async function load() {
return {
props: {
servicesOptions: await getServicesOptions(),
Expand Down
11 changes: 6 additions & 5 deletions src/routes/recherche.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
return [];
}
export async function load({ page, _fetch, _session, _context }) {
const category = page.query.get("cat");
const subcategory = page.query.get("sub");
const cityCode = page.query.get("city");
const cityLabel = page.query.get("cl");
export async function load({ url }) {
const query = url.searchParams;
const category = query.get("cat");
const subcategory = query.get("sub");
const cityCode = query.get("city");
const cityLabel = query.get("cl");
return {
props: {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/services/[slug]/_orientation-box.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
export let service;
export let sharingUrl = `https://${$page.host}${$page.path}`;
export let sharingUrl = $page.url;
export let pdfUrl = `${PDF_SERVICE_URL}/service-pdf/${service.slug}`;
let orientationModalIsOpen = false;
Expand Down
4 changes: 3 additions & 1 deletion src/routes/services/[slug]/_orientation-modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ ${service.credentialsDisplay.map((s) => `- ${s}`).join("\n")}
/>
<LinkButton
label="Connexion"
to={`/auth/connexion?next=${encodeURIComponent($page.path)}`}
to={`/auth/connexion?next=${encodeURIComponent(
$page.url.pathname
)}`}
/>
</div>
{/if}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/services/[slug]/_service-header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
export let service;
export let isPreview = false;
const editLink = `${$page.path}/editer`;
const editLink = `${$page.url.pathname}/editer`;
</script>

<style>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/services/[slug]/editer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { getServicesOptions, getService } from "$lib/services";
import { getMyStructures } from "$lib/structures";
export async function load({ page, _fetch, _session, _context }) {
const service = await getService(page.params.slug);
export async function load({ params }) {
const service = await getService(params.slug);
return {
props: {
service,
Expand Down
4 changes: 2 additions & 2 deletions src/routes/services/[slug]/index.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script context="module">
import { getService } from "$lib/services";
export async function load({ page, _fetch, _session, _context }) {
const service = await getService(page.params.slug);
export async function load({ params }) {
const service = await getService(params.slug);
return {
props: {
service,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/services/creer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { userInfo } from "$lib/auth";
export async function load({ _page, _fetch, _session, _context }) {
export async function load() {
return {
props: {
lastDraft: await getLastDraft(),
Expand Down
8 changes: 4 additions & 4 deletions src/routes/structures/[slug]/__layout.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script context="module">
import { getStructure, getStructureServices } from "$lib/structures";
export async function load({ page }) {
const structure = await getStructure(page.params.slug);
const services = await getStructureServices(page.params.slug, {
export async function load({ params }) {
const structure = await getStructure(params.slug);
const services = await getStructureServices(params.slug, {
publishedOnly: true,
});
return {
Expand All @@ -25,7 +25,7 @@
import StructureHeader from "./_structure-header.svelte";
export let structure;
$: currentTab = $page.path.endsWith("/services") ? 2 : 1;
$: currentTab = $page.url.pathname.endsWith("/services") ? 2 : 1;
</script>

<CenteredGrid --col-bg="var(--col-magenta-brand)" topPadded>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/tableau-de-bord/admin/services.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script context="module">
import { getServices } from "$lib/services";
export async function load({ _page, _fetch, _session, _context }) {
export async function load() {
return {
props: {
services: await getServices(),
Expand Down
2 changes: 1 addition & 1 deletion src/routes/tableau-de-bord/admin/structures.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script context="module">
import { getStructures } from "$lib/structures";
export async function load({ _page, _fetch, _session, _context }) {
export async function load() {
return {
props: {
structures: await getStructures(),
Expand Down
2 changes: 1 addition & 1 deletion src/routes/tableau-de-bord/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { getMyServices } from "$lib/services";
import { getMyStructures } from "$lib/structures";
export async function load({ _page, _fetch, _session, _context }) {
export async function load() {
return {
props: {
services: await getMyServices(),
Expand Down
4 changes: 2 additions & 2 deletions src/routes/tableau-de-bord/structures/[slug]/editer.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script context="module">
import { getStructure, getStructuresOptions } from "$lib/structures";
export async function load({ page, _fetch, _session, _context }) {
export async function load({ params }) {
return {
props: {
structure: await getStructure(page.params.slug),
structure: await getStructure(params.slug),
structuresOptions: await getStructuresOptions(),
},
};
Expand Down
4 changes: 2 additions & 2 deletions src/routes/tableau-de-bord/structures/[slug]/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import { getMyStructures, getStructures } from "$lib/structures";
import { userInfo } from "$lib/auth";
export async function load({ page, _fetch, _session, _context }) {
export async function load({ params }) {
const structures = userInfo.isStaff
? await getStructures()
: await getMyStructures();
const structureSlug = page.params.slug;
const structureSlug = params.slug;
const structure = structures.find((s) => (s.slug = structureSlug));
if (structure) {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/tableau-de-bord/structures/creer/index.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script context="module">
import { getStructuresOptions } from "$lib/structures";
export async function load({ _page, _fetch, _session, _context }) {
export async function load() {
return { props: { structuresOptions: await getStructuresOptions() } };
}
</script>
Expand Down

0 comments on commit 2a0787d

Please sign in to comment.