diff --git a/app/javascript/src/components/PatientDashboardForm.jsx b/app/javascript/src/components/PatientDashboardForm.jsx index 7ad778743..ab6873423 100644 --- a/app/javascript/src/components/PatientDashboardForm.jsx +++ b/app/javascript/src/components/PatientDashboardForm.jsx @@ -26,7 +26,6 @@ export default PatientDashboardForm = ({ const autosave = async (updatedData) => { const updatedPatientData = { ...patientData, ...updatedData } - setPatientData(updatedPatientData) const putData = { name: updatedPatientData.name, @@ -44,9 +43,9 @@ export default PatientDashboardForm = ({ } } - const debouncedAutosave = useMemo((params) => { - return debounce(autosave, 300) - }, []); + const debouncedAutosave = (params) => { + return debounce(autosave(params), 300) + }; // Stop the invocation of the debounced function after unmounting useEffect(() => { @@ -131,6 +130,7 @@ export default PatientDashboardForm = ({ label={i18n.t('patient.shared.status')} value={patientData.status} className="form-control-plaintext" + disabled="true" tooltip={statusTooltip} onChange={e => debouncedAutosave({ status: e.target.value })} /> diff --git a/app/views/patients/_patient_dashboard.html.erb b/app/views/patients/_patient_dashboard.html.erb index 32145efcd..62d24ec82 100644 --- a/app/views/patients/_patient_dashboard.html.erb +++ b/app/views/patients/_patient_dashboard.html.erb @@ -1,77 +1,12 @@
- <%= bootstrap_form_with model: patient, - html: { id: 'patient_dashboard_form' }, - local: false, - method: 'patch', - class: 'edit_patient' do |f| %> -
- -
- <%= f.text_field :name, - label: t('patient.shared.name'), - autocomplete: 'off' %> -
- -
- <%= f.select :last_menstrual_period_weeks, - options_for_select(weeks_options, patient.last_menstrual_period_weeks ), - label: t('patient.dashboard.weeks_along'), - autocomplete: 'off', - help: t('patient.dashboard.currently', weeks: patient.last_menstrual_period_now_weeks, days: patient.last_menstrual_period_now_days) %> -
- -
- <%= f.select :last_menstrual_period_days, - options_for_select(days_options, patient.last_menstrual_period_days), - autocomplete: 'off', - skip_label: true, - help: t('patient.dashboard.called_on', date: patient.initial_call_date.strftime("%m/%d/%Y")) %> - <%= f.label :last_menstrual_period_days, t('common.days_along'), class: "sr-only" %> -
- -
- <%= f.date_field :appointment_date, - label: t('patient.shared.appt_date'), - autocomplete: 'off', - help: t('patient.dashboard.approx_gestation', weeks: patient.last_menstrual_period_at_appt_weeks, days: patient.last_menstrual_period_at_appt_days) %> -
-
- -
-
- <%= f.text_field :primary_phone, - value: patient.primary_phone_display, - label: t('patient.dashboard.phone'), - autocomplete: 'off' %> -
- -
- <%= f.text_field :pronouns, - value: patient.pronouns, - autocomplete: 'off' %> -
- -
-
- - -
-
- -
- <% if current_user.admin? %> -
- -
- <%= link_to t('patient.dashboard.delete'), - patient_path(patient), - class: 'btn btn-danger', - method: :delete, - data: { confirm: t('patient.dashboard.confirm_del', name: patient.name) } %> -
-
- <% end %> -
-
- <% end %> -
+ <%= render ReactComponent.new("PatientDashboardForm", raw_props: { + patient: patient.as_json, + weeksOptions: weeks_options.map { |opt| { label: opt[0], value: opt[1] } }, + daysOptions: days_options.map { |opt| { label: opt[0], value: opt[1] } }, + initialCallDate: patient.initial_call_date.strftime("%m/%d/%Y"), + statusHelpText: status_help_text(patient), + isAdmin: current_user.admin?, + patientPath: patient_path(patient), + formAuthenticityToken: form_authenticity_token + }) %> + \ No newline at end of file diff --git a/test/system/update_patient_info_test.rb b/test/system/update_patient_info_test.rb index 83aafb238..41be20983 100644 --- a/test/system/update_patient_info_test.rb +++ b/test/system/update_patient_info_test.rb @@ -28,7 +28,6 @@ class UpdatePatientInfoTest < ApplicationSystemTestCase describe 'updating name' do before do fill_in 'First and last name', with: 'Susie Everyteen 2' - click_away_from_field wait_for_ajax reload_page_and_click_link 'Patient Information' end @@ -75,7 +74,6 @@ class UpdatePatientInfoTest < ApplicationSystemTestCase describe 'updating appointment date' do before do fill_in 'Appointment date', with: 5.days.from_now.strftime('%m/%d/%Y') - click_away_from_field wait_for_ajax reload_page_and_click_link 'Patient Information' end @@ -108,7 +106,6 @@ class UpdatePatientInfoTest < ApplicationSystemTestCase describe 'updating phone number' do before do fill_in 'Phone number', with: '123-666-8888' - click_away_from_field wait_for_ajax reload_page_and_click_link 'Patient Information' end @@ -123,7 +120,6 @@ class UpdatePatientInfoTest < ApplicationSystemTestCase describe 'updating pronouns' do before do fill_in 'Pronouns', with: 'they/them' - click_away_from_field wait_for_ajax reload_page_and_click_link 'Patient Information' end @@ -298,7 +294,6 @@ class UpdatePatientInfoTest < ApplicationSystemTestCase it 'should flash failure on a bad field change' do fill_in 'Phone number', with: '111-222-3333445' - click_away_from_field assert has_text? 'Primary phone is the wrong length' end end @@ -365,7 +360,6 @@ class UpdatePatientInfoTest < ApplicationSystemTestCase private def reload_page_and_click_link(link_text) - click_away_from_field visit authenticated_root_path visit edit_patient_path @patient click_link link_text