-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: copied data from electron (#60)
* chore: copied data from electron * chore: added qr-code * fix: selector * chore: axios base query with retry; error handling; qr-code scan * chore: axios base query with retry; error handling; qr-code scan * chore: i18n; better bootstrap; redux persist
- Loading branch information
1 parent
8eaa773
commit befaccd
Showing
44 changed files
with
983 additions
and
211 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"action": { | ||
"scan": "Scan" | ||
}, | ||
"welcome": "Welcome to the Lynx-Scanner" | ||
} |
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,7 @@ | ||
{ | ||
"page": "Welcome to Lynx!", | ||
"description": "Please scan the QR Code for configuration", | ||
"dark": "Dark Mode", | ||
"light": "Light Mode", | ||
"valantine": "Valantine Mode" | ||
} |
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,16 +1,16 @@ | ||
import { JSX } from 'react'; | ||
import { RouterProvider } from 'react-router-dom'; | ||
import { router } from './router.tsx'; | ||
import { FloatingConfig } from './components/floating-config.tsx'; | ||
import { Notification } from '@components/notification.tsx'; | ||
|
||
/** | ||
* The main application component. | ||
*/ | ||
export function App(): JSX.Element { | ||
return ( | ||
<div className="mx-auto max-w-screen-lg"> | ||
<FloatingConfig /> | ||
<> | ||
<RouterProvider router={router} /> | ||
</div> | ||
<Notification /> | ||
</> | ||
); | ||
} |
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,19 @@ | ||
import { useCallback } from 'react'; | ||
import { Button } from 'react-daisyui'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
export default function ConfigScanButton() { | ||
const { t } = useTranslation(); | ||
const navigate = useNavigate(); | ||
const scanConfigAndPersist = useCallback( | ||
() => navigate('/config/scan'), | ||
[navigate] | ||
); | ||
|
||
return ( | ||
<Button fullWidth onClick={scanConfigAndPersist} color="primary"> | ||
{t('action.scan')} | ||
</Button> | ||
); | ||
} |
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,16 @@ | ||
import { useConfigData, useFetchConfigUrl } from '@store'; | ||
import { Loading } from 'react-daisyui'; | ||
import QRCode from 'react-qr-code'; | ||
import { useEffect } from 'react'; | ||
|
||
export default function ConfigQrCode() { | ||
const getUrl = useFetchConfigUrl(); | ||
const url = useConfigData(); | ||
useEffect(() => getUrl(), [getUrl]); | ||
return ( | ||
<figure> | ||
{!url && <Loading />} | ||
{url && <QRCode value={url} />} | ||
</figure> | ||
); | ||
} |
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,50 @@ | ||
import { Button } from 'react-daisyui'; | ||
import { ArrowLeft, Icon } from 'react-feather'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { ReactNode } from 'react'; | ||
|
||
interface HeaderProps { | ||
title: string; | ||
Icon?: Icon; | ||
onIconClick: () => void; | ||
back: false; | ||
} | ||
|
||
interface BackHeaderProps { | ||
title: string; | ||
back: string; | ||
} | ||
|
||
interface RawTrail { | ||
trailing?: ReactNode; | ||
} | ||
|
||
export function Header({ | ||
trailing, | ||
title, | ||
back, | ||
...rest | ||
}: RawTrail & (HeaderProps | BackHeaderProps)) { | ||
const nav = useNavigate(); | ||
const { Icon, onIconClick } = rest as HeaderProps; | ||
const navBack = () => { | ||
nav('..'); | ||
}; | ||
return ( | ||
<div className={`flex items-center ${back ? '' : 'justify-between'}`}> | ||
{back && ( | ||
<Button color="ghost" onClick={navBack} shape="circle"> | ||
<ArrowLeft /> | ||
</Button> | ||
)} | ||
<h1 className="text-2xl ml-2">{title}</h1> | ||
<div className="mx-auto" /> | ||
{!back && Icon && ( | ||
<Button color="ghost" onClick={onIconClick} shape="circle"> | ||
<Icon /> | ||
</Button> | ||
)} | ||
{trailing} | ||
</div> | ||
); | ||
} |
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,37 @@ | ||
import { | ||
selectNotification, | ||
removeNotification, | ||
useAppDispatch, | ||
useAppSelector, | ||
} from '@store'; | ||
import { Alert, Button, Toast } from 'react-daisyui'; | ||
import { useCallback } from 'react'; | ||
import { X } from 'react-feather'; | ||
|
||
export function Notification() { | ||
const notifications = useAppSelector(selectNotification); | ||
const dispatch = useAppDispatch(); | ||
const remove = useCallback( | ||
(id: string) => () => { | ||
dispatch(removeNotification(id)); | ||
}, | ||
[dispatch] | ||
); | ||
return ( | ||
<Toast horizontal="start" vertical="bottom"> | ||
{notifications.map((notification) => ( | ||
<Alert key={notification.id} status="error"> | ||
<Button | ||
onClick={remove(notification.id)} | ||
size="sm" | ||
color="ghost" | ||
shape="circle" | ||
> | ||
<X /> | ||
</Button> | ||
<span>{notification.message}</span> | ||
</Alert> | ||
))} | ||
</Toast> | ||
); | ||
} |
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 was deleted.
Oops, something went wrong.
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,16 @@ | ||
import { useCallback } from 'react'; | ||
import { Button } from 'react-daisyui'; | ||
import { ArrowRight } from 'react-feather'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export default function ToListScanButton() { | ||
const navigate = useNavigate(); | ||
const toScans = useCallback(() => navigate('/scans'), [navigate]); | ||
|
||
return ( | ||
<Button fullWidth color="primary" onClick={toScans}> | ||
<span>To Scans</span> | ||
<ArrowRight /> | ||
</Button> | ||
); | ||
} |
Oops, something went wrong.