datocms-plugin-netlify-forms 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Netlify forms
1
+ # Netlify forms management for DatoCMS
2
2
 
3
3
  Plugin that allows DatoCMS show and manage Netlify form submissions
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datocms-plugin-netlify-forms",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Plugin that allows DatoCMS show and manage Netlify form submissions",
5
5
  "homepage": "https://github.com/gempi/datocms-plugin-netlify-forms#readme",
6
6
  "author": "Matthias Gemperli <hello@matthiasgemperli.ch>",
@@ -22,8 +22,8 @@ export type ValidParameters = {
22
22
  type Parameters = ValidParameters;
23
23
 
24
24
  export default function ConfigScreen({ ctx }: PropTypes) {
25
- const accessToken = ctx.plugin.attributes.parameters.accessToken;
26
- const site = ctx.plugin.attributes.parameters.site;
25
+ const parameters = ctx.plugin.attributes.parameters;
26
+ const accessToken = parameters.accessToken;
27
27
  const [sites, setSites] = useState([]);
28
28
 
29
29
  useEffect(() => {
@@ -65,6 +65,10 @@ export default function ConfigScreen({ ctx }: PropTypes) {
65
65
  return errors;
66
66
  }}
67
67
  onSubmit={async (values) => {
68
+ if (values.accessToken !== accessToken) {
69
+ setSites([]);
70
+ }
71
+
68
72
  await ctx.updatePluginParameters(values);
69
73
  ctx.notice("Settings updated successfully!");
70
74
  }}
@@ -97,7 +101,7 @@ export default function ConfigScreen({ ctx }: PropTypes) {
97
101
  )}
98
102
  </Field>
99
103
 
100
- {site || sites.length > 0 ? (
104
+ {sites.length > 0 ? (
101
105
  <Field name="site">
102
106
  {({ input, meta: { error } }) => (
103
107
  <SelectField
@@ -29,6 +29,8 @@ export default function SubmissionsPage({ ctx }: PropTypes) {
29
29
  }
30
30
  );
31
31
 
32
+ setLoading(false);
33
+
32
34
  if (!response.ok) {
33
35
  const message = `An error has occured: ${response.status}`;
34
36
  ctx.alert(message);
@@ -36,7 +38,6 @@ export default function SubmissionsPage({ ctx }: PropTypes) {
36
38
 
37
39
  const forms = await response.json();
38
40
  setSubmissions(forms);
39
- setLoading(false);
40
41
  };
41
42
 
42
43
  getSubmissions();