Moving on implementing invitations
This commit is contained in:
parent
5ad98a860e
commit
04cd163906
|
@ -1,4 +1,6 @@
|
||||||
import { Component, createSignal } from 'solid-js';
|
import { Box, Button, TextField } from '@suid/material';
|
||||||
|
import { Component, createEffect, createSignal, Show } from 'solid-js';
|
||||||
|
import Dialog from '../dialog';
|
||||||
|
|
||||||
interface props {}
|
interface props {}
|
||||||
|
|
||||||
|
@ -13,12 +15,16 @@ export const searchInvitation = () => {
|
||||||
const payload = hash.slice(1);
|
const payload = hash.slice(1);
|
||||||
const decoded = atob(payload);
|
const decoded = atob(payload);
|
||||||
const url = new URL(decoded);
|
const url = new URL(decoded);
|
||||||
setInvitation(url);
|
fetch(url)
|
||||||
console.log({
|
.then((response) => response.json())
|
||||||
caller: 'Invitation / searchInvitation',
|
.then((data) => {
|
||||||
hash,
|
setInvitation({ url, data });
|
||||||
invitation: decoded,
|
console.log({
|
||||||
});
|
caller: 'Invitation / searchInvitation',
|
||||||
|
hash,
|
||||||
|
invitation: invitation(),
|
||||||
|
});
|
||||||
|
});
|
||||||
} catch {
|
} catch {
|
||||||
console.warn({
|
console.warn({
|
||||||
caller: 'Invitation / searchInvitation',
|
caller: 'Invitation / searchInvitation',
|
||||||
|
@ -30,7 +36,62 @@ export const searchInvitation = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const Invitation: Component<props> = (props) => {
|
const Invitation: Component<props> = (props) => {
|
||||||
return <></>;
|
createEffect(() => {
|
||||||
|
console.log({
|
||||||
|
caller: 'Invitation / createEffect',
|
||||||
|
invitation: invitation(),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const closeHandler = () => {};
|
||||||
|
const submitHandler = async () => {
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
`${invitation().url.href}/${invitation().code}`
|
||||||
|
);
|
||||||
|
const codeData = await response.json();
|
||||||
|
setInvitation({ ...invitation(), codeData });
|
||||||
|
} catch (error) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
const codeChangeHandler = (event: any) => {
|
||||||
|
setInvitation({ ...invitation(), code: event.target.value });
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open={!!invitation()}
|
||||||
|
fullScreen={false}
|
||||||
|
closeHandler={closeHandler}
|
||||||
|
title='Invitation'
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
component='form'
|
||||||
|
sx={{
|
||||||
|
width: '100%',
|
||||||
|
'& .MuiTextField-root': { m: 1, width: '100%' },
|
||||||
|
paddingTop: '5px',
|
||||||
|
}}
|
||||||
|
noValidate
|
||||||
|
autoComplete='off'
|
||||||
|
>
|
||||||
|
<p>
|
||||||
|
Pour configurer cette application en tant que "{invitation().data.id}
|
||||||
|
", copier le code qui vous a été envoyé par mail à l'adresse "
|
||||||
|
{invitation().data.mail}" :{' '}
|
||||||
|
</p>
|
||||||
|
<TextField
|
||||||
|
required
|
||||||
|
label='Code'
|
||||||
|
type='number'
|
||||||
|
onChange={codeChangeHandler}
|
||||||
|
/>
|
||||||
|
<Button variant='contained' onClick={submitHandler}>
|
||||||
|
OK
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Invitation;
|
export default Invitation;
|
||||||
|
|
|
@ -46,7 +46,7 @@ import { Overlays } from '../overlays/Overlays';
|
||||||
import Finder, { findLocation } from '../finder';
|
import Finder, { findLocation } from '../finder';
|
||||||
import { ZoomIn } from '@suid/icons-material';
|
import { ZoomIn } from '@suid/icons-material';
|
||||||
import Note from '../note';
|
import Note from '../note';
|
||||||
import { searchInvitation } from '../invitation';
|
import Invitation, { searchInvitation } from '../invitation';
|
||||||
|
|
||||||
const [getState, setState] = createSignal({
|
const [getState, setState] = createSignal({
|
||||||
lon: 0,
|
lon: 0,
|
||||||
|
@ -294,6 +294,7 @@ const Map: Component = () => {
|
||||||
//<OsmFetch map={getMap} />
|
//<OsmFetch map={getMap} />
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
<div class='ol-map' ref={target}>
|
<div class='ol-map' ref={target}>
|
||||||
|
<Invitation />
|
||||||
<Overlays map={getMap} />
|
<Overlays map={getMap} />
|
||||||
<Note />
|
<Note />
|
||||||
<Finder />
|
<Finder />
|
||||||
|
|
Loading…
Reference in New Issue