2020-12-20 13:50:12 +01:00
|
|
|
<style>
|
|
|
|
#form {
|
2020-12-25 10:03:50 +01:00
|
|
|
box-sizing: border-box;
|
2020-12-20 13:50:12 +01:00
|
|
|
flex: 1;
|
|
|
|
display: flex;
|
|
|
|
min-width: 300px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#form input {
|
|
|
|
margin: 5px;
|
|
|
|
}
|
2020-12-20 15:24:25 +01:00
|
|
|
|
|
|
|
input#url {
|
|
|
|
flex: 1;
|
|
|
|
font-size: 1rem;
|
|
|
|
}
|
2020-12-25 10:03:50 +01:00
|
|
|
|
|
|
|
.input--error {
|
|
|
|
border: 1px solid firebrick;
|
|
|
|
}
|
2020-12-20 13:50:12 +01:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<script>
|
2020-12-20 15:24:25 +01:00
|
|
|
import logger from '../services/logger'
|
2020-12-20 13:50:12 +01:00
|
|
|
|
2020-12-25 09:59:13 +01:00
|
|
|
export let error
|
|
|
|
export let pending
|
2020-12-25 13:19:49 +01:00
|
|
|
export let pendingRequest
|
2020-12-25 09:59:13 +01:00
|
|
|
|
2020-12-25 13:19:49 +01:00
|
|
|
let value = ''
|
|
|
|
$: value = error && pendingRequest && pendingRequest.url || ''
|
2020-12-25 10:15:28 +01:00
|
|
|
let form
|
2020-12-20 13:50:12 +01:00
|
|
|
|
2020-12-25 10:03:50 +01:00
|
|
|
let inputClasses = ''
|
|
|
|
$: inputClasses = [
|
|
|
|
error ? 'input--error' : '',
|
|
|
|
pending ? 'input--pending': '',
|
|
|
|
].join(' ')
|
|
|
|
|
2020-12-25 14:40:23 +01:00
|
|
|
const handleSubmit = async (e) => {
|
2020-12-25 10:15:28 +01:00
|
|
|
if (!form.reportValidity()) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-12-20 13:50:12 +01:00
|
|
|
e.preventDefault()
|
2020-12-25 12:35:40 +01:00
|
|
|
|
2020-12-25 14:40:23 +01:00
|
|
|
try {
|
|
|
|
const module = await import('../actions')
|
|
|
|
module.createEvent(value, { logger })
|
|
|
|
value = ''
|
|
|
|
} catch (importError) {
|
|
|
|
console.error(importError)
|
|
|
|
}
|
2020-12-25 13:19:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const handleChange = (e) => {
|
|
|
|
value = e.currentTarget.value
|
2020-12-20 13:50:12 +01:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2020-12-25 12:35:40 +01:00
|
|
|
<form id="form" on:submit={handleSubmit} bind:this={form}>
|
2020-12-20 13:50:12 +01:00
|
|
|
<input
|
|
|
|
required
|
2020-12-25 12:35:40 +01:00
|
|
|
pattern={String.raw`^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?|\d+$`}
|
2020-12-20 13:50:12 +01:00
|
|
|
id="url"
|
|
|
|
name="url"
|
2020-12-25 10:03:50 +01:00
|
|
|
class={inputClasses}
|
2020-12-25 09:59:13 +01:00
|
|
|
disabled={pending}
|
2020-12-20 13:50:12 +01:00
|
|
|
placeholder="Paste / type FB event URL or event number..."
|
|
|
|
title="Please insert Facebook Event URL / Number"
|
2020-12-25 13:19:49 +01:00
|
|
|
on:change={handleChange}
|
|
|
|
value={value}
|
2020-12-20 13:50:12 +01:00
|
|
|
/>
|
|
|
|
<input
|
|
|
|
id="submit"
|
2020-12-25 10:03:50 +01:00
|
|
|
class={inputClasses}
|
2020-12-20 13:50:12 +01:00
|
|
|
type='submit'
|
|
|
|
value='Submit'
|
2020-12-25 09:59:13 +01:00
|
|
|
disabled={pending}
|
2020-12-20 13:50:12 +01:00
|
|
|
on:click={handleSubmit}
|
|
|
|
/>
|
|
|
|
</form>
|