-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* temp: event parameters * feat: dinamic tabs * feat: saving settings * fix: a lot of things * fix: a lot of things * fix: a lot of things Co-authored-by: Andre Gava <andrelzgava@gmail.com>
- Loading branch information
1 parent
75354c9
commit e9c5b79
Showing
40 changed files
with
1,628 additions
and
446 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React, { ReactElement } from 'react'; | ||
import { useBarcode, BarcodeProps } from '../../hooks/useBarcode'; | ||
|
||
export default function Barcode(props: BarcodeProps): ReactElement { | ||
const { value, options } = props; | ||
const { inputRef } = useBarcode({ | ||
value, | ||
options, | ||
}); | ||
|
||
return <svg ref={inputRef} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,111 @@ | ||
import React from 'react'; | ||
import React, { useCallback, useEffect, useState } from 'react'; | ||
import { FiSave } from 'react-icons/fi'; | ||
import { useToast } from '../../hooks/toast'; | ||
import i18n from '../../i18n'; | ||
import Button from '../Button'; | ||
import Input from '../Input'; | ||
import { ButtonContainer, Container } from './styles'; | ||
interface Settings { | ||
id?: number; | ||
daysReturnDate: string; | ||
backupPath: string; | ||
} | ||
const Settings: React.FC = () => { | ||
const { addToast } = useToast(); | ||
|
||
import { Container } from './styles'; | ||
const [settings, setSettings] = useState(null); | ||
const [daysReturnDate, setDaysReturnDate] = useState('7'); | ||
const [backupPath, setBackupPath] = useState(''); | ||
|
||
useEffect(() => { | ||
const result = window.api.sendSync('list', { | ||
entity: 'Settings', | ||
value: {}, | ||
}) as Settings[]; | ||
|
||
if (result.length > 0) { | ||
setSettings(result[0]); | ||
setDaysReturnDate(result[0].daysReturnDate); | ||
setBackupPath(result[0].backupPath); | ||
return; | ||
} | ||
}, []); | ||
|
||
const handleSave = useCallback(() => { | ||
const result = window.api.sendSync(settings.id ? 'update' : 'create', { | ||
entity: 'Settings', | ||
value: settings.id | ||
? { | ||
id: settings.id, | ||
daysReturnDate: daysReturnDate, | ||
backupPath: backupPath, | ||
} | ||
: { | ||
daysReturnDate: daysReturnDate, | ||
backupPath: backupPath, | ||
}, | ||
}) as { id: string }; | ||
|
||
addToast({ | ||
title: i18n.t('notifications.success'), | ||
type: 'success', | ||
description: i18n.t('settings.saved'), | ||
}); | ||
|
||
return; | ||
}, [backupPath, daysReturnDate, settings]); | ||
|
||
const Settings: React.FC = () => { | ||
return ( | ||
<Container> | ||
Settings | ||
<> | ||
<div | ||
style={{ | ||
padding: '24px', | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
}} | ||
> | ||
<Input | ||
containerStyle={{ marginRight: '18px' }} | ||
type="number" | ||
name="daysReturnDate" | ||
label={i18n.t('settings.time')} | ||
autoFocus | ||
onChange={(e) => setDaysReturnDate(e.target.value)} | ||
value={daysReturnDate} | ||
placeholder={i18n.t('settings.time')} | ||
/> | ||
|
||
<Input | ||
directory="" | ||
webkitdirectory="" | ||
type="file" | ||
name="path" | ||
label={i18n.t('settings.path')} | ||
value={backupPath} | ||
onChange={(e) => setBackupPath(e.target.value)} | ||
placeholder={i18n.t('settings.path')} | ||
/> | ||
</div> | ||
|
||
<ButtonContainer> | ||
<Button | ||
color="primary" | ||
title={i18n.t('button.save')} | ||
onClick={handleSave} | ||
> | ||
<FiSave size={20} /> | ||
</Button> | ||
</ButtonContainer> | ||
</> | ||
</Container> | ||
); | ||
}; | ||
|
||
declare module 'react' { | ||
interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> { | ||
directory?: string; | ||
webkitdirectory?: string; | ||
} | ||
} | ||
export default Settings; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,63 @@ | ||
import styled from 'styled-components'; | ||
import { shade, tint } from 'polished'; | ||
import styled, { css } from 'styled-components'; | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
width: 100vw; | ||
`; | ||
|
||
export const ButtonContainer = styled.div` | ||
position: relative,; | ||
padding: 0 24px; | ||
display: flex; | ||
justify-content: end; | ||
`; | ||
|
||
export const List = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
`; | ||
|
||
export const ListItem = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
border-radius: 8px; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 12px; | ||
margin-bottom: 4px; | ||
width: 100%; | ||
background-color: ${props => tint(0.2, props.theme.colors.background)}; | ||
&:hover { | ||
background-color: ${props => tint(0.25, props.theme.colors.background)}; | ||
${(props) => props.theme.title == 'light' && css` | ||
background-color: ${(props) => shade(0.05, props.theme.colors.background)}; | ||
`} | ||
} | ||
svg { | ||
cursor: pointer; | ||
&:hover { | ||
color: ${props => tint(0.2, props.theme.colors.secondary.dark)} | ||
} | ||
} | ||
`; | ||
|
||
export const Row = styled.div` | ||
padding: 24px 0 24px 0; | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: space-between; | ||
flex-wrap: wrap; | ||
width: 100%; | ||
`; | ||
|
||
export const Column = styled.div` | ||
display: flex; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.