@pplancq/react-template 2.8.17 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/_README.md +57 -52
- package/mise.toml +2 -2
- package/package.json +25 -24
- package/scripts/removeDemo.cjs +105 -66
- package/src/README.md +81 -0
- package/src/app/App.tsx +18 -0
- package/src/{bootstrap.tsx → app/AppHTMLElement.tsx} +2 -2
- package/src/app/README.md +69 -0
- package/src/{__tests__/bootstraps.test.tsx → app/__tests__/AppHTMLElement.test.tsx} +5 -5
- package/src/app/config/serviceContainer.ts +6 -0
- package/src/app/providers/Providers/Providers.tsx +18 -0
- package/src/{providers → app/providers}/QueryClientProvider/QueryClientProvider.tsx +3 -3
- package/src/app/providers/ServiceProvider/ServiceContext.ts +8 -0
- package/src/app/providers/ServiceProvider/ServiceProvider.tsx +14 -0
- package/src/app/routing/Router.tsx +14 -0
- package/src/app/routing/appRoutes.ts +3 -0
- package/src/app/routing/routes.tsx +9 -0
- package/src/demo/README.md +148 -0
- package/src/demo/application/dtos/ArchitecturePrinciple.ts +5 -0
- package/src/{types/profileTypes.ts → demo/application/dtos/ProfileFormValues.ts} +1 -1
- package/src/demo/application/use-cases/GetArchitecturePrinciplesUseCase.ts +11 -0
- package/src/demo/application/use-cases/GetArchitecturePrinciplesUseCaseInterface.ts +5 -0
- package/src/demo/application/use-cases/GetDemoUsersUseCase.ts +11 -0
- package/src/demo/application/use-cases/GetDemoUsersUseCaseInterface.ts +5 -0
- package/src/demo/domain/entities/DemoUser.ts +7 -0
- package/src/demo/domain/repositories/ArchitecturePrincipleRepositoryInterface.d.ts +5 -0
- package/src/demo/domain/repositories/DemoUserRepositoryInterface.d.ts +5 -0
- package/src/demo/infrastructure/repositories/HttpDemoUserRepository.ts +29 -0
- package/src/demo/infrastructure/repositories/StaticArchitecturePrincipleRepository.ts +33 -0
- package/src/demo/serviceDemo.ts +39 -0
- package/src/demo/serviceIdentifiers.ts +6 -0
- package/src/demo/ui/components/DemoFooter/DemoFooter.tsx +17 -0
- package/src/{components/Footer → demo/ui/components/DemoFooter}/__tests__/Footer.test.tsx +2 -2
- package/src/{components/Footer → demo/ui/components/DemoFooter}/__tests__/__snapshots__/Footer.test.tsx.snap +3 -3
- package/src/demo/ui/components/DemoFooter/index.ts +1 -0
- package/src/demo/ui/components/DemoHeader/DemoHeader.tsx +25 -0
- package/src/{components/Header → demo/ui/components/DemoHeader}/__tests__/Header.test.tsx +2 -2
- package/src/demo/ui/components/DemoHeader/__tests__/__snapshots__/Header.test.tsx.snap +64 -0
- package/src/demo/ui/components/DemoHeader/index.ts +1 -0
- package/src/{ui/molecules/Navigation/Navigation.tsx → demo/ui/components/DemoNavigation/DemoNavigation.tsx} +4 -4
- package/src/demo/ui/components/DemoNavigation/index.ts +1 -0
- package/src/{components → demo/ui/components}/TextInput/TextInput.tsx +3 -3
- package/src/{forms → demo/ui/forms}/ProfileForm/ProfileForm.tsx +7 -7
- package/src/demo/ui/hooks/useDemoUsersQuery/useDemoUsersQuery.ts +13 -0
- package/src/demo/ui/layouts/DemoLayout/DemoLayout.tsx +12 -0
- package/src/demo/ui/layouts/MainTemplate/MainTemplate.module.css +21 -0
- package/src/{ui/templates → demo/ui/layouts}/MainTemplate/MainTemplate.tsx +7 -7
- package/src/demo/ui/pages/DemoHome/DemoHome.tsx +117 -0
- package/src/demo/ui/pages/DependencyInjectionDemo/DependencyInjectionDemo.tsx +47 -0
- package/src/{pages/Demo → demo/ui/pages}/ReactHookFormDemo/ReactHookFormDemo.tsx +7 -7
- package/src/demo/ui/pages/ReactQueryDemo/ReactQueryDemo.module.scss +38 -0
- package/src/{pages/Demo → demo/ui/pages}/ReactQueryDemo/ReactQueryDemo.tsx +5 -4
- package/src/demo/ui/routing/demoAppRoutes.ts +6 -0
- package/src/demo/ui/routing/demoRoutes.tsx +31 -0
- package/src/main.ts +2 -2
- package/src/shared/README.md +53 -0
- package/src/shared/application/README.md +49 -0
- package/src/shared/domain/README.md +52 -0
- package/src/shared/infrastructure/README.md +51 -0
- package/src/{api → shared/infrastructure/http}/fetchApi.ts +1 -1
- package/src/shared/ui/README.md +50 -0
- package/src/shared/ui/hooks/useService/useService.ts +13 -0
- package/tsconfig.json +3 -1
- package/vitest.config.mts +5 -1
- package/src/api/README.md +0 -65
- package/src/api/demoApi.ts +0 -10
- package/src/assets/README.md +0 -54
- package/src/components/App/App.tsx +0 -18
- package/src/components/App/index.ts +0 -1
- package/src/components/Footer/Footer.tsx +0 -16
- package/src/components/Footer/index.ts +0 -1
- package/src/components/Header/Header.tsx +0 -17
- package/src/components/Header/__tests__/__snapshots__/Header.test.tsx.snap +0 -37
- package/src/components/Header/index.ts +0 -1
- package/src/components/README.md +0 -33
- package/src/config/README.md +0 -63
- package/src/config/index.ts +0 -1
- package/src/forms/README.md +0 -142
- package/src/hooks/README.md +0 -83
- package/src/hooks/api/queryKey.ts +0 -1
- package/src/hooks/api/useDemoApi.ts +0 -16
- package/src/pages/Demo/Demo.tsx +0 -236
- package/src/pages/Demo/ReactHookFormDemo/index.ts +0 -1
- package/src/pages/Demo/ReactHookFormDemo/routes.tsx +0 -7
- package/src/pages/Demo/ReactQueryDemo/index.ts +0 -1
- package/src/pages/Demo/ReactQueryDemo/routes.tsx +0 -7
- package/src/pages/Demo/__tests__/Demo.test.tsx +0 -15
- package/src/pages/Demo/__tests__/__snapshots__/Demo.test.tsx.snap +0 -557
- package/src/pages/Demo/index.ts +0 -1
- package/src/pages/Demo/routes.tsx +0 -8
- package/src/pages/Layout/Layout.tsx +0 -12
- package/src/pages/Layout/index.ts +0 -1
- package/src/pages/README.md +0 -91
- package/src/pages/UnexpectedError/UnexpectedError.module.css +0 -8
- package/src/pages/UnexpectedError/UnexpectedError.tsx +0 -22
- package/src/pages/UnexpectedError/index.ts +0 -1
- package/src/providers/QueryClientProvider/index.ts +0 -1
- package/src/providers/README.md +0 -112
- package/src/providers/index.ts +0 -1
- package/src/providers/withProviders/index.ts +0 -1
- package/src/providers/withProviders/withProviders.tsx +0 -18
- package/src/routing/README.md +0 -76
- package/src/routing/appRoutes.ts +0 -5
- package/src/routing/routerFactory.ts +0 -12
- package/src/routing/routes.tsx +0 -13
- package/src/types/README.md +0 -62
- package/src/types/demoApi.ts +0 -25
- package/src/ui/README.md +0 -144
- package/src/ui/molecules/Navigation/index.ts +0 -1
- package/src/ui/organisms/Footer/Footer.module.css +0 -10
- package/src/ui/organisms/Footer/Footer.tsx +0 -10
- package/src/ui/organisms/Footer/index.ts +0 -1
- package/src/ui/organisms/Header/Header.module.css +0 -17
- package/src/ui/organisms/Header/Header.tsx +0 -16
- package/src/ui/organisms/Header/index.ts +0 -1
- package/src/ui/organisms/MainContent/MainContent.module.css +0 -3
- package/src/ui/organisms/MainContent/MainContent.tsx +0 -6
- package/src/ui/organisms/MainContent/index.ts +0 -1
- package/src/ui/templates/MainTemplate/MainTemplate.module.css +0 -5
- package/src/utils/README.md +0 -70
- /package/src/{assets → app/assets}/css/index.ts +0 -0
- /package/src/{assets → app/assets}/css/mainBody.css +0 -0
- /package/src/{assets → app/assets}/css/reset.css +0 -0
- /package/src/{config → app/config}/queryClientConfig.ts +0 -0
- /package/src/{assets → demo/ui/assets}/images/logo.png +0 -0
- /package/src/{assets → demo/ui/assets}/images/templatePlugins.png +0 -0
- /package/src/{components/Footer/Footer.module.css → demo/ui/components/DemoFooter/DemoFooter.module.css} +0 -0
- /package/src/{components/Header/Header.module.css → demo/ui/components/DemoHeader/DemoHeader.module.css} +0 -0
- /package/src/{ui/molecules/Navigation/Navigation.module.css → demo/ui/components/DemoNavigation/DemoNavigation.module.css} +0 -0
- /package/src/{ui/atoms → demo/ui/components}/Input/Input.module.scss +0 -0
- /package/src/{ui/atoms → demo/ui/components}/Input/Input.tsx +0 -0
- /package/src/{ui/atoms → demo/ui/components}/Input/index.ts +0 -0
- /package/src/{ui/atoms → demo/ui/components}/Logo/Logo.module.css +0 -0
- /package/src/{ui/atoms → demo/ui/components}/Logo/Logo.tsx +0 -0
- /package/src/{ui/atoms → demo/ui/components}/Logo/__tests__/Logo.test.tsx +0 -0
- /package/src/{ui/atoms → demo/ui/components}/Logo/index.ts +0 -0
- /package/src/{ui/atoms → demo/ui/components}/NavLink/NavLink.tsx +0 -0
- /package/src/{ui/atoms → demo/ui/components}/NavLink/index.ts +0 -0
- /package/src/{components → demo/ui/components}/TextInput/index.ts +0 -0
- /package/src/{forms → demo/ui/forms}/ProfileForm/ProfileForm.module.scss +0 -0
- /package/src/{forms → demo/ui/forms}/ProfileForm/index.ts +0 -0
- /package/src/{ui/templates → demo/ui/layouts}/MainTemplate/index.ts +0 -0
- /package/src/{pages/Demo/Demo.module.scss → demo/ui/pages/DemoHome/DemoHome.module.scss} +0 -0
- /package/src/{pages/Demo/ReactQueryDemo/ReactQueryDemo.module.scss → demo/ui/pages/DependencyInjectionDemo/DependencyInjectionDemo.module.scss} +0 -0
- /package/src/{pages/Demo/ReactHookFormDemo/ReactHookFormDemo.module.css → demo/ui/pages/ReactHookFormDemo/ReactHookFormDemo.module.scss} +0 -0
- /package/src/{api → shared/infrastructure/http}/constant.ts +0 -0
- /package/src/{types/api.ts → shared/infrastructure/http/fetchApi.type.d.ts} +0 -0
package/src/forms/README.md
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
# 📁 forms
|
|
2
|
-
|
|
3
|
-
The "forms" folder is designed to organize and manage all the necessary forms in our application. Whether it's for managing vehicle-related risks, contact forms, or any other type of form, this folder is intended to centralize the logic and presentation of forms.
|
|
4
|
-
|
|
5
|
-
## 📑 Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Why Use a "forms" Folder](#folder-organization)
|
|
8
|
-
- [Typical Structure of a "forms" Folder](#structure)
|
|
9
|
-
- [Usage](#usage)
|
|
10
|
-
- [Using React Hook Form](#react-hook-form)
|
|
11
|
-
- [Best Practice](#best-practice)
|
|
12
|
-
|
|
13
|
-
## <span id="folder-organization">Why Use a "forms" Folder?</span>
|
|
14
|
-
|
|
15
|
-
1. **Organization** : By grouping all form components in a dedicated folder, we maintain a clean and clear project structure. This facilitates the search and management of forms.
|
|
16
|
-
|
|
17
|
-
2. **Reusability** : The form components we develop in this folder can be reused across different parts of the application, promoting code modularity.
|
|
18
|
-
|
|
19
|
-
3. **Code Clarity** : By separating form components from the application logic, we make our code more readable and easier to maintain.
|
|
20
|
-
|
|
21
|
-
## <span id="structure">Typical Structure of a "forms" Folder</span>
|
|
22
|
-
|
|
23
|
-
The structure of a "forms" folder can vary based on our project's needs, but here is a typical structure we might adopt:
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
📁 forms
|
|
27
|
-
├── 📁VehicleRiskForm
|
|
28
|
-
│ ├── 📄 index.ts
|
|
29
|
-
│ ├── 📄 VehicleRiskForm.tsx
|
|
30
|
-
│ ├── 📄 VehicleRiskForm.module.css
|
|
31
|
-
├── 📁ContactForm
|
|
32
|
-
│ ├── 📄 index.ts
|
|
33
|
-
│ ├── 📄 ContactForm.tsx
|
|
34
|
-
│ ├── 📄 ContactForm.module.css
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
In this structure, each form, such as "VehicleRiskForm" or "ContactForm," has its own sub-folder containing associated TypeScript and CSS files. This helps maintain a clear organization of our code.
|
|
38
|
-
|
|
39
|
-
## <span id="usage">🧑🏻💻Usage Example</span>
|
|
40
|
-
|
|
41
|
-
Suppose we have a "VehicleRiskForm" form component in the "forms/VehicleRiskForm" folder. We can import and use it in our React components like this:
|
|
42
|
-
|
|
43
|
-
```javascript
|
|
44
|
-
import { VehicleRiskForm } from '@Front/forms/VehicleRiskForm';
|
|
45
|
-
|
|
46
|
-
export const App = () => {
|
|
47
|
-
return (
|
|
48
|
-
<div>
|
|
49
|
-
<VehicleRiskForm />
|
|
50
|
-
{/* ... other elements of the application */}
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## <span id="react-hook-form">💡 Using React Hook Form</span>
|
|
57
|
-
|
|
58
|
-
This project utilizes [React Hook Form](https://react-hook-form.com/) for handling forms. React Hook Form is a powerful library for managing forms in React applications with a simple and intuitive API.
|
|
59
|
-
|
|
60
|
-
### React Hook Form Overview
|
|
61
|
-
|
|
62
|
-
[React Hook Form](https://react-hook-form.com/) is a library for managing forms in React applications. It offers a declarative approach to handling form state and validation, making it easy to create complex forms with minimal boilerplate.
|
|
63
|
-
|
|
64
|
-
#### Features:
|
|
65
|
-
|
|
66
|
-
- **Declarative Approach:** Define your forms with a declarative syntax, making it easy to understand and maintain.
|
|
67
|
-
|
|
68
|
-
- **Minimal Re-renders:** React Hook Form is designed to minimize re-renders for optimal performance.
|
|
69
|
-
|
|
70
|
-
- **Form Validation:** Easily implement form validation with built-in validation rules or custom validation functions.
|
|
71
|
-
|
|
72
|
-
- **Context API Integration:** Leverage React Hook Form's context API for managing form state across components.
|
|
73
|
-
|
|
74
|
-
### Implementation using React Hook Form Context
|
|
75
|
-
|
|
76
|
-
In this project, we've taken advantage of React Hook Form's context API to manage the state of our forms across different components. This allows us to access and update form data without prop drilling, making the codebase cleaner and more maintainable.
|
|
77
|
-
|
|
78
|
-
#### Example:
|
|
79
|
-
|
|
80
|
-
```jsx
|
|
81
|
-
import React from 'react';
|
|
82
|
-
import { useForm } from 'react-hook-form';
|
|
83
|
-
|
|
84
|
-
// Form component using React Hook Form
|
|
85
|
-
const MyForm = () => {
|
|
86
|
-
const { register, handleSubmit, formState } = useForm();
|
|
87
|
-
|
|
88
|
-
const onSubmit = data => {
|
|
89
|
-
// Handle form submission
|
|
90
|
-
console.log(data);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<form onSubmit={handleSubmit(onSubmit)}>
|
|
95
|
-
<label>
|
|
96
|
-
Name:
|
|
97
|
-
<input {...register('name', { required: true })} />
|
|
98
|
-
</label>
|
|
99
|
-
|
|
100
|
-
{/* Add more form fields as needed */}
|
|
101
|
-
|
|
102
|
-
<button type="submit" disabled={formState.isSubmitting}>
|
|
103
|
-
Submit
|
|
104
|
-
</button>
|
|
105
|
-
</form>
|
|
106
|
-
);
|
|
107
|
-
};
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
In the above example, we use the useForm hook to initialize the form and get the necessary methods (register, handleSubmit, and formState). The onSubmit function is called when the form is submitted, and you can access the form data from the data parameter.
|
|
111
|
-
|
|
112
|
-
**_By using React Hook Form in this way, we've streamlined the form management process and created a more maintainable and efficient solution for handling forms in our project._**
|
|
113
|
-
|
|
114
|
-
## <span id="best-practice">🎖️ Best Practice</span>
|
|
115
|
-
|
|
116
|
-
When working with `React-hook-form`, consider the following best practices to enhance maintainability and organization:
|
|
117
|
-
|
|
118
|
-
#### - Use FormProvider
|
|
119
|
-
|
|
120
|
-
Always use the `FormProvider` provided by `react-hook-form` to manage the form state.
|
|
121
|
-
|
|
122
|
-
This ensures a centralized state management approach and simplifies form-related operations.
|
|
123
|
-
|
|
124
|
-
#### - Separate Yup Validation Rules
|
|
125
|
-
|
|
126
|
-
If validation rules become extensive, consider separating them into a dedicated file for better organization. This enhances readability and simplifies updates to validation logic.
|
|
127
|
-
|
|
128
|
-
#### - Separate useForm Logic
|
|
129
|
-
|
|
130
|
-
Separate the logic related to `useForm` into a custom hook file, especially if the form logic is complex or if it is shared across multiple components.
|
|
131
|
-
|
|
132
|
-
#### - Separate onSubmit Function
|
|
133
|
-
|
|
134
|
-
If the `onSubmit` function logic is substantial, consider separating it into a dedicated file. This promotes a clean separation of concerns and makes the codebase more modular.
|
|
135
|
-
|
|
136
|
-
#### - Separate Submit Button
|
|
137
|
-
|
|
138
|
-
If needed, separate the submit button into its own file to facilitate easy customization or relocation from the main form component.
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
**_By adhering to these best practices, you create a structured and modular approach to form management, ensuring clarity and maintainability in your codebase._**
|
package/src/hooks/README.md
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
# 📁 hooks
|
|
2
|
-
|
|
3
|
-
The "hooks" folder is a directory you can create in your React project to group custom hooks you develop. Hooks are special functions introduced in React 16.8, allowing the management of state and lifecycle in functional components.
|
|
4
|
-
|
|
5
|
-
## 📑 Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Why Use a "hooks" Folder](#folder-organization)
|
|
8
|
-
- [Usage Example](#usage)
|
|
9
|
-
- [React-Query-Folder](#folder-react-query)
|
|
10
|
-
|
|
11
|
-
## <span id="folder-organization">Why Use a "hooks" Folder?</span>
|
|
12
|
-
|
|
13
|
-
1. **Code Reusability** : Custom hooks enable reusing state and lifecycle logic across multiple functional components, promoting code reuse and adhering to the DRY (Don't Repeat Yourself) principle.
|
|
14
|
-
|
|
15
|
-
2. **Separation of Concerns** : By grouping your custom hooks in a distinct folder, you maintain a clear separation between the business logic of your application and the React components themselves.
|
|
16
|
-
|
|
17
|
-
3. **Code Clarity** : Grouping custom hooks in a "hooks" folder simplifies code maintenance and readability, making it easier to locate and understand specific logic.
|
|
18
|
-
|
|
19
|
-
## <span id="usage">🧑🏻💻 Usage Example</span>
|
|
20
|
-
|
|
21
|
-
Suppose you have a custom hook "useCustomHook1.js" in the "hooks" folder. You can import it and use it in a functional component like this :
|
|
22
|
-
|
|
23
|
-
```javascript
|
|
24
|
-
import { useCustomHook1 } from './hooks/useCustomHook1';
|
|
25
|
-
|
|
26
|
-
export const MyComponent = () => {
|
|
27
|
-
const customData = useCustomHook1();
|
|
28
|
-
|
|
29
|
-
return <div>{/* Use customData in your component */}</div>;
|
|
30
|
-
};
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## <span id="folder-react-query">"api" Folder for React Query Requests</span>
|
|
34
|
-
|
|
35
|
-
Under the "hooks" folder, we have included a sub-folder "api" specifically designed to handle requests using React Query. This allows for more efficient organization of API requests, isolating them from component logic and leveraging the power of React Query for state and data caching.
|
|
36
|
-
|
|
37
|
-
The typical structure of this "api" folder might look like this:
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
📁 hooks
|
|
41
|
-
├── 📁 api
|
|
42
|
-
│ ├── 📄 useUsers.ts
|
|
43
|
-
│ ├── 📄 usePosts.ts
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Each file, such as "useUsers.ts" or "usePosts.ts," contains logic to perform requests specific to a given resource. You can then use these queries in your components by importing them appropriately.
|
|
47
|
-
|
|
48
|
-
Using React Query for API request management makes data retrieval, caching, and updating easier while reducing code complexity.
|
|
49
|
-
|
|
50
|
-
### What is React Query?
|
|
51
|
-
|
|
52
|
-
React Query is an open-source JavaScript library that simplifies data management in a React application. It provides a simple and powerful way to handle network requests, data caching, error handling, and more. With React Query, you can significantly improve the development experience of your React applications by managing data efficiently.
|
|
53
|
-
|
|
54
|
-
### Key Features
|
|
55
|
-
|
|
56
|
-
#### 1. Query Management
|
|
57
|
-
|
|
58
|
-
- React Query simplifies making API requests by providing hooks for GET, POST, PUT, DELETE, etc.
|
|
59
|
-
- You can easily specify query options such as parameters, headers, and more.
|
|
60
|
-
|
|
61
|
-
#### 2. Data Caching
|
|
62
|
-
|
|
63
|
-
- Retrieved data is automatically cached, avoiding unnecessary API calls.
|
|
64
|
-
- Custom caching rules can be defined for each query.
|
|
65
|
-
|
|
66
|
-
#### 3. State Management
|
|
67
|
-
|
|
68
|
-
- React Query automatically manages data state, providing loading, success, and error states for each query.
|
|
69
|
-
- You can easily access query states in your components.
|
|
70
|
-
|
|
71
|
-
#### 4. Automatic Refetching
|
|
72
|
-
|
|
73
|
-
- React Query offers automatic data refetching, ensuring data is automatically refreshed at regular intervals, improving data freshness.
|
|
74
|
-
|
|
75
|
-
#### 5. Mutation Management
|
|
76
|
-
|
|
77
|
-
- The library also facilitates mutation management, such as creating, updating, and deleting data.
|
|
78
|
-
- Mutations are easy to define and manage.
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
**_For more information and details, refer to the
|
|
83
|
-
[official React Query documentation.](https://tanstack.com/query/v3/)_**
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const demoQuery = () => ['dataWithDelay'];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { fetchDemoApi } from '@Front/api/demoApi';
|
|
2
|
-
import type { Users } from '@Front/types/demoApi';
|
|
3
|
-
import { useQuery } from '@tanstack/react-query';
|
|
4
|
-
import { demoQuery } from './queryKey';
|
|
5
|
-
|
|
6
|
-
type UseDemoApiReturn = {
|
|
7
|
-
result: Users;
|
|
8
|
-
isLoading: boolean;
|
|
9
|
-
isError: boolean;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const useDemoApi = (): UseDemoApiReturn => {
|
|
13
|
-
const { data = [], isLoading, isError } = useQuery<Users>({ queryKey: demoQuery(), queryFn: fetchDemoApi });
|
|
14
|
-
|
|
15
|
-
return { result: data, isLoading, isError };
|
|
16
|
-
};
|
package/src/pages/Demo/Demo.tsx
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import image from '@Front/assets/images/templatePlugins.png';
|
|
2
|
-
import { approutes } from '@Front/routing/appRoutes';
|
|
3
|
-
import { NavLink } from '@Front/ui/atoms/NavLink';
|
|
4
|
-
import classes from './Demo.module.scss';
|
|
5
|
-
|
|
6
|
-
export const Demo = () => {
|
|
7
|
-
return (
|
|
8
|
-
<div className={classes.container}>
|
|
9
|
-
<div className={classes.bigTitleStyle}>
|
|
10
|
-
Welcome to Your React Starter Kit <span>Welcome</span>
|
|
11
|
-
</div>
|
|
12
|
-
|
|
13
|
-
<div className={classes.foo}>FlexBlug</div>
|
|
14
|
-
|
|
15
|
-
<div className={classes.paragraphContainer}>
|
|
16
|
-
<h1 className={classes.titleStyle}>Overview</h1>
|
|
17
|
-
<div className={classes.infoSection}>
|
|
18
|
-
<span className={classes.centredText}>
|
|
19
|
-
<p className={classes.paragraphStyle}>
|
|
20
|
-
<span className={classes.highlight}>Congratulations</span> on starting your project with our{' '}
|
|
21
|
-
<span className={classes.highlight}>React Starter Kit!</span> This kit is designed to jumpstart your
|
|
22
|
-
development with a well-organized project structure and pre-configured tools.
|
|
23
|
-
</p>
|
|
24
|
-
<p className={classes.paragraphStyle}>
|
|
25
|
-
Below, you'll find an overview of the key features, tools, and architecture used in this starter kit.
|
|
26
|
-
</p>
|
|
27
|
-
</span>
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
<img src={image} alt="template" className={classes.imagePlace} />
|
|
31
|
-
|
|
32
|
-
<div className={classes.paragraphContainer}>
|
|
33
|
-
<h1 className={classes.titleStyle}>Objective</h1>
|
|
34
|
-
<div className={classes.infoSection}>
|
|
35
|
-
<p className={classes.paragraphStyle}>
|
|
36
|
-
The goal of this <span className={classes.boldText}>starter kit</span> is to enable you to quickly start a
|
|
37
|
-
new project with all the necessary tools.
|
|
38
|
-
</p>
|
|
39
|
-
<p className={classes.paragraphStyle}>
|
|
40
|
-
Additionally, this <span className={classes.boldText}>starter kit</span> offers a robust set of options for
|
|
41
|
-
structuring your <span className={classes.boldText}>React application</span>, providing flexibility to adapt
|
|
42
|
-
to various project architectures.
|
|
43
|
-
</p>
|
|
44
|
-
<p className={classes.paragraphStyle}>
|
|
45
|
-
It has been thoughtfully designed not only to expedite the initial setup but also to streamline the
|
|
46
|
-
implementation of <span className={classes.highlight}>Micro-Frontends</span>, making it a versatile solution
|
|
47
|
-
for projects of different scales. (for more details check the{' '}
|
|
48
|
-
<span className={classes.highlight}>README.md</span> file)
|
|
49
|
-
</p>
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
|
|
53
|
-
<div className={classes.paragraphContainer}>
|
|
54
|
-
<h1 className={classes.titleStyle}>Features</h1>
|
|
55
|
-
<div className={classes.infoSection}>
|
|
56
|
-
<p className={classes.paragraphStyle}>
|
|
57
|
-
<span className={classes.boldText}>React: </span>A JavaScript library for building user interfaces.
|
|
58
|
-
</p>
|
|
59
|
-
</div>
|
|
60
|
-
<div className={classes.infoSection}>
|
|
61
|
-
<p className={classes.paragraphStyle}>
|
|
62
|
-
<span className={classes.boldText}>TypeScript: </span>A superset of JavaScript that adds static typing.
|
|
63
|
-
</p>
|
|
64
|
-
</div>
|
|
65
|
-
<div className={classes.infoSection}>
|
|
66
|
-
<p className={classes.paragraphStyle}>
|
|
67
|
-
<span className={classes.boldText}>React Query: </span>A library for managing, caching, and updating server
|
|
68
|
-
state in React applications. (for more details check the{' '}
|
|
69
|
-
<span className={classes.highlight}>README.md</span> file under the{' '}
|
|
70
|
-
<span className={classes.boldText}>hooks</span> folder)
|
|
71
|
-
</p>
|
|
72
|
-
<div className={classes.demoStyle}>
|
|
73
|
-
<NavLink to={approutes.reactQueryDemo} className={classes.a}>
|
|
74
|
-
Run Demo
|
|
75
|
-
</NavLink>
|
|
76
|
-
</div>
|
|
77
|
-
</div>
|
|
78
|
-
<div className={classes.infoSection}>
|
|
79
|
-
<p className={classes.paragraphStyle}>
|
|
80
|
-
<span className={classes.boldText}>React Hook Form: </span>A library for managing forms with React hooks.
|
|
81
|
-
(for more details check the <span className={classes.highlight}>README.md</span> file under the{' '}
|
|
82
|
-
<span className={classes.boldText}>forms</span> folder)
|
|
83
|
-
</p>
|
|
84
|
-
<div className={classes.demoStyle}>
|
|
85
|
-
<NavLink to={approutes.reactHookFormDemo} className={classes.a}>
|
|
86
|
-
Run Demo
|
|
87
|
-
</NavLink>
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
|
|
91
|
-
<div className={classes.infoSection}>
|
|
92
|
-
<p className={classes.paragraphStyle}>
|
|
93
|
-
<span className={classes.boldText}>React Router: </span>A declarative routing solution for React. (for more
|
|
94
|
-
details check the <span className={classes.highlight}>README.md</span> file under the{' '}
|
|
95
|
-
<span className={classes.boldText}>routing</span> folder)
|
|
96
|
-
</p>
|
|
97
|
-
</div>
|
|
98
|
-
<div className={classes.infoSection}>
|
|
99
|
-
<p className={classes.paragraphStyle}>
|
|
100
|
-
<span className={classes.boldText}>...and more: </span>Explore the{' '}
|
|
101
|
-
<span className={classes.highlight}>Package.json</span> file to see additional dependencies.
|
|
102
|
-
</p>
|
|
103
|
-
</div>
|
|
104
|
-
</div>
|
|
105
|
-
|
|
106
|
-
<div className={classes.paragraphContainer}>
|
|
107
|
-
<h1 className={classes.titleStyle}>Project Structure</h1>
|
|
108
|
-
|
|
109
|
-
<div className={classes.infoSection}>
|
|
110
|
-
<div className={classes.tableWrapper}>
|
|
111
|
-
<table>
|
|
112
|
-
<thead>
|
|
113
|
-
<tr>
|
|
114
|
-
<th>Folder</th>
|
|
115
|
-
<th>Description</th>
|
|
116
|
-
</tr>
|
|
117
|
-
</thead>
|
|
118
|
-
<tbody>
|
|
119
|
-
<tr>
|
|
120
|
-
<td>
|
|
121
|
-
<span className={classes.boldText}>api</span>
|
|
122
|
-
</td>
|
|
123
|
-
<td>Place your API-related code here.</td>
|
|
124
|
-
</tr>
|
|
125
|
-
<tr>
|
|
126
|
-
<td>
|
|
127
|
-
<span className={classes.boldText}>assets</span>
|
|
128
|
-
</td>
|
|
129
|
-
<td>Store your static assets (images, fonts, etc.) in this directory.</td>
|
|
130
|
-
</tr>
|
|
131
|
-
<tr>
|
|
132
|
-
<td>
|
|
133
|
-
<span className={classes.boldText}>components</span>
|
|
134
|
-
</td>
|
|
135
|
-
<td>Reusable React components go here.</td>
|
|
136
|
-
</tr>
|
|
137
|
-
<tr>
|
|
138
|
-
<td>
|
|
139
|
-
<span className={classes.boldText}>config</span>
|
|
140
|
-
</td>
|
|
141
|
-
<td>Configuration files and environment variables are managed here.</td>
|
|
142
|
-
</tr>
|
|
143
|
-
<tr>
|
|
144
|
-
<td>
|
|
145
|
-
<span className={classes.boldText}>forms</span>
|
|
146
|
-
</td>
|
|
147
|
-
<td>Define your forms using React Hook Form.</td>
|
|
148
|
-
</tr>
|
|
149
|
-
<tr>
|
|
150
|
-
<td>
|
|
151
|
-
<span className={classes.boldText}>hooks</span>
|
|
152
|
-
</td>
|
|
153
|
-
<td>Custom React hooks to share logic across components.</td>
|
|
154
|
-
</tr>
|
|
155
|
-
<tr>
|
|
156
|
-
<td>
|
|
157
|
-
<span className={classes.boldText}>pages</span>
|
|
158
|
-
</td>
|
|
159
|
-
<td>React components that represent individual pages or views.</td>
|
|
160
|
-
</tr>
|
|
161
|
-
<tr>
|
|
162
|
-
<td>
|
|
163
|
-
<span className={classes.boldText}>providers</span>
|
|
164
|
-
</td>
|
|
165
|
-
<td>React context providers for state management.</td>
|
|
166
|
-
</tr>
|
|
167
|
-
<tr>
|
|
168
|
-
<td>
|
|
169
|
-
<span className={classes.boldText}>routing</span>
|
|
170
|
-
</td>
|
|
171
|
-
<td>Configure your application routes here.</td>
|
|
172
|
-
</tr>
|
|
173
|
-
<tr>
|
|
174
|
-
<td>
|
|
175
|
-
<span className={classes.boldText}>types</span>
|
|
176
|
-
</td>
|
|
177
|
-
<td>TypeScript type definitions.</td>
|
|
178
|
-
</tr>
|
|
179
|
-
<tr>
|
|
180
|
-
<td>
|
|
181
|
-
<span className={classes.boldText}>ui</span>
|
|
182
|
-
</td>
|
|
183
|
-
<td>Presentational components and styles.</td>
|
|
184
|
-
</tr>
|
|
185
|
-
<tr>
|
|
186
|
-
<td>
|
|
187
|
-
<span className={classes.boldText}>utils</span>
|
|
188
|
-
</td>
|
|
189
|
-
<td>General utility functions.</td>
|
|
190
|
-
</tr>
|
|
191
|
-
</tbody>
|
|
192
|
-
</table>
|
|
193
|
-
</div>
|
|
194
|
-
</div>
|
|
195
|
-
</div>
|
|
196
|
-
<div className={classes.paragraphContainer}>
|
|
197
|
-
<h1 className={classes.titleStyle}>Additional Information</h1>
|
|
198
|
-
<div className={classes.infoSection}>
|
|
199
|
-
<ul>
|
|
200
|
-
<li>
|
|
201
|
-
- Customize the project configuration in the <code>config</code> directory.
|
|
202
|
-
</li>
|
|
203
|
-
<li>
|
|
204
|
-
- Explore the <code>utils</code> directory for utility functions.
|
|
205
|
-
</li>
|
|
206
|
-
<li>- Leverage React Query for efficient data fetching.</li>
|
|
207
|
-
<li>- Take advantage of React Hook Form for managing forms seamlessly.</li>
|
|
208
|
-
<li>
|
|
209
|
-
- Refer to the <code>types</code> directory for TypeScript type definitions.
|
|
210
|
-
</li>
|
|
211
|
-
</ul>
|
|
212
|
-
</div>
|
|
213
|
-
<div className={classes.infoSection}>
|
|
214
|
-
<span className={classes.centredText}>
|
|
215
|
-
<p className={classes.paragraphStyle}>
|
|
216
|
-
Our project is organized into various folders, each containing its own{' '}
|
|
217
|
-
<span className={classes.highlight}>README.md</span> file with specific details, instructions, and
|
|
218
|
-
additional information. This documentation will guide you through setting up the environment,
|
|
219
|
-
understanding the project structure, and using the available components and features. For more details,
|
|
220
|
-
check the <span className={classes.highlight}>README.md</span> file in{' '}
|
|
221
|
-
<span className={classes.boldText}>each folder of the project</span>.
|
|
222
|
-
</p>
|
|
223
|
-
</span>
|
|
224
|
-
</div>
|
|
225
|
-
<div className={classes.infoSection}>
|
|
226
|
-
<span className={classes.centredText}>
|
|
227
|
-
<p className={classes.paragraphStyle}>
|
|
228
|
-
Feel free to explore and modify the structure to suit your project's needs.{' '}
|
|
229
|
-
<span className={classes.boldText}>Happy coding!</span>
|
|
230
|
-
</p>
|
|
231
|
-
</span>
|
|
232
|
-
</div>
|
|
233
|
-
</div>
|
|
234
|
-
</div>
|
|
235
|
-
);
|
|
236
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { reactHookFormDemoRoutes } from './routes';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { reactQueryDemoRoutes } from './routes';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react';
|
|
2
|
-
import { BrowserRouter as Router } from 'react-router';
|
|
3
|
-
import { Demo } from '../Demo';
|
|
4
|
-
|
|
5
|
-
describe('Demo Component', () => {
|
|
6
|
-
it('should render the Demo component correctly', () => {
|
|
7
|
-
const { container } = render(
|
|
8
|
-
<Router>
|
|
9
|
-
<Demo />
|
|
10
|
-
</Router>,
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
expect(container).toMatchSnapshot();
|
|
14
|
-
});
|
|
15
|
-
});
|