mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-04 18:35:17 +02:00
Imporved logger
This commit is contained in:
parent
5ae4d6e7c4
commit
e3ed429da1
12 changed files with 89 additions and 55 deletions
|
@ -1,17 +1,28 @@
|
|||
import { useState, useEffect, ChangeEvent, FormEvent } from 'react';
|
||||
import axios from 'axios';
|
||||
|
||||
// Redux
|
||||
import { connect } from 'react-redux';
|
||||
import { createNotification } from '../../../store/actions';
|
||||
|
||||
// Typescript
|
||||
import { ApiResponse, NewNotification } from '../../../interfaces';
|
||||
|
||||
// UI
|
||||
import InputGroup from '../../UI/Forms/InputGroup/InputGroup';
|
||||
import Button from '../../UI/Buttons/Button/Button';
|
||||
import { ApiResponse } from '../../../interfaces';
|
||||
|
||||
const StyleSettings = (): JSX.Element => {
|
||||
interface ComponentProps {
|
||||
createNotification: (notification: NewNotification) => void;
|
||||
}
|
||||
|
||||
const StyleSettings = (props: ComponentProps): JSX.Element => {
|
||||
const [customStyles, setCustomStyles] = useState<string>('');
|
||||
|
||||
useEffect(() => {
|
||||
axios.get<ApiResponse<string>>('/api/config/0/css')
|
||||
.then(data => setCustomStyles(data.data.data))
|
||||
.catch(err => console.log(err));
|
||||
.catch(err => console.log(err.response));
|
||||
}, [])
|
||||
|
||||
const inputChangeHandler = (e: ChangeEvent<HTMLTextAreaElement>) => {
|
||||
|
@ -22,7 +33,14 @@ const StyleSettings = (): JSX.Element => {
|
|||
const formSubmitHandler = (e: FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
axios.put<ApiResponse<{}>>('/api/config/0/css', { styles: customStyles });
|
||||
axios.put<ApiResponse<{}>>('/api/config/0/css', { styles: customStyles })
|
||||
.then(() => {
|
||||
props.createNotification({
|
||||
title: 'Success',
|
||||
message: 'CSS saved. Reload page to see changes'
|
||||
})
|
||||
})
|
||||
.catch(err => console.log(err.response));
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -34,6 +52,7 @@ const StyleSettings = (): JSX.Element => {
|
|||
name='customStyles'
|
||||
value={customStyles}
|
||||
onChange={(e) => inputChangeHandler(e)}
|
||||
spellCheck={false}
|
||||
></textarea>
|
||||
</InputGroup>
|
||||
<Button>Save CSS</Button>
|
||||
|
@ -41,4 +60,4 @@ const StyleSettings = (): JSX.Element => {
|
|||
)
|
||||
}
|
||||
|
||||
export default StyleSettings;
|
||||
export default connect(null, { createNotification })(StyleSettings);
|
Loading…
Add table
Add a link
Reference in a new issue