Skip to content

Commit

Permalink
add ability to reset to default config
Browse files Browse the repository at this point in the history
  • Loading branch information
tytremblay committed Jan 11, 2024
1 parent bd36e68 commit a00c205
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
58 changes: 31 additions & 27 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Button, { Variant } from './components/core/Button';
import {
getQRCodeData,
resetSections,
resetToDefaultConfig,
uploadConfig,
useQRScoutState,
} from './store/store';
Expand Down Expand Up @@ -102,10 +103,9 @@ export function App() {
Reset
</button>
</div>
<div className="mb-4 flex flex-col justify-center rounded bg-white shadow-md dark:bg-gray-600">
<div className="mb-4 flex flex-col justify-center rounded bg-white shadow-md dark:bg-gray-600 gap-2 p-2">
<Button
variant={Variant.Secondary}
className="m-2"
onClick={() =>
navigator.clipboard.writeText(
formData.sections
Expand All @@ -120,12 +120,11 @@ export function App() {
</Button>
<Button
variant={Variant.Secondary}
className="m-2"
onClick={() => downloadConfig()}
>
Download Config
</Button>
<label className="m-2 flex cursor-pointer flex-row justify-center rounded bg-gray-500 py-2 text-center font-bold text-white shadow-sm hover:bg-gray-600">
<label className="mx-2 flex cursor-pointer flex-row justify-center rounded bg-gray-500 py-2 text-center font-bold text-white shadow-sm hover:bg-gray-600">
<span className="text-base leading-normal">Upload Config</span>
<input
type="file"
Expand All @@ -134,30 +133,35 @@ export function App() {
onChange={e => uploadConfig(e)}
/>
</label>
{
<div className="m-2 flex flex-col justify-start bg-gray-500 p-2">
<div className="rounded-t pb-2 text-left font-bold text-white">
Theme
</div>
<select
className="rounded bg-white px-4 py-2 dark:bg-gray-700 dark:text-white"
name="Theme"
id="theme"
onInput={v => setTheme(v.currentTarget.value)}
value={theme}
>
<option key={'system'} value={'system'}>
System
</option>
<option key={'dark'} value={'dark'}>
Dark
</option>
<option key={'light'} value={'light'}>
Light
</option>
</select>
<div className="mx-2 flex flex-col justify-start bg-gray-500 p-2 rounded">
<div className="rounded-t pb-2 text-left font-bold text-white">
Theme
</div>
}
<select
className="rounded bg-white px-4 py-2 dark:bg-gray-700 dark:text-white"
name="Theme"
id="theme"
onInput={v => setTheme(v.currentTarget.value)}
value={theme}
>
<option key={'system'} value={'system'}>
System
</option>
<option key={'dark'} value={'dark'}>
Dark
</option>
<option key={'light'} value={'light'}>
Light
</option>
</select>
</div>

<Button
variant={Variant.Secondary}
onClick={() => resetToDefaultConfig()}
>
Reset To Default Config
</Button>
</div>
</div>
</form>
Expand Down
4 changes: 4 additions & 0 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export const useQRScoutState = createStore<QRScoutState>(
},
);

export function resetToDefaultConfig() {
useQRScoutState.setState(initialState);
}

export function updateValue(sectionName: string, code: string, data: any) {
useQRScoutState.setState(
produce((state: QRScoutState) => {
Expand Down

0 comments on commit a00c205

Please sign in to comment.