From aa306702a346342814ec594aa23f98277360680d Mon Sep 17 00:00:00 2001 From: Benjamin ratelade Date: Sun, 5 Sep 2021 15:20:23 +1000 Subject: [PATCH 1/6] [Round Trip Data] A start on importing user data via CSV Created a test for data upload. Some changes to the html for the Stats page, to allow for better targeting in tests. Added an ugly upload button to Home.js Created a support class for handling CSV uploads (and downloads, later). Also created a sample csv file, which really ought to be replaced with some Factory. --- app/javascript/react/pages/Home/Home.js | 72 +++++++++++++++-------- app/javascript/react/pages/Stats/Stats.js | 4 +- app/services/csv_import_export.rb | 58 ++++++++++++++++++ config/initializers/devise.rb | 2 +- spec/features/user_uploads_own_data.rb | 64 ++++++++++++++++++++ spec/support/csv_sample.csv | 11 ++++ 6 files changed, 182 insertions(+), 29 deletions(-) create mode 100644 app/services/csv_import_export.rb create mode 100644 spec/features/user_uploads_own_data.rb create mode 100644 spec/support/csv_sample.csv diff --git a/app/javascript/react/pages/Home/Home.js b/app/javascript/react/pages/Home/Home.js index c83291f..5ff4394 100644 --- a/app/javascript/react/pages/Home/Home.js +++ b/app/javascript/react/pages/Home/Home.js @@ -44,32 +44,52 @@ const Home = () => { return (

Are you sweating enough?

- - {display && ( - <> -
- setDate(newDate)} - focused={focus} - onFocusChange={({ focused }) => setFocus(focused)} - id="date" - /> -
- - - )} +
+
+ + {display && ( + <> +
+ setDate(newDate)} + focused={focus} + onFocusChange={({ focused }) => setFocus(focused)} + id="date" + /> +
+ + + )} +
+
+
+
+ + + +
+
); }; diff --git a/app/javascript/react/pages/Stats/Stats.js b/app/javascript/react/pages/Stats/Stats.js index b08f97f..602c377 100644 --- a/app/javascript/react/pages/Stats/Stats.js +++ b/app/javascript/react/pages/Stats/Stats.js @@ -19,7 +19,7 @@ const Stats = () => { if (error) return

{`Error! ${error.message}`}

; return ( -