mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-30 18:58:39 -04:00
- Introduced crop suggestions functionality allowing users to receive tailored crop recommendations based on their location and preferences. - Implemented the ability for users to dismiss specific crop suggestions, preventing them from receiving recommendations for crops they are not interested in. - Added a location picker for users to set their gardening location, enhancing the accuracy of crop suggestions. - Enhanced the dashboard to display relevant statistics, including plantings and harvests, with comparisons to previous years. - Created new views and partials for displaying statistics, crop suggestions, and user interactions on the dashboard. - Updated routes to accommodate new features related to crop suggestions and member locations. - Added migrations for new database tables and columns to support crop dismissal and suggestion preferences. - Developed tests for the new features, ensuring functionality and user experience are maintained.
38 lines
1.5 KiB
React
38 lines
1.5 KiB
React
// Entry point for the React "islands": small React components mounted into
|
|
// server-rendered pages. Rails renders an empty element with
|
|
// data-react-component="Name" and data-props='{...}' (see the react_component
|
|
// helper); this finds each one and mounts the matching component.
|
|
//
|
|
// To add a component: create it in ./components and register it below.
|
|
import React from 'react';
|
|
import {createRoot} from 'react-dom/client';
|
|
|
|
import GardenCards from './components/GardenCards';
|
|
import GardenLayout from './components/GardenLayout';
|
|
import LocationPicker from './components/LocationPicker';
|
|
import PhotoDialog from './components/PhotoDialog';
|
|
import PlantPicker from './components/PlantPicker';
|
|
import PlantingActions from './components/PlantingActions';
|
|
import PlantingRating from './components/PlantingRating';
|
|
|
|
const components = {GardenCards, GardenLayout, LocationPicker, PhotoDialog, PlantPicker, PlantingActions, PlantingRating};
|
|
|
|
function mountIslands() {
|
|
document.querySelectorAll('[data-react-component]').forEach((element) => {
|
|
const name = element.dataset.reactComponent;
|
|
const Component = components[name];
|
|
if (!Component) {
|
|
console.error(`No React component registered as "${name}"`);
|
|
return;
|
|
}
|
|
const props = JSON.parse(element.dataset.props || '{}');
|
|
createRoot(element).render(<Component {...props} />);
|
|
});
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', mountIslands);
|
|
} else {
|
|
mountIslands();
|
|
}
|