Starting to implement subscriptions.

This commit is contained in:
Eric van der Vlist 2023-02-27 19:28:18 +01:00
parent 0dde189741
commit 9f396a167a
1 changed files with 97 additions and 102 deletions

View File

@ -1,5 +1,5 @@
import { createForm } from '@felte/solid';
import { Component, Index, Match, onMount, Switch } from 'solid-js';
import { Component, Index, Match, onMount, Show, Switch } from 'solid-js';
import { TextField, Button } from '@kobalte/core';
import reporter from '@felte/reporter-tippy';
import './style.css';
@ -130,7 +130,8 @@ const User: Component<Props> = (props) => {
}
function addSubscription(index?: number) {
return () => addField(`subscriptions`, { user: '', direction: '' }, index);
return () =>
addField(`subscriptions`, { username: '', direction: '' }, index);
}
console.log({
@ -141,6 +142,10 @@ const User: Component<Props> = (props) => {
});
return (
<>
<Show when={!isNew()}>
<h2>{userId(data('username'), data('database'))}</h2>
</Show>
<form use:form>
<TextField.Root>
<TextField.Label>Mail address</TextField.Label>
@ -192,8 +197,7 @@ const User: Component<Props> = (props) => {
+
</button>
</th>
<th>User</th>
<th>Direction</th>
<th>User name</th>
</tr>
</thead>
<tbody>
@ -209,19 +213,9 @@ const User: Component<Props> = (props) => {
<TextField.Root>
<TextField.Input
type='text'
name={`subscriptions.${index}.user`}
name={`subscriptions.${index}.username`}
required={true}
placeholder='user'
/>
</TextField.Root>
</td>
<td>
<TextField.Root>
<TextField.Input
type='text'
name={`subscriptions.${index}.direction`}
required={true}
placeholder='direction'
placeholder='user name'
/>
</TextField.Root>
</td>
@ -241,6 +235,7 @@ const User: Component<Props> = (props) => {
</Switch>
<Button.Root onclick={cancelHandler}>Cancel</Button.Root>
</form>
</>
);
};