Init work with making field required

This commit is contained in:
Ibitoye Rotimi Best
2021-07-26 07:49:05 +03:00
parent 950653d669
commit 2e596cd6fb
4 changed files with 30 additions and 7 deletions
+7 -2
View File
@@ -2,12 +2,17 @@
export let label;
export let value;
export let options = [];
export let valueKey = "id";
export let valueKey = 'id';
export let isRequired = false;
</script>
<label class="block">
{#if label} <span class="text-gray-700">{label}</span> {/if}
<select bind:value class="form-select block w-full mt-1">
<select
bind:value
class="form-select block w-full mt-1"
required={isRequired}
>
{#each options as option}
<option value={option[valueKey]}>
{option.text}
+7 -1
View File
@@ -8,11 +8,16 @@
export let inputClassName = '';
export let type = 'text';
export let autoFocus = false;
export let isRequired = false;
let ref = null;
let ref;
function typeAction(node) {
node.type = type;
if (isRequired) {
node.required = '';
}
}
afterUpdate(() => {
@@ -31,5 +36,6 @@
{placeholder}
bind:value
bind:this={ref}
required={true}
/>
</label>
+14 -3
View File
@@ -2,6 +2,7 @@
import TextField from '../components/Form/TextField.svelte';
import Select from '../components/Form/Select.svelte';
import PrimaryButton from '../components/PrimaryButton/index.svelte';
import { supabase } from '../utils/functions/supabase';
let email;
let userType = 0;
@@ -20,9 +21,17 @@
value: 2,
},
];
function handleSubmit() {
console.log(`email`, email);
async function handleSubmit() {
try {
loading = true;
const { error } = await supabase.auth.signIn({ email });
if (error) throw error;
alert('Check your email for the login link!');
} catch (error) {
alert(error.error_description || error.message);
} finally {
loading = false;
}
}
</script>
@@ -52,6 +61,7 @@
bind:value={userType}
options={userTypes}
valueKey="value"
isRequired={true}
/>
</div>
@@ -64,6 +74,7 @@
placeholder="Enter your email"
onKeyDown={handleSubmit}
inputClassName="rounded-md w-full px-2 py-4"
isRequired={true}
/>
<p class="py-3 text-sm">
A magic link will be sent to your email, please open the link
+2 -1
View File
@@ -1,6 +1,7 @@
import { createClient } from '@supabase/supabase-js';
import config from '../../config';
import getConfig from '../../config';
const config = getConfig();
export const supabase = createClient(
config.supabaseConfig.url,