Skip to content

Refactor duplicated Syncfusion component loading and database queries#1

Merged
Facelles merged 4 commits intomainfrom
copilot/refactor-duplicated-code
Nov 2, 2025
Merged

Refactor duplicated Syncfusion component loading and database queries#1
Facelles merged 4 commits intomainfrom
copilot/refactor-duplicated-code

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 2, 2025

Eliminated repeated patterns across 9 files: dynamic Syncfusion component imports, license registration, and database queries.

Changes

  • Created useSyncfusionComponent hook - Consolidates useState/useEffect pattern for dynamic imports across 7 components (Header, TripCard, MobileSideBar, admin-layout, all-users, create-trip, NavItems). Includes error handling and prevents memory leaks.

  • Centralized license registration - app/lib/syncfusion.ts replaces 3 duplicate calls with singleton pattern.

  • Extracted queryUserByAccountId helper - Eliminates duplication between getExistingUser and getUser in auth.ts.

Example

Before:

const [ButtonComponent, setButtonComponent] = useState<any>(null);
useEffect(() => {
  import("@syncfusion/ej2-react-buttons").then((pkg) => 
    setButtonComponent(() => pkg.ButtonComponent)
  );
}, []);
if (!ButtonComponent) return null;

After:

const components = useSyncfusionComponent(
  () => import("@syncfusion/ej2-react-buttons"),
  ["ButtonComponent"]
);
if (!components) return null;
const { ButtonComponent } = components;

Net: +51 lines added (new utilities), -84 lines removed from components.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • o1.ingest.sentry.io
    • Triggering command: node /home/REDACTED/work/travel-WebApp/travel-WebApp/node_modules/.bin/react-router typegen (dns block)
    • Triggering command: node /home/REDACTED/work/travel-WebApp/travel-WebApp/node_modules/.bin/react-router build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Find and refactor duplicated code


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@netlify
Copy link
Copy Markdown

netlify Bot commented Nov 2, 2025

Deploy Preview for travel-app-ts ready!

Name Link
🔨 Latest commit 3b55577
🔍 Latest deploy log https://app.netlify.com/projects/travel-app-ts/deploys/69073ecfcc49ed000808f30e
😎 Deploy Preview https://deploy-preview-1--travel-app-ts.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI and others added 3 commits November 2, 2025 11:17
Co-authored-by: Facelles <122049357+Facelles@users.noreply.github.com>
…ndling

Co-authored-by: Facelles <122049357+Facelles@users.noreply.github.com>
Co-authored-by: Facelles <122049357+Facelles@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor duplicated code for better maintainability Refactor duplicated Syncfusion component loading and database queries Nov 2, 2025
Copilot AI requested a review from Facelles November 2, 2025 11:25
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 2, 2025

@copilot як мені примінити ці зміни до мого локального проекту?

To apply these changes to your local project, you have a few options:

Option 1: Merge the PR branch

git checkout main
git pull origin main
git merge copilot/refactor-duplicated-code

Option 2: Pull the PR branch directly

git fetch origin copilot/refactor-duplicated-code
git checkout copilot/refactor-duplicated-code

Option 3: If you want to merge via GitHub
Simply merge this PR through the GitHub interface, then pull the latest main branch:

git checkout main
git pull origin main

After applying the changes, run:

npm install  # Ensure all dependencies are installed
npm run typecheck  # Verify TypeScript
npm run build  # Build the application

Copy link
Copy Markdown
Owner

@Facelles Facelles left a comment

Choose a reason for hiding this comment

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

good

@Facelles Facelles marked this pull request as ready for review November 2, 2025 11:34
@Facelles Facelles merged commit 8634fff into main Nov 2, 2025
4 of 5 checks passed
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.

2 participants