diff --git a/deno.lock b/deno.lock
index b250047..5a1d5f2 100644
--- a/deno.lock
+++ b/deno.lock
@@ -1595,6 +1595,21 @@
"integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g=="
}
},
+ "remote": {
+ "https://deno.land/x/zod@v3.23.8/ZodError.ts": "528da200fbe995157b9ae91498b103c4ef482217a5c086249507ac850bd78f52",
+ "https://deno.land/x/zod@v3.23.8/errors.ts": "5285922d2be9700cc0c70c95e4858952b07ae193aa0224be3cbd5cd5567eabef",
+ "https://deno.land/x/zod@v3.23.8/external.ts": "a6cfbd61e9e097d5f42f8a7ed6f92f93f51ff927d29c9fbaec04f03cbce130fe",
+ "https://deno.land/x/zod@v3.23.8/helpers/enumUtil.ts": "54efc393cc9860e687d8b81ff52e980def00fa67377ad0bf8b3104f8a5bf698c",
+ "https://deno.land/x/zod@v3.23.8/helpers/errorUtil.ts": "7a77328240be7b847af6de9189963bd9f79cab32bbc61502a9db4fe6683e2ea7",
+ "https://deno.land/x/zod@v3.23.8/helpers/parseUtil.ts": "c14814d167cc286972b6e094df88d7d982572a08424b7cd50f862036b6fcaa77",
+ "https://deno.land/x/zod@v3.23.8/helpers/partialUtil.ts": "998c2fe79795257d4d1cf10361e74492f3b7d852f61057c7c08ac0a46488b7e7",
+ "https://deno.land/x/zod@v3.23.8/helpers/typeAliases.ts": "0fda31a063c6736fc3cf9090dd94865c811dfff4f3cb8707b932bf937c6f2c3e",
+ "https://deno.land/x/zod@v3.23.8/helpers/util.ts": "30c273131661ca5dc973f2cfb196fa23caf3a43e224cdde7a683b72e101a31fc",
+ "https://deno.land/x/zod@v3.23.8/index.ts": "d27aabd973613985574bc31f39e45cb5d856aa122ef094a9f38a463b8ef1a268",
+ "https://deno.land/x/zod@v3.23.8/locales/en.ts": "a7a25cd23563ccb5e0eed214d9b31846305ddbcdb9c5c8f508b108943366ab4c",
+ "https://deno.land/x/zod@v3.23.8/mod.ts": "ec6e2b1255c1a350b80188f97bd0a6bac45801bb46fc48f50b9763aa66046039",
+ "https://deno.land/x/zod@v3.23.8/types.ts": "1b172c90782b1eaa837100ebb6abd726d79d6c1ec336350c8e851e0fd706bf5c"
+ },
"workspace": {
"packageJson": {
"dependencies": [
diff --git a/pb_migrations/1729501485_updated_extractions.js b/pb_migrations/1729501485_updated_extractions.js
new file mode 100644
index 0000000..dba0cda
--- /dev/null
+++ b/pb_migrations/1729501485_updated_extractions.js
@@ -0,0 +1,52 @@
+///
+migrate((db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("a3ohzxb6zpqym11")
+
+ collection.createRule = ""
+
+ // update
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "tig9x7zm",
+ "name": "utilisateur",
+ "type": "relation",
+ "required": true,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "collectionId": "_pb_users_auth_",
+ "cascadeDelete": false,
+ "minSelect": null,
+ "maxSelect": 1,
+ "displayFields": null
+ }
+ }))
+
+ return dao.saveCollection(collection)
+}, (db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("a3ohzxb6zpqym11")
+
+ collection.createRule = null
+
+ // update
+ collection.schema.addField(new SchemaField({
+ "system": false,
+ "id": "tig9x7zm",
+ "name": "utilisateur",
+ "type": "relation",
+ "required": false,
+ "presentable": false,
+ "unique": false,
+ "options": {
+ "collectionId": "_pb_users_auth_",
+ "cascadeDelete": false,
+ "minSelect": null,
+ "maxSelect": 1,
+ "displayFields": null
+ }
+ }))
+
+ return dao.saveCollection(collection)
+})
diff --git a/pb_migrations/1729502042_updated_extractions.js b/pb_migrations/1729502042_updated_extractions.js
new file mode 100644
index 0000000..92fc42a
--- /dev/null
+++ b/pb_migrations/1729502042_updated_extractions.js
@@ -0,0 +1,18 @@
+///
+migrate((db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("a3ohzxb6zpqym11")
+
+ collection.listRule = "@request.auth.id = utilisateur.id"
+ collection.createRule = "@request.data.utilisateur.id = @request.auth.id"
+
+ return dao.saveCollection(collection)
+}, (db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("a3ohzxb6zpqym11")
+
+ collection.listRule = null
+ collection.createRule = ""
+
+ return dao.saveCollection(collection)
+})
diff --git a/pb_migrations/1729505120_updated_extractions.js b/pb_migrations/1729505120_updated_extractions.js
new file mode 100644
index 0000000..cc69295
--- /dev/null
+++ b/pb_migrations/1729505120_updated_extractions.js
@@ -0,0 +1,16 @@
+///
+migrate((db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("a3ohzxb6zpqym11")
+
+ collection.viewRule = "@request.auth.id = utilisateur.id"
+
+ return dao.saveCollection(collection)
+}, (db) => {
+ const dao = new Dao(db)
+ const collection = dao.findCollectionByNameOrId("a3ohzxb6zpqym11")
+
+ collection.viewRule = null
+
+ return dao.saveCollection(collection)
+})
diff --git a/src/components/GrosBouton.svelte b/src/components/GrosBouton.svelte
new file mode 100644
index 0000000..26f3357
--- /dev/null
+++ b/src/components/GrosBouton.svelte
@@ -0,0 +1,35 @@
+
+
+
diff --git a/src/components/ListeExtractions.svelte b/src/components/ListeExtractions.svelte
new file mode 100644
index 0000000..ff356a1
--- /dev/null
+++ b/src/components/ListeExtractions.svelte
@@ -0,0 +1,17 @@
+
+
+
+ {#await data}
+ Chargement des cafés...
+ {:then extractions}
+ {#each extractions.items as extraction}
+
+ {/each}
+ {/await}
+
diff --git a/src/components/Loader.svelte b/src/components/Loader.svelte
new file mode 100644
index 0000000..4e52a02
--- /dev/null
+++ b/src/components/Loader.svelte
@@ -0,0 +1,28 @@
+
+
+
+
+
diff --git a/src/components/MessageErreur.svelte b/src/components/MessageErreur.svelte
new file mode 100644
index 0000000..57e6ef2
--- /dev/null
+++ b/src/components/MessageErreur.svelte
@@ -0,0 +1,11 @@
+
+
+
+ ${props.erreur}
+
diff --git a/src/components/ResumeExtraction.svelte b/src/components/ResumeExtraction.svelte
new file mode 100644
index 0000000..8143fbf
--- /dev/null
+++ b/src/components/ResumeExtraction.svelte
@@ -0,0 +1,14 @@
+
+
+
diff --git a/src/lib/extractions.ts b/src/lib/extractions.ts
new file mode 100644
index 0000000..9c09da9
--- /dev/null
+++ b/src/lib/extractions.ts
@@ -0,0 +1,31 @@
+import { pb } from './database.ts';
+import { type RecordModel } from 'pocketbase';
+import { creationExtractionSchema } from './schemas.ts';
+import { currentUser } from './login.svelte.ts';
+
+export interface Extraction extends RecordModel {
+ nom: string;
+ poids_cafe: number;
+ releves_tds: number[];
+}
+
+export async function nouvelleExtraction(nom: string): Promise {
+ const creationExtraction = creationExtractionSchema.parse({
+ nom,
+ utilisateur: currentUser.value.id
+ });
+
+ const nouvelleExtraction: Extraction = await pb
+ .collection('extractions')
+ .create(creationExtraction);
+
+ return nouvelleExtraction;
+}
+
+export async function getExtractions(page: number, perPage: number) {
+ return await pb.collection('extractions').getList(page, perPage);
+}
+
+export async function getExtraction(id: string) {
+ return await pb.collection('extractions').getOne(id);
+}
diff --git a/src/lib/login.svelte.ts b/src/lib/login.svelte.ts
index 8f6e280..d4d0905 100644
--- a/src/lib/login.svelte.ts
+++ b/src/lib/login.svelte.ts
@@ -2,6 +2,7 @@ import type { AuthModel, RecordModel } from 'pocketbase';
import { pb } from './database';
export type User = {
+ id: string;
username: string;
email: string;
name: string;
diff --git a/src/lib/schemas.ts b/src/lib/schemas.ts
index fe1ab1a..a2cd828 100644
--- a/src/lib/schemas.ts
+++ b/src/lib/schemas.ts
@@ -3,4 +3,9 @@ import { z } from 'zod';
export const loginSchema = z.object({
email: z.string().email(),
password: z.string()
-});
\ No newline at end of file
+});
+
+export const creationExtractionSchema = z.object({
+ nom: z.string().min(5).max(50),
+ utilisateur: z.string()
+});
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index 9373620..0ac4338 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -1,3 +1,18 @@
-
-
On fait du café
+
+
+
+ {#if currentUser.value != null}
+
+ ➕ Nouvelle extraction
+
+
+ {:else}
+
Salut ! Ici on fait du café !
+
Mais d'abord faut se connecter.
+ {/if}
diff --git a/src/routes/extractions/+layout.ts b/src/routes/extractions/+layout.ts
new file mode 100644
index 0000000..d43d0cd
--- /dev/null
+++ b/src/routes/extractions/+layout.ts
@@ -0,0 +1 @@
+export const prerender = false;
diff --git a/src/routes/extractions/[id]/+page.svelte b/src/routes/extractions/[id]/+page.svelte
new file mode 100644
index 0000000..1290e7e
--- /dev/null
+++ b/src/routes/extractions/[id]/+page.svelte
@@ -0,0 +1,12 @@
+
+
+{#await data}
+
Bientôt le café
+{:then extraction}
+
Miam le café : {extraction.nom}
+{/await}
diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte
index d3ff0db..dcd1992 100644
--- a/src/routes/login/+page.svelte
+++ b/src/routes/login/+page.svelte
@@ -1,17 +1,16 @@
-