This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
generated from ost-cas-fee-adv-22-23/cas-fee-adv-design-system-tpl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.tsx
103 lines (94 loc) · 3.07 KB
/
index.tsx
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
import React, { useEffect, useMemo, useState } from 'react';
import Navi from './includes/navi';
import { TextBox, Heading, Container, UploadForm } from '@smartive-education/design-system-component-library-yeahyeahyeah';
import debounce from 'lodash.debounce';
import { FileRejection } from 'react-dropzone';
export default function Timeline() {
const [posts, setPosts] = useState(['']);
const [inputValue, setInputValue] = useState<string>('');
const [errorMessage, setErrorMessage] = useState<string>('');
const [showModal, setShowModal] = useState(false);
const [fileUploadError, setFileUploadError] = useState('');
const setTimerForError = () =>
setTimeout(() => {
setFileUploadError('');
}, 2000);
const onDropCallBack = (acceptedFiles: File[], fileRejections: FileRejection[]) => {
console.log('acceptedFiles, fileRejections', acceptedFiles, fileRejections);
fileRejections?.length && setFileUploadError(fileRejections[0].errors[0].message);
setTimerForError();
};
const setErrorDebounced = useMemo(
() =>
debounce(() => {
setErrorMessage('');
}, 100),
[debounce]
);
useEffect(() => {
if (inputValue !== '') {
setErrorDebounced();
}
}, [inputValue, setErrorDebounced]);
const addText = () => {
if (inputValue === '') {
setErrorMessage('Bitte füllen Sie das Feld aus.');
return;
}
if (posts[0] === '') {
setPosts([inputValue]);
setInputValue('');
return;
}
setPosts([...posts, inputValue]);
setInputValue('');
};
const handleUpload = () => {
setShowModal(true);
};
return (
<>
<UploadForm
onDropCallBack={onDropCallBack}
showModal={showModal}
setShowModal={setShowModal}
fileUploadError={fileUploadError}
/>
<div tw="flex flex-col justify-center items-center bg-slate-200 w-full h-full pb-64">
<Navi />
<Container layout="plain">
<Heading label="Willkommen auf Mumble" color="violet" tag="h2" size="default" mbSpacing="32" />
<Heading
label="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna."
color="light"
tag="h4"
size="default"
mbSpacing="32"
/>
</Container>
<Container layout="plain">
<div tw="mb-32">
<TextBox
variant="write"
user={{
label: 'Hey, was läuft?',
avatar: {
src: 'https://media.giphy.com/media/cfuL5gqFDreXxkWQ4o/giphy.gif',
alt: 'Family Guy goes Mumble',
},
}}
form={{
errorMessage: errorMessage,
placeholder: 'Hast du uns etwas mitzuteilen?',
}}
setInputValue={setInputValue}
inputValue={inputValue}
sendCallback={addText}
uploadCallback={handleUpload}
/>
</div>
</Container>
</div>
</>
);
}