2023-06-19 20:38:45 +02:00
|
|
|
<script lang="ts">
|
2023-06-23 17:23:14 +02:00
|
|
|
export let card_data ={
|
|
|
|
}
|
2023-06-21 19:50:27 +02:00
|
|
|
let short_name
|
2023-06-23 17:23:14 +02:00
|
|
|
let password
|
2023-06-19 20:38:45 +02:00
|
|
|
let datecreated = new Date()
|
|
|
|
let datemodified = datecreated
|
|
|
|
|
2023-06-21 19:50:27 +02:00
|
|
|
import CardAdd from '$lib/components/CardAdd.svelte';
|
2023-06-23 17:23:14 +02:00
|
|
|
|
|
|
|
import SeasonSelect from '$lib/components/SeasonSelect.svelte';
|
|
|
|
export let season = []
|
|
|
|
|
2023-06-22 20:26:48 +02:00
|
|
|
import CreateIngredientList from '$lib/components/CreateIngredientList.svelte';
|
2023-06-23 17:23:14 +02:00
|
|
|
export let ingredients = []
|
|
|
|
|
2023-06-22 20:26:48 +02:00
|
|
|
import CreateStepList from '$lib/components/CreateStepList.svelte';
|
2023-06-23 17:23:14 +02:00
|
|
|
export let instructions = []
|
|
|
|
|
2023-06-19 20:38:45 +02:00
|
|
|
async function doPost () {
|
|
|
|
const res = await fetch('/api/add', {
|
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify({
|
|
|
|
recipe: {
|
2023-06-23 17:23:14 +02:00
|
|
|
season: get_season(),
|
|
|
|
...card_data,
|
|
|
|
images: [{
|
|
|
|
mediapath: short_name + '.webp',
|
|
|
|
alt: "",
|
|
|
|
caption: ""
|
|
|
|
}],
|
2023-06-19 20:38:45 +02:00
|
|
|
short_name,
|
|
|
|
datecreated,
|
|
|
|
datemodified,
|
2023-06-23 17:23:14 +02:00
|
|
|
instructions,
|
|
|
|
ingredients,
|
2023-06-19 20:38:45 +02:00
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
2023-06-23 17:23:14 +02:00
|
|
|
bearer: password,
|
2023-06-19 20:38:45 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
const json = await res.json()
|
|
|
|
result = JSON.stringify(json)
|
|
|
|
console.log(result)
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2023-06-23 17:23:14 +02:00
|
|
|
input.temp{
|
2023-06-21 19:50:27 +02:00
|
|
|
all: unset;
|
2023-06-19 20:38:45 +02:00
|
|
|
display: block;
|
2023-06-23 17:23:14 +02:00
|
|
|
margin: 1rem auto;
|
2023-06-21 19:50:27 +02:00
|
|
|
padding: 0.2em 1em;
|
|
|
|
border-radius: 1000px;
|
|
|
|
background-color: var(--nord4);
|
|
|
|
|
2023-06-19 20:38:45 +02:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<h1>Rezept hinzufügen</h1>
|
|
|
|
|
2023-06-23 17:23:14 +02:00
|
|
|
<CardAdd {card_data}></CardAdd>
|
|
|
|
|
|
|
|
<input class=temp bind:value={short_name} placeholder="Kurzname"/>
|
|
|
|
|
|
|
|
<SeasonSelect {season}></SeasonSelect>
|
|
|
|
|
2023-06-19 20:38:45 +02:00
|
|
|
|
2023-06-21 19:50:27 +02:00
|
|
|
<h2>Zutaten</h2>
|
2023-06-23 17:23:14 +02:00
|
|
|
<CreateIngredientList {ingredients}></CreateIngredientList>
|
2023-06-21 19:50:27 +02:00
|
|
|
<h2>Zubereitung</h2>
|
2023-06-23 17:23:14 +02:00
|
|
|
<CreateStepList {instructions} ></CreateStepList>
|
|
|
|
<input class=temp type="password" placeholder=Passwort bind:value={password}>
|
|
|
|
<button on:click={doPost}>ADD RECIPE</button>
|