generated from mantinedev/next-app-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate from API routes to Server Functions #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Added a comment in the barometer page to investigate the use of Prisma.BarometerCreateInput type for schema foundation. - Renamed the form submission handler in the document page from `handleFormSubmit` to `submitForm` for clarity. - Updated the form submission method to use the new handler, improving code readability and maintainability. - Introduced a new export for `revalidateCategory` in the utils index, enhancing server-side functionality.
…er form with zod - Replaced Yup with Zod for form validation in the barometer component, enhancing type safety and validation capabilities. - Updated the form submission logic to utilize Zod's transformation and validation features. - Added Zod as a new dependency in package.json and bun.lock for consistent validation handling. - Cleaned up unused imports and improved code readability in the barometer form component.
- Updated the BrandEdit component to include a multi-select for countries and successors, improving user experience. - Integrated a new ManufacturerImageEdit component for better image management, allowing drag-and-drop functionality and image uploads. - Refactored form handling to utilize Zod for validation, ensuring type safety and cleaner code. - Added a RequiredFieldMark component for indicating mandatory fields in forms. - Implemented deleteImages function for handling image deletions from storage. - Cleaned up imports and improved overall code organization across several files.
…and query files for server-side rendering support
…bmission state management - Added state management for form submission success to prevent unnecessary cleanup of temporary images. - Refactored image deletion logic to ensure only removed images are deleted from storage. - Cleaned up the component by consolidating the cleanup logic on dialog close.
…oved data fetching and form handling - Replaced existing form handling logic with dedicated BarometerForm and DocumentForm components for better separation of concerns. - Enhanced data fetching by utilizing async functions to retrieve conditions, categories, movements, brands, and materials in AddBarometer and conditions and all barometers in AddDocument. - Updated type definitions for materials and movements to ensure consistency across the application. - Cleaned up imports and improved overall code organization in related files.
- Updated the package.json dump command to include dotenv and script execution for database backup. - Added a new link in the Admin component for adding brands, enhancing navigation and user experience. - Removed the AddManufacturer component to streamline the barometer form, consolidating manufacturer management within the brand editing process. - Refactored the barometer form to include required field indicators for better user guidance. - Improved image handling in the BrandEdit component by integrating icon upload functionality. - Cleaned up imports and improved overall code organization across several files.
- Moved barometer and category query functions to dedicated files in the lib directory for better organization and maintainability. - Updated import paths across the application to reflect the new structure, ensuring consistency. - Removed obsolete API service file to streamline the codebase. - Cleaned up unused imports and improved overall code organization in related components and services.
- Wrapped the BrandEdit component in an IsAdmin check to restrict editing functionality to admin users. - Corrected the order of parameters in the searchBarometers function call to align with the updated function signature, improving search functionality. - Cleaned up imports and improved overall code organization in the affected files.
…e multi-select functionality into forms - Deleted the MaterialsMultiSelect component to streamline the codebase and reduce redundancy. - Replaced the MaterialsMultiSelect usage in BarometerForm and DocumentForm with a new MultiSelect component for improved consistency and functionality. - Updated related imports and adjusted props to align with the new MultiSelect implementation. - Enhanced overall code organization and maintainability across affected files.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactor: Migrate from API routes to Server Functions
What
/api/v2/*) to Server Functions patternlib/modules for each domain (barometers, brands, categories, etc.)Why
Key Changes
Removed API Routes (20+ files)
/api/v2/barometers/*→lib/barometers/queries.ts/api/v2/manufacturers/*→lib/brands/queries.ts/api/v2/categories/*→lib/categories/queries.tslib/modulesEnhanced Admin Features
Component Improvements
multi-select,image-upload,icon-uploadcomponentsTechnical Improvements
anytypesMigration Impact