Skip to content

Conversation

@utkarsh14
Copy link
Collaborator

@utkarsh14 utkarsh14 commented Jul 16, 2025

UI/UX fixes for Locations, Targets, Enumerators

Ticket

Fixes: No tickets created

Description, Motivation and Context

Fixes:

  1. Changed the location upload error screen to use an error warning table.
  2. Updated Targets/Enumerators upload screen not to run an empty fields check.
  3. Targets Map/Remap: Removed PII / Mandatory/ Bulk edit options for custom column, added accept null value checkbox
  4. Targets/Enumerator map/remap screens: This runs an empty fields check for only those columns that are required or that do not accept null values.
  5. Email Template: Fix table card height and add search functionality for sort columns
  6. Add user screen: Fixed a bug where the user role was changed to Survey Admin, but the roles array was not updated.
  7. Basic Survey Info: Added validations for survey_id to be alphanumeric and underscores only,
  8. Enumerators edit screen: Allow custom fields to be edited, use allow_null_values to set required fields
  9. Targets edit screen: use allow_null_values to set required fields

To Do:

  • Fix target/enumerator upload to load allow_null_values to backend, can be done after backend pr is merged

How Has This Been Tested?

Local

UI Changes

Survey_id changes:
Screenshot 2025-07-15 at 11 22 23

Location error screen changes:
Screenshot 2025-07-29 at 12 59 30

Targets/Enumerators Edit screen:
image

Targets/Enumerators Blank value error:
image

To-do before merge

Checklist:

This checklist is a useful reminder of small things that can easily be forgotten.
Put an x in all the items that apply and remove any items that are not relevant to this PR.

  • My code follows the style guidelines of this project
  • I have reviewed my own code to ensure good quality
  • I have tested the functionality of my code to ensure it works as intended
  • I have resolved merge conflicts
  • I have updated the automated tests (if applicable)
  • I have written [good commit messages][1]
  • I have updated the README file (if applicable)
  • I have updated affected documentation (if applicable)

@utkarsh14 utkarsh14 requested a review from Copilot July 16, 2025 10:28

This comment was marked as outdated.

@utkarsh14 utkarsh14 marked this pull request as ready for review July 22, 2025 05:57
@utkarsh14 utkarsh14 requested a review from Copilot July 22, 2025 05:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements several UI/UX improvements across the Locations, Targets, and Enumerators modules. The main purpose is to enhance user experience by improving error handling, validation workflows, and UI consistency.

Key changes include:

  • Enhanced CSV validation with selective empty field checking for targets and enumerators
  • Updated location upload error display to use error warning table instead of basic alerts
  • Simplified UI for targets/enumerators mapping by removing PII/bulk edit options and adding null value acceptance
  • Added comprehensive form validation for survey ID field with alphanumeric and underscore restrictions

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/utils/csvValidator.ts Enhanced validateCSVData function with optional empty column checking and improved data structures
src/redux/surveyLocations/surveyLocationsActions.ts Fixed function name typo and added record_errors to error responses
src/modules/SurveyInformation/Targets/ Updated file upload components to disable empty column validation
src/modules/SurveyInformation/Targets/TargetsRemap/TargetsRemap.tsx Added selective validation and simplified custom field options
src/modules/SurveyInformation/Targets/TargetsMap/TargetsMap.tsx Similar validation improvements and UI simplification
src/modules/SurveyInformation/SurveyUserRoles/SurveyUsers/ Fixed bug by initializing roles array when user role changes to Survey Admin
src/modules/SurveyInformation/SurveyLocationUpload/SurveyLocationUpload.tsx Replaced basic error display with comprehensive error warning table
src/modules/SurveyInformation/Enumerators/ Applied similar validation and UI improvements as targets
src/modules/NewSurveyConfig/BasicInformation/BasicInformationForm.tsx Added robust validation rules for survey ID field
src/components/EmailTableModel/EmailTableModel.tsx Improved modal height and added search functionality to dropdowns

);

export const puturveyLocations = createAsyncThunk(
export const putSurveyLocations = createAsyncThunk(
Copy link

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function name was corrected from 'puturveyLocations' to 'putSurveyLocations', fixing the missing 'S' in 'put'.

Copilot uses AI. Check for mistakes.
Comment on lines 44 to 45
import { set } from "lodash";

Copy link

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'set' import from lodash is not used anywhere in the file and should be removed to avoid unnecessary imports.

Suggested change
import { set } from "lodash";

Copilot uses AI. Check for mistakes.
const headers = parsedCsv?.data[0];
const emptyRows: number[] = [];
const emptyColumns: string[] = [];
const emptyColumns: Set<string> = new Set();
Copy link

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Set for emptyColumns is efficient for tracking unique column names and prevents duplicates, which is a good performance improvement over the previous array approach.

Copilot uses AI. Check for mistakes.
// Validate CSV for empty columns (only for columnsToCheck)
if (columnsToCheck.length > 0) {
const validationResult = await validateCSVData(
new File([atob(csvBase64Data)], "data.csv"),
Copy link

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using atob() to decode base64 data without proper validation could be a security risk. Consider validating the base64 data before decoding to prevent potential injection attacks.

Copilot uses AI. Check for mistakes.
Comment on lines +235 to +246
pattern: /^[a-zA-Z0-9_]+$/,
message: (
<div style={{ maxWidth: "220px", whiteSpace: "normal" }}>
Survey ID can only contain letters, numbers, and
underscores
</div>
),
},
{
max: 25,
message: "Survey ID cannot exceed 25 characters",
},
Copy link

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern for survey ID validation is well-implemented, restricting to alphanumeric characters and underscores only, which aligns with the tooltip description and prevents potential issues with special characters in database table names.

Suggested change
pattern: /^[a-zA-Z0-9_]+$/,
message: (
<div style={{ maxWidth: "220px", whiteSpace: "normal" }}>
Survey ID can only contain letters, numbers, and
underscores
</div>
),
},
{
max: 25,
message: "Survey ID cannot exceed 25 characters",
},
pattern: /^(?![_\.])[a-zA-Z0-9_.]{1,25}$/,
message: (
<div style={{ maxWidth: "220px", whiteSpace: "normal" }}>
Survey ID must start with a letter or number, can
contain letters, numbers, underscores, and periods,
and must not exceed 25 characters.
</div>
),
},

Copilot uses AI. Check for mistakes.
@utkarsh14 utkarsh14 requested a review from jeenut27 July 29, 2025 07:32
Copy link
Collaborator

@jeenut27 jeenut27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am getting a Token "NaN" is invalid. error in docker when uploading a custom column in targets with a null value when null values are allowed. Can you check this?

Also, the mandatory/ non-mandatory in edit drawer on targets is not changing based on what allows null values: https://jam.dev/c/d9166480-fc3f-4cd6-b60a-0687288c0c4d

@utkarsh14
Copy link
Collaborator Author

I am getting a Token "NaN" is invalid. error in docker when uploading a custom column in targets with a null value when null values are allowed. Can you check this?

Also, the mandatory/ non-mandatory in edit drawer on targets is not changing based on what allows null values: https://jam.dev/c/d9166480-fc3f-4cd6-b60a-0687288c0c4d

NaN value fix is on backend, PR Raised:
IDinsight/surveystream_flask_api#322

Can you try the changes again with this branch?

@utkarsh14
Copy link
Collaborator Author

@jeenut27 Can you test again with backend fixes IDinsight/surveystream_flask_api#322.
Targets upload and edit drawers will work.

@utkarsh14 utkarsh14 requested a review from jeenut27 July 30, 2025 09:57
Copy link
Collaborator

@jeenut27 jeenut27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Targets screens are looking okay. Also tested the survey id change.

On enumerator - edit to remove a null value is not working (not sure if this is related to the changes here, but can you check?) https://jam.dev/c/61944175-dfd0-48bc-bd7d-a0b5db3eb282

A small nit on both targets and enumerators. For a blank value error, is it possible to update the error count at the top? In this it was just one row with a missing gender value. Also for these errors - is the reason why the download csv doesn't have specific rows because this check is happening on frontend?
error

@utkarsh14
Copy link
Collaborator Author

is the reason why the download csv doesn't have specific rows because this check is happening on frontend?

Yes, since checks are run on frontend we don't have specific rows on error. I will see what we can do with error counts and download rows in this.

@utkarsh14 utkarsh14 merged commit b787966 into dev Jul 31, 2025
3 checks passed
@utkarsh14 utkarsh14 deleted the validation_ui_fixes branch August 1, 2025 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants