Skip to content

Commit

Permalink
feat: ajout des CGU et de leur validation (#2044)
Browse files Browse the repository at this point in the history
* feat: add cgu_validated_at column

* fix: remove vite config files

* feat: force CGU approval

* test: fix seeds and validate cgu for everyone

* test: by default, validate cgus

* test: don't validate cgu for arbol

* test: fix typo

* feat: add cgu text

* fix: use fixed date in test

Co-authored-by: Jonathan Perret <[email protected]>

* fix: remove unused value

---------

Co-authored-by: Jonathan Perret <[email protected]>
  • Loading branch information
vjousse and jonathanperret authored Nov 29, 2023
1 parent 3db45ed commit bf94df5
Show file tree
Hide file tree
Showing 16 changed files with 839 additions and 294 deletions.
24 changes: 23 additions & 1 deletion app/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,30 @@
--border-plain-blue-france: var(--vert-cdb);
}


/* Remove chrome clear icon */
input[type='search']::-webkit-search-cancel-button {
-webkit-appearance: none;
}

div.cgu {
counter-reset: my-awesome-counter;
}
div.cgu ol {
list-style: none;
padding-left: 0px;
}
div.cgu ol li {
counter-increment: my-awesome-counter;
padding-bottom: 1rem;
}

div.cgu ol li::before {
content: counter(my-awesome-counter) '. ';
font-weight: bold;
font-weight: 700;
}

div.cgu ol > li::marker {
content: none;
font-size: var(--xl-size);
}
10 changes: 10 additions & 0 deletions app/src/routes/(auth)/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@ import {
} from '$lib/graphql/_gen/typed-document-nodes';
import { accountData } from '$lib/stores';
import { error } from '@sveltejs/kit';
import { redirect } from '@sveltejs/kit';

import { createClient, type Client } from '@urql/core';
import type { LayoutLoad } from './$types';

export const load: LayoutLoad = async (event) => {
const data = await event.parent();
const accountInfo = await getAccount(event.fetch, data.user.id);

if (!accountInfo) {
throw error(400, 'récupération du compte impossible');
}

if (!accountInfo.cguValidatedAt) {
// If cgu are not validated, we should alway redirect to the CGU validation page
if (event.url.pathname !== `/cguvalidate`) {
throw redirect(302, `/cguvalidate`);
}
}

accountData.set(accountInfo);
return {
account: accountInfo,
Expand Down
1 change: 1 addition & 0 deletions app/src/routes/(auth)/_query.gql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query GetAccountByPk($accountId: uuid!) {
confirmed
username
type
cguValidatedAt
beneficiary {
id
firstname
Expand Down
14 changes: 14 additions & 0 deletions app/src/routes/(auth)/cguvalidate/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script lang="ts">
import type { MenuItem } from '$lib/types';
import Footer from '$lib/ui/base/Footer.svelte';
import Header from '$lib/ui/base/Header.svelte';
const menuItems: MenuItem[] = [];
</script>

<Header {menuItems} />
<div class="fr-container fr-mb-8w">
<slot />
</div>

<Footer />
723 changes: 723 additions & 0 deletions app/src/routes/(auth)/cguvalidate/+page.svelte

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions app/src/routes/(auth)/cguvalidate/_updateAccountCgu.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mutation UpdateAccountCgu($cguValidatedAt: timestamptz!, $id: uuid!) {
updateCgu: update_account_by_pk(
_set: { cguValidatedAt: $cguValidatedAt }
pk_columns: { id: $id }
) {
id
}
}
67 changes: 0 additions & 67 deletions app/vite.config.ts.timestamp-1693905049559.mjs

This file was deleted.

67 changes: 0 additions & 67 deletions app/vite.config.ts.timestamp-1693905070418.mjs

This file was deleted.

Loading

0 comments on commit bf94df5

Please sign in to comment.