Intro
00:00:00Building a Real-Time React Admin Dashboard Develop a real-time React admin dashboard featuring authentication, charts, event tracking, and CRUD operations. The application includes smooth animations for data visualization and allows users to manage company details with search capabilities. Real-time synchronization enables instant updates across devices without refreshing the page. A Kanban board facilitates task management with drag-and-drop functionality while keeping track of deadlines and assignments.
Leveraging Refine for Efficient Development Refine simplifies web app development by providing ready-to-use hooks and components that streamline repetitive tasks like authentication, routing, state management, and internationalization. This modern architecture accelerates project implementation in various applications such as internal tools or dashboards. Familiarity with JavaScript and React is essential for this tutorial; beginners can find resources online to learn these skills quickly.
Create Refine Project
00:04:33To start building a dashboard, open Visual Studio Code and run the command 'npm create refine Das app at latest'. Confirm installation when prompted. After downloading the remote source, select a project template; in this case, choose Vite for simplicity over Next.js. For backend services, opt for NestJS and use Ant Design as your UI framework while selecting custom mock authentication without internationalization support.
Refine Dev Tools
00:07:39Refine Step Tools enhances the development experience with two key features. The package overview allows users to view and update refine-related packages in their app, ensuring they are using the latest versions. Monitoring provides insights into application queries and mutations via hooks, displaying success or failure statuses along with detailed information about each hook used. Upcoming features like playground inference preview and an AI assistant promise further improvements.
Remove unnecessary files
00:09:48To streamline the project, unnecessary files and components are removed, starting with the components folder and context. This process includes deleting imports related to these elements from app.tsx, which leads to errors due to missing references. Commenting out problematic code helps manage TypeScript complaints about absent types while preparing for future adjustments.
Data provider setup
00:10:45Setting Up a Data Provider for Efficient Data Management Data providers are essential components that streamline various application functions like data fetching, authentication, and real-time updates. A typical workflow involves connecting an API to the provider which manages HTTP requests and caching. By creating a custom fetch function within this setup, developers can efficiently handle headers and errors without cluttering their code.
Creating Custom Fetch Functions for Enhanced Reusability The process begins by establishing a GraphQL client linked to the desired API URL. Developers create a custom fetch wrapper that adds authorization headers automatically while managing error handling effectively through structured responses. This approach enhances reusability across multiple requests in the application.
Implementing WebSocket Connections for Real-Time Updates To facilitate real-time data synchronization, implementing WebSockets is crucial as it allows applications to listen for changes instantly via subscriptions on the GraphQL API. The live provider feature enables seamless updates when users interact with shared resources without needing page refreshes.
Integrating Live Providers into Application Architecture 'Live providers' complement standard data providers by enabling subscription-based functionalities using established websocket connections alongside regular RESTful interactions with APIs. Proper configuration ensures both types of communication work harmoniously within refine's architecture.
Finalizing Setup: Exporting Providers For Application Use 'After setting up both standard and live data providers successfully, exporting them from designated files simplifies integration into main application components—ensuring efficient access throughout development cycles while maintaining clean code practices.'
Auth provider
00:29:44The OP provider facilitates user login and permission management, handling redirects and errors. It allows integration with third-party authentication services or custom methods. A new file named o.ts is created to implement the OP provider, which includes essential methods like login, logout, error handling, check for authentication status, and retrieving user identity information. The implementation involves calling a GraphQL API through a data provider to manage access tokens in local storage effectively.
Workflow setup
00:34:02Setting up a workflow for TypeScript involves using GraphQL Code Generator to automatically generate types, eliminating the need for manual type definitions. Begin by installing necessary packages like codegen-typescript and graphql-code-generator plugins that enhance type safety across queries, mutations, and subscriptions. Additionally, include preset configurations to optimize import statements in generated files. After installation is complete, proceed to create routes within your application by defining components such as an index route linked to a home component.
Initial routes demo
00:36:41To create a home page, establish a new folder named 'home' and add an index.tsx file. Use the rafc command to generate a React functional component called Home, then export all pages from the pages directory by creating an index.ds file that exports components for home, forgot password, login, and register. Ensure each page uses 'export const' instead of default export to allow multiple exports from one file. Duplicate routes in your routing setup for registration and login paths while ensuring they are correctly linked with their respective URLs.
Update login
00:40:39The focus shifts to updating the login functionality by utilizing credentials from providers instead of demo values. The necessary o credentials are imported, allowing for a connection between the login and provider systems. A minor adjustment is made in the data provider where the API URL is corrected to point specifically to the GraphQL endpoint using template strings. After these changes, testing reveals successful sign-in with existing o credentials, confirming that users are redirected appropriately to their welcome page.
App routes and layout setup
00:42:49App Routes and Layout Initialization The app routes and layout setup is now functional, allowing for the development of a homepage that includes both authenticated and non-authenticated routes. The initial focus will be on creating a header component to be used across all pages.
Creating Header Component Structure A new components folder is created within the source directory, containing a layout subfolder for shared elements like headers. A header component file named Heather.tsx is established using React snippets to streamline creation.
User Authentication Check in Header To verify user authentication status, another component called Current User is added inside the header. This utilizes Ant Design's Popover feature to display additional information when clicked.
Utilizing Ant Design Components Effectively 'Ant Design' provides UI components essential for dashboard applications; understanding its documentation enhances developer skills. The popover requires specific props such as placement and trigger settings which are configured accordingly.
'Layout' Integration with App Structure 'Themed Layout V2', imported from refine Dev library, wraps around children components including our newly created header ensuring it appears consistently across all pages while managing title properties dynamically through callbacks.
Home deals and upcoming events
01:33:04Creating Components for Home Page New components are created for the homepage, specifically 'Upcoming Events' and 'Deals Chart'. These components are organized in a dedicated folder. An index file is set up to facilitate importing these new components.
Designing Upcoming Events Card The upcoming events card is designed using Ant Design's card component with specific styles applied. A loading state is implemented to manage data display while fetching information about upcoming events.
Implementing Loading State and Skeletons A skeleton loader mimics content structure during data fetches, enhancing user experience by indicating that loading occurs. The skeleton component displays placeholders until real event data becomes available.
Rendering Event Data Once Loaded 'IsLoading' toggles off once the actual event data loads from an API call via refine hooks. This allows rendering of list items based on fetched event details such as title and date.
Fetching Real Data Using Refine Hooks 'UseList' hook simplifies fetching resources like events through GraphQL queries, allowing easy integration of pagination, sorting, filtering into applications without complex setups.
'No Upcoming Events' Handling Logic Conditional logic checks if there’s no loaded data after completing the load process; it provides feedback when no upcoming events exist instead of leaving users confused or misled by empty states.
Latest activities and total count cards
02:15:49Building the Total Count Card Component Creating a dashboard total count card involves setting up a new component in the homepage. This includes defining resources for companies, contracts, and deals while ensuring proper loading states are established. The data is fetched using custom hooks to retrieve counts from GraphQL queries.
Defining Props and Styling Cards To display accurate resource totals, props such as resource type and loading state must be defined within the card's structure. Styling elements like height and padding enhance visual appeal while maintaining functionality with Ant Design components.
Utilizing Constants for Dynamic Icons Icons representing each resource can be dynamically rendered by creating constants that store values used across cards. These constants simplify management of labels, colors, icons, titles, etc., allowing easy updates without altering JSX directly.
Integrating Charts into Dashboard Cards The chart visualization enhances user experience by displaying trends related to company metrics through area charts configured with specific styles including color gradients based on primary colors associated with each metric category.
.Setting Up Latest Activities Section. 'Latest Activities' section requires additional setup similar to previous components but focuses on rendering audit activities instead of static data displays. Loading states simulate real-time interactions before actual implementation begins
'useList' hook fetches audits which then allows extraction of deal IDs necessary for subsequent calls retrieving detailed information about those deals linked via their respective actions recorded during audits processing them efficiently together improves performance overall
Company list page
02:52:53Setting Up Company List Page The dashboard is complete, and the next step involves creating a company list page. A new route will be added in app.TSX with a path for companies leading to the company list component. This requires setting up an index file within a newly created folder named 'company'. The structure allows easy navigation back to the homepage while preparing for future functionalities like create and edit options.
Creating Searchable Table Structure A searchable table displaying companies will be developed, featuring columns for deal amounts and action buttons (edit/delete). Utilizing refine Dev's components simplifies this process by automatically generating necessary elements when routes are established. Initial configurations include disabling breadcrumbs on display while implementing header buttons that facilitate navigation through actions such as creating new entries.
Enhancing Data Presentation with Pagination Integrating Ant Design’s table component enhances data presentation capabilities including pagination features set at twelve items per page. Columns are defined based on specific attributes: one displays company names alongside logos using custom avatars; another shows total revenue from deals aggregated effectively via GraphQL queries ensuring accurate representation of financial metrics across all listed entities.
Implementing Action Functionality Within Rows Action functionality is incorporated into each row allowing users to edit or delete records seamlessly integrated through refined Dev tools which manage routing dynamically upon user interaction—confirming operational integrity even without visible changes yet implemented in UI design aspects during testing phases.
'Create' Button Activation Process 'Create' button functionality needs activation enabling addition of new companies directly from their respective pages linked appropriately within existing routing structures outlined earlier in app.TSX configuration files facilitating smooth transitions between listing views and creation forms enhancing overall application usability experience significantly over time as more features get rolled out progressively thereafter
Create company
03:12:24Creating Companies with Modal Interface The application allows users to create new companies through a modal interface. This involves wrapping the functionality in a company list component and utilizing Ant Design's modal for user interaction. The process includes defining form properties, setting default visibility, specifying resource types, and determining mutation modes such as pessimistic updates.
Dynamic Input Fields for Company Creation To facilitate data entry for creating companies, two input fields are required: one for the company name and another to select a sales owner from existing database entries. A refined hook called useSelect is employed to fetch available sales owners dynamically while ensuring proper mapping of user details like ID and avatar URL into selectable options within the form.
Real-Time Updates on Submission Success Upon entering valid information in both fields (company name & sales owner), clicking save triggers an automatic loading alert followed by real-time updates reflecting changes in the database without manual refreshes. Successful submissions result in immediate visual feedback confirming that new records have been added correctly alongside their respective attributes like open deal amounts.
Implementing Edit Functionality With successful creation implemented, attention shifts towards enabling editing capabilities via dynamic routing adjustments within app configuration files. By duplicating existing routes but modifying paths accordingly (e.g., edit SL colon ID), developers can set up dedicated pages allowing users to modify previously created entries seamlessly throughout their workflow experience.
Company edit
03:29:25Creating the Edit Component A new edit component is created within the company pages, allowing for an empty slate to develop editing functionality. The goal is to transform this into a user-friendly form that includes essential fields and layout adjustments using Ant Design components.
Implementing Form Functionality The core of the edit functionality involves utilizing hooks from refine Dev, specifically focusing on managing forms with options like redirect settings and GraphQL mutations for updating company data. Essential properties are destructured from these hooks to facilitate smooth integration into the form structure.
Building Out Form Elements Form elements such as custom avatars, select fields for sales owners, inputs for revenue and other details are added sequentially. Each input field pulls initial values dynamically while ensuring proper validation through props management in order to enhance user experience during updates.
Integrating Contacts Management To finalize features related to contacts associated with companies, a contact table is integrated alongside CRUD functionalities including create, read update delete operations seamlessly managed by refine's built-in capabilities. This results in a comprehensive dashboard where users can manage all aspects of their company's information efficiently.
Kanban board
03:47:34Setting Up Task Structure Create a new folder for tasks and set up the initial structure with an empty React fragment. Begin building a Kanban board by creating components for the board and columns, which will temporarily break the app until fully implemented.
Exporting Components Define two main exports from your Kanban component: one for the container that accepts children as props, allowing you to render content within it. Use divs to create styling placeholders while preparing functionality.
Integrating Drag-and-Drop Functionality Install DND Kit (drag-and-drop library) to enable drag-and-drop features in your application. Wrap everything inside a DND context so that child elements can utilize this feature effectively.
Styling Your Board Layout Apply styles to both outer and inner containers of your Kanban board using flexbox properties like width, height, padding, margin adjustments etc., ensuring proper layout before adding dynamic content later on.
Kanban task create
05:11:04Implementing Task Creation Functionality in Kanban The Kanban task creation process involves implementing an add button under each column. The functionality is linked to a click handler that redirects users based on the stage ID, directing them either to create or edit tasks. Using React Router's replace method allows for seamless navigation when adding new cards.
Setting Up Routing and Modal Overlays Routing for tasks requires defining paths within the application structure, allowing both creation and editing of tasks on separate pages while maintaining visibility of the list. New routes are established using React Router’s Outlet component to manage child elements effectively. A modal overlay will be introduced later for displaying task details without disrupting user experience during real-time collaboration.
Kanban task edit
05:18:45Streamlined Task Editing Process Editing tasks in the Kanban system involves using familiar hooks and functionalities similar to those used for creating or editing companies. Essential components must be downloaded, unzipped, and organized within the project structure. Proper exports from various files are crucial for seamless integration of these components into the edit task functionality.
Debugging Import Errors Effectively To resolve errors related to missing imports like Markdown editor and user tags, necessary packages need installation via terminal commands. Ensuring consistent import/export conventions is vital; mixing named with default exports can lead to issues that require debugging. Adjustments made during this process help restore functionality while enhancing code organization.
Enhanced User Interaction on Kanban Board The final implementation allows users to interact seamlessly with cards on the Kanban board by clicking titles directly instead of just dragging them around. Users can add detailed descriptions using markdown formatting when editing tasks, assign due dates, and move cards through different stages efficiently within a unified dashboard experience reminiscent of dedicated applications like Jira or Trello.
Deployment
05:28:26Creating Your GitHub Repository for Deployment To deploy a project online, start by creating a new repository on GitHub. Name it appropriately and set its visibility to public or private as needed. Initialize the git repository in your terminal, add files, commit changes, and push them to the main branch.
Importing Code into Vercel and Handling Errors After deploying code on GitHub, head over to Vercel to import your newly created repo for deployment. If you encounter TypeScript errors during this process due to strict settings in Vercel's environment variables, adjust those settings accordingly so that minor issues won't halt deployment.
Finalizing Deployment: A Successful Interactive Dashboard Once all adjustments are made regarding TypeScript types within various components of the application codebase—such as lists and tasks—the app can be successfully redeployed without further issues. The final product is an interactive dashboard showcasing real-time data with features like task management; demonstrating scalability potential thanks to refine’s capabilities.