-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBadgesCreate.vue
More file actions
305 lines (293 loc) · 14.2 KB
/
Copy pathBadgesCreate.vue
File metadata and controls
305 lines (293 loc) · 14.2 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<script setup>
import Layout from "@/Layouts/Layout.vue";
import {Link, Head, usePage} from '@inertiajs/vue3'
import Steps from 'primevue/steps';
import Fieldset from 'primevue/fieldset';
import InputText from "primevue/inputtext";
import Dropdown from "primevue/dropdown";
import Dialog from 'primevue/dialog';
import {useForm} from 'laravel-precognition-vue-inertia'
import InputSwitch from 'primevue/inputswitch';
import {computed, reactive, ref} from "vue";
import Button from 'primevue/button';
import ImageUpload from "@/Components/BadgeCreator/ImageUpload.vue";
import Panel from 'primevue/panel';
import Tag from 'primevue/tag';
import dayjs from "dayjs";
import InputError from "@/Components/InputError.vue";
import Message from "primevue/message";
defineOptions({
layout: Layout
})
const props = defineProps({
species: Array,
isFree: Boolean
})
const imageModalOpen = ref(false)
const previewImage = ref(null);
const imageSource = reactive({});
const form = useForm('post', route('badges.store'), {
species: null,
name: null,
image: null,
catchEmAll: true,
publish: false,
tos: false,
upgrades: {
doubleSided: false,
spareCopy: false
}
})
function submit() {
form.submit();
}
function imageUpdatedEvent(image) {
console.log(image);
previewImage.value = image.croppedImage;
form.image = new File([image.blob], 'fursuit.' + image.type, {
type: image.type
});
imageModalOpen.value = false;
}
const basePrice = computed(() => {
let price = 0;
if (props.isFree === false) {
price += 2;
}
return price;
})
const latePrice = computed(() => {
if (dayjs().isAfter(dayjs(usePage().props.event.preorder_ends_at))) {
return 2;
}
return 0;
})
const total = computed(() => {
let total = basePrice.value + latePrice.value;
if (form.upgrades.doubleSided) {
total += 1;
}
if (form.upgrades.spareCopy) {
total += 2;
}
return total;
})
</script>
<template>
<Head title="Order your Fursuit Badge"/>
<Dialog ke v-model:visible="imageModalOpen" :dismissableMask="false" modal header="Upload Fursuit Picture"
:style="{ width: '25rem' }">
<span
class="text-surface-600 dark:text-surface-0/70 block mb-5">Please upload a picture, you can crop the image after you uploaded it.</span>
<ImageUpload @update-image="imageUpdatedEvent" @update-source="args => imageSource = args" :image-source="imageSource"></ImageUpload>
</Dialog>
<!-- Fursuit Creator -->
<div class="pt-8 px-6 xl:px-0">
<div class="mb-8">
<h1 class="text-xl sm:text-2xl md:text-3xl font-semibold font-main">Eurofurence Fursuit Badge Creator</h1>
<p>Welcome to our badge configurator, please enter all the details and options you would like!</p>
</div>
<Message
v-if="new Date(usePage().props.event.mass_printed_at) < new Date()"
severity="info"
:closable="false">
{{ "Your badge will be available to pick up on the 2nd convention day." }}
</Message>
<!-- Group 1 -- Fursuit Details -->
<div class="space-y-8">
<div class="md:border-2 md:shadow md:bg-white md:rounded-lg md:p-8">
<div class="mb-8 ">
<h2 class="text-lg font-semibold">Your Eurofurence Fursuit Badge</h2>
<p>Please enter the Information below, this will be displayed on your Fursuit Badge.</p>
</div>
<div class="flex flex-col md:flex-row gap-8 w-full">
<!-- Image -->
<div class="w-48 mx-auto shrink-0">
<div class="block md:flex gap-6 justify-center mb-1">
<div v-if="!previewImage" @click="imageModalOpen = true"
class="bg-primary-600 h-64 w-48 rounded-lg drop-shadow mx-auto md:mx-0 flex items-center justify-center cursor-pointer">
<div class="text-primary-100 text-center text-sm px-4">
Click/Tap here to upload a photo of your fursuit
</div>
</div>
<div v-else class="relative">
<div @click="imageModalOpen = true"
class="absolute top-0 right-0 h-64 w-48 z-50 rounded-lg duration-200 hover:bg-gray-900/50 text-center opacity-0 hover:opacity-100 flex flex-col justify-end items-center cursor-pointer">
<div class="text-white mb-2">Edit Image</div>
</div>
<img :src="previewImage" alt=""
class="h-64 w-48 rounded-lg drop-shadow mx-auto md:mx-0 block z-25">
</div>
</div>
<div class="text-center text-xs text-gray-500">
<div>Only jpg/png</div>
<div>Min 240x340px</div>
<div>Max 8 MB</div>
</div>
<InputError :error="form.errors.image"></InputError>
</div>
<!-- End Image -->
<div class="flex flex-col gap-6 grow">
<!-- Name -->
<div>
<div class="flex flex-col gap-2">
<label for="name">Fursuit Name</label>
<InputText class="w-full" id="name" v-model="form.name" aria-describedby="name-help"/>
<InputError :error="form.errors.name"></InputError>
<small id="name-help">Enter the name of the fursuit.</small>
</div>
</div>
<!-- End Name -->
<!-- Species (Primevue Dropdown editable) -->
<div>
<div class="flex flex-col gap-2">
<label for="species">Fursuit Species</label>
<Dropdown v-model="form.species" id="species" aria-describedby="species-help" editable
:options="species" optionLabel="name" optionValue="name"
placeholder="Select a Species"
class="w-full"/>
<InputError :error="form.errors.species"></InputError>
<small
id="species-help">Enter the species of the fursuit. You may select one of the existing ones or create a
<span
v-tooltip.bottom="'Woof, Woof! You found an Easteregg.'">mew</span> Species!</small>
</div>
</div>
<!-- End Species -->
</div>
</div>
</div>
<!-- End Fursuit Creator -->
<!-- Group 2 -- Options -->
<div class="grid lg:grid-cols-2 gap-6">
<!-- Catch Em All -->
<div>
<div>
<div class="flex flex-row gap-2">
<InputSwitch v-model="form.catchEmAll" id="catchEmAll" aria-describedby="catchEmAll-help"/>
<label for="catchEmAll">Participate in the Catch-Em-All Game</label>
</div>
<small
id="catchEmAll-help">Participate in the Catch-Em-All game to be catchable by other attendees.</small>
</div>
</div>
<!-- Catch Em All -->
<!-- Publish -->
<div>
<div>
<div class="flex flex-row gap-2">
<InputSwitch v-model="form.publish" id="publish" aria-describedby="publish-help"/>
<label for="publish">Publish to Gallery</label>
</div>
<small
id="publish-help">Save your Fursuit Data and Publish your badge information in our Fursuiter gallery.</small>
</div>
</div>
<!-- End Publish -->
</div>
<!-- End Group 2 -->
<!-- Paid Extras -->
<div>
<div class="">
<div class="mb-8 ">
<h2 class="text-lg font-semibold">Upgrades</h2>
<p>Get a spare copy or get an exclusive double printed badge!</p>
</div>
<div class="space-y-3">
<div class="flex flex-col md:flex-row gap-8 w-full">
<div class="flex gap-3">
<div class="flex flex-row gap-2 mt-3">
<InputSwitch v-model="form.upgrades.doubleSided" id="extra1"
aria-describedby="extra1-help"/>
</div>
<div>
<label class="font-semibold block" for="extra1">Double Sided Badge
<Tag value="+1,00 €"></Tag>
</label>
<small
id="extra1-help">By default our Badges are only Printed on one side. If you want to have a double sided badge, please select this option.</small>
</div>
</div>
</div>
<div class="flex flex-col md:flex-row gap-8 w-full">
<div class="flex gap-3">
<div class="flex flex-row gap-2 mt-3">
<InputSwitch v-model="form.upgrades.spareCopy" id="extra2"
aria-describedby="extra2-help"/>
</div>
<div>
<label class="font-semibold block" for="extra2">Spare Copy
<Tag value="+2,00 €"></Tag>
</label>
<small
id="extra2-help">Get a spare copy of your badge. This is useful if you want to have a backup or if you want to give it to a friend.</small>
</div>
</div>
</div>
</div>
</div>
<!-- End Paid Extras -->
</div>
<Panel header="Checkout">
<template #header>
<div class="flex items-center gap-2">
<i class="pi pi-shopping-cart"></i>
<span class="font-semibold">Checkout</span>
</div>
</template>
<div class="flex flex-col gap-4">
<div class="mx-auto">
<!-- tOS Checkbox -->
<div class="flex items-center gap-2 mx-auto">
<div>
<InputSwitch v-model="form.tos" id="tos" aria-describedby="tos-help"/>
</div>
<label :class="{'text-red-500 font-bold': form.errors.tos}"
for="tos">I confirm that the Information that I have supplied is correct.</label>
</div>
<InputError class="mx-auto" :error="form.errors.tos"></InputError>
</div>
<!-- Total -->
<div class="max-w-sm w-full mx-auto space-y-2">
<div>
<!-- Options -->
<div class="flex justify-between border-b border-dotted border-gray-900">
<span>Base Price</span>
<span>{{ basePrice }},00 €</span>
</div>
<!-- Options -->
<div v-if="latePrice > 0"
class="border-b border-dotted border-gray-900">
<div class="flex justify-between ">
<span>Late Fee</span>
<span>{{ latePrice }},00 €</span>
</div>
<small>Orders placed after the Preorder Deadline will be charged a late fee.</small>
</div>
<div v-if="form.upgrades.doubleSided"
class="flex justify-between border-b border-dotted border-gray-900">
<span>Double Sided Badge</span>
<span>1,00 €</span>
</div>
<div v-if="form.upgrades.spareCopy"
class="flex justify-between mb-4 border-b border-dotted border-gray-900">
<span>Spare Copy</span>
<span>2,00 €</span>
</div>
<!-- End Options -->
<div class="flex justify-between text-2xl border-b border-double border-gray-900">
<span>Total</span>
<span>{{ total }},00 €</span>
</div>
</div>
<!-- Confirm Button -->
<Button label="Confirm Badge Order" icon="pi pi-check" @click="submit()"
:loading="form.processing" class="w-full"/>
</div>
</div>
</Panel>
</div>
</div>
</template>
<style scoped>
</style>