-
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.
Merge pull request #12 from mbgeorge48/local-storage
Local storage
- Loading branch information
Showing
16 changed files
with
679 additions
and
233 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ESLINT_NO_DEV_ERRORS=true |
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,29 +1,5 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:react-hooks/recommended", | ||
"react-app", | ||
"react-app/jest", | ||
], | ||
ignorePatterns: ["dist", ".eslintrc.cjs", "jest.config.ts"], | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["react"], | ||
extends: ["eslint:recommended", "plugin:react/recommended"], | ||
rules: { | ||
"react/react-in-jsx-scope": 0, | ||
"react/jsx-uses-react": 0, | ||
"react/no-unescaped-entities": 0, | ||
"no-undef": 0, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ["**/__helpers__/**", "**/*.test.*"], | ||
env: { | ||
jest: true, | ||
}, | ||
}, | ||
], | ||
rules: { "prettier/prettier": 0 }, | ||
extends: ["universe/web", "plugin:jsx-a11y/recommended"], | ||
}; |
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,62 @@ | ||
import { Field, Form, Formik } from "formik"; | ||
import { useState } from "react"; | ||
|
||
import { Timer } from "./types"; | ||
|
||
interface Props { | ||
timerData: Timer[]; | ||
} | ||
|
||
export function AdvancedMode(props: Props) { | ||
const [responseOk, setResponseOk] = useState<boolean>(false); | ||
const initialValues = { url: "" }; | ||
|
||
const handleSubmit = async (values: { url: string }) => { | ||
console.log({ values }); | ||
const response = await fetch(values.url, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(props.timerData), | ||
}); | ||
const responseSuccess = await response.ok; | ||
setResponseOk(responseSuccess); | ||
}; | ||
|
||
return ( | ||
<> | ||
<p> | ||
Experimental! Posts the form data to a URL so you can | ||
programmatically set timers | ||
</p> | ||
<p> | ||
Not aware of any endpoints that accept this data at the minute | ||
</p> | ||
<Formik initialValues={initialValues} onSubmit={handleSubmit}> | ||
{() => ( | ||
<Form className="grid"> | ||
<div className="field food-item"> | ||
<Field | ||
className="item border" | ||
name="url" | ||
type="url" | ||
placeholder="https://example.com/set-timers" | ||
pattern="https?://.*" | ||
size="30" | ||
required | ||
/> | ||
<label htmlFor="url"> | ||
URL you'd like to POST the data to | ||
</label> | ||
</div> | ||
<button type="submit" className="item"> | ||
Post! | ||
</button> | ||
{responseOk && <p>Success!</p>} | ||
</Form> | ||
)} | ||
</Formik> | ||
</> | ||
); | ||
} |
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.