-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lost.svelte
155 lines (129 loc) · 3.41 KB
/
Lost.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<script lang="ts">
// logic
import { navigate } from 'svelte-routing';
import { get } from 'svelte/store';
import { userStore } from '../../model/user.store';
let size = '';
let SelectionItem = '';
let OptionItem = [
'Sock',
'Underwear',
'T-shirt', 'Shirt', 'Trousers', 'Jacket'
]
let group = 1;
let SelectionColor = [];
let OptionColor = ['white','black','red','blue','green','yellow','orange','purple']
$: if(!!size && !!SelectionItem && !!SelectionColor)
console.log('filled out')
$: console.log('Changed selected:', SelectionItem)
$: console.log('Updated options:', OptionItem)
$: console.log('Changed selected:', SelectionColor)
$: console.log('Updated options:', OptionColor)
const redirectToUploaded = async () => {
const data = {
name: SelectionItem,
colors: SelectionColor.join(','),
size: size,
owner: get(userStore).id
};
const response = await fetch('https://api.iperka.com/items', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
if (response.ok) {
navigate('/lost-and-found/LostUploaded.svelte');
} else {
console.error('Failed to upload lost item');
}
};
</script>
<div class="mainContainer">
<h1>Define your lost item</h1>
<div></div>
</div>
<div class="itemSection">
<p class="sectionTitle">Item</p>
<select bind:value={SelectionItem}>
{#each OptionItem as value}<option {value}>{value}</option>{/each}
</select>
</div>
<div class="colorSection">
<p class="sectionTitle">Color</p>
<div class="colorboxes">
{#each OptionColor as color}
<label class="colorboxLabel">
{color}
<input type="checkbox" bind:group={SelectionColor} value={color} class="colorboxInput"/>
</label>
{/each}
</div>
</div>
<div class="sizeSection">
<p class="sectionTitle">Size</p>
<input bind:value={size} placeholder="enter the size" />
</div>
<button on:click={redirectToUploaded}>Upload my lost item.</button>
<style>
.mainContainer {
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.itemSection {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
margin-bottom: 50px;
}
.colorSection {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
margin-bottom: 50px;
}
.sizeSection {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
margin-bottom: 50px;
}
.sectionTitle {
font-size: 20px;
font-weight: bold;
margin-bottom: 10px;
}
.colorboxes {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.colorboxLabel {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100px;
}
.colorboxInput {
width: 30px;
height: 30px;
border-radius: 50%;
background-color: white;
margin-left: 5px;
}
.colorboxInput:checked {
background-color: var(--color);
}
</style>