Skip to content

Feat: CSV import textfield and minor ui improvments#656

Merged
CodeWithCJ merged 2 commits intoCodeWithCJ:mainfrom
Sim-sat:improve-csv-import2
Feb 14, 2026
Merged

Feat: CSV import textfield and minor ui improvments#656
CodeWithCJ merged 2 commits intoCodeWithCJ:mainfrom
Sim-sat:improve-csv-import2

Conversation

@Sim-sat
Copy link
Contributor

@Sim-sat Sim-sat commented Feb 14, 2026

Description

Adds a textfield to the import function as requested by #546.
Additionally, this PR makes the modal wider and the button smaller.

Closes #546

Screenshots

Import Function

Import Textfield

UI Fixes

Fixes the background inconsistency:

Before After
Before After

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Sim-sat, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the user experience by introducing a direct text input option for CSV data import, complementing the existing file upload method. Additionally, it refines the UI of the import modal and addresses a minor visual inconsistency in the meal plan template form, contributing to a more polished and functional application.

Highlights

  • CSV Import Functionality: Added a new textfield to the CSV import dialog, allowing users to paste CSV content directly for parsing and import.
  • UI Improvements: The CSV import modal has been widened, and the import button's size has been reduced for better aesthetics.
  • Background Consistency Fix: Resolved an inconsistency in background colors within the meal plan template form, ensuring a more uniform appearance across themes.
Changelog
  • SparkyFitnessFrontend/src/components/EnhancedFoodSearch.tsx
    • Increased the maximum width of the import from CSV dialog content.
  • SparkyFitnessFrontend/src/components/FoodImportFromCSV.tsx
    • Imported the Textarea component for direct text input.
    • Introduced csvText state to manage the content of the new text area.
    • Implemented handleTextImport function to process CSV data pasted directly into the text area, including validation and parsing.
    • Rendered a Textarea input field and an associated 'Parse Text' button within the import dialog.
    • Reduced the width of the main import button.
    • Improved the display of the imported record count to correctly show 'Record' or 'Records'.
  • SparkyFitnessFrontend/src/pages/Foods/MealPlanTemplateForm.tsx
    • Adjusted the background color of meal plan template items to improve UI consistency, supporting both light and dark modes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a text field for CSV import functionality and includes some minor UI improvements. The changes are well-implemented. I've added a couple of comments to improve code maintainability by reducing duplication and to fix a minor typo in the UI. Overall, great work!

Comment on lines +155 to +190
const handleTextImport = () => {
if (!csvText || csvText.trim() === '') {
toast({
title: 'Import Error',
description: 'Please paste some CSV data first.',
variant: 'destructive',
});
return;
}

const lines = csvText.split('\n');
const fileHeaders = lines[0].split(',').map((h) => h.trim());
const areHeadersValid =
requiredHeaders.length === fileHeaders.length &&
requiredHeaders.every((value, index) => value === fileHeaders[index]);

if (!areHeadersValid) {
toast({
title: 'Invalid CSV Format',
description: 'Headers do not match required format. Use the template.',
variant: 'destructive',
});
return;
}

const parsedData = parseCSV(csvText);
if (parsedData.length > 0) {
setHeaders(Object.keys(parsedData[0]).filter((key) => key !== 'id'));
setCsvData(parsedData);
setCsvText(''); // Feld leeren nach Erfolg
toast({
title: 'Success',
description: `Loaded ${parsedData.length} rows from text.`,
});
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The header validation logic (lines 165-178) is duplicated from the handleFileUpload function. To improve maintainability, you could extract this into a shared helper function. For example:

const validateHeaders = (text: string): boolean => {
  const lines = text.split('\n');
  if (lines.length === 0) return false;
  const fileHeaders = lines[0].split(',').map((h) => h.trim());
  return (
    requiredHeaders.length === fileHeaders.length &&
    requiredHeaders.every((value, index) => value === fileHeaders[index])
  );
};

This can then be used in both handleTextImport and handleFileUpload.

Additionally, the comment on line 184 is in German. For consistency, it's best to use English for all comments.

@CodeWithCJ
Copy link
Owner

@Sim-sat it has some conflicts. could you look into it

@Sim-sat Sim-sat force-pushed the improve-csv-import2 branch from e320430 to 2a0d62c Compare February 14, 2026 18:49
@Sim-sat
Copy link
Contributor Author

Sim-sat commented Feb 14, 2026

@CodeWithCJ weird. Git could resolve the conflict locally without problems.

@CodeWithCJ CodeWithCJ merged commit b385106 into CodeWithCJ:main Feb 14, 2026
6 checks passed
@Sim-sat Sim-sat deleted the improve-csv-import2 branch February 20, 2026 13:04
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.

[Feature]: Add nutrients for a food pasting a single csv line

2 participants