refactor(products): organize product showcase into feature module
This commit is contained in:
@@ -130,14 +130,8 @@ All components should be Server Components by default.
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
export default function UsersPage(){
|
export default function UsersPage() {
|
||||||
|
return <div>Users</div>;
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
Users
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -158,7 +152,7 @@ Examples:
|
|||||||
Then add:
|
Then add:
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
"use client"
|
'use client';
|
||||||
```
|
```
|
||||||
|
|
||||||
at the top.
|
at the top.
|
||||||
@@ -166,11 +160,9 @@ at the top.
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
"use client"
|
'use client';
|
||||||
|
|
||||||
export default function LoginForm(){
|
export default function LoginForm() {}
|
||||||
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Do not add `"use client"` unnecessarily.
|
Do not add `"use client"` unnecessarily.
|
||||||
@@ -274,10 +266,8 @@ Never call Axios directly inside components.
|
|||||||
Wrong:
|
Wrong:
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
function Users(){
|
function Users() {
|
||||||
|
axios.get('/users');
|
||||||
axios.get("/users")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -319,8 +309,8 @@ Example:
|
|||||||
|
|
||||||
```ts
|
```ts
|
||||||
export const api = axios.create({
|
export const api = axios.create({
|
||||||
baseURL: process.env.NEXT_PUBLIC_API_URL
|
baseURL: process.env.NEXT_PUBLIC_API_URL,
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -336,7 +326,6 @@ Examples:
|
|||||||
- Application settings
|
- Application settings
|
||||||
- Global UI state
|
- Global UI state
|
||||||
|
|
||||||
|
|
||||||
Structure:
|
Structure:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -383,20 +372,12 @@ store/provider.tsx
|
|||||||
```
|
```
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
"use client"
|
'use client';
|
||||||
|
|
||||||
import {Provider} from "react-redux"
|
import {Provider} from 'react-redux';
|
||||||
|
|
||||||
export function ReduxProvider({
|
|
||||||
children
|
|
||||||
}){
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Provider store={store}>
|
|
||||||
{children}
|
|
||||||
</Provider>
|
|
||||||
)
|
|
||||||
|
|
||||||
|
export function ReduxProvider({children}) {
|
||||||
|
return <Provider store={store}>{children}</Provider>;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -415,16 +396,16 @@ The project must be strongly typed.
|
|||||||
Avoid:
|
Avoid:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
any
|
any;
|
||||||
```
|
```
|
||||||
|
|
||||||
Prefer:
|
Prefer:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
interface
|
interface;
|
||||||
type
|
type;
|
||||||
generics
|
generics;
|
||||||
unknown
|
unknown;
|
||||||
```
|
```
|
||||||
|
|
||||||
Each feature owns its types:
|
Each feature owns its types:
|
||||||
@@ -446,7 +427,6 @@ Use Tailwind for:
|
|||||||
- Responsive design
|
- Responsive design
|
||||||
- Custom styling
|
- Custom styling
|
||||||
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
@@ -477,7 +457,6 @@ Examples:
|
|||||||
- Pagination
|
- Pagination
|
||||||
- Notification
|
- Notification
|
||||||
|
|
||||||
|
|
||||||
Use Tailwind for:
|
Use Tailwind for:
|
||||||
|
|
||||||
- Layout
|
- Layout
|
||||||
@@ -485,7 +464,6 @@ Use Tailwind for:
|
|||||||
- Spacing
|
- Spacing
|
||||||
- Responsive behavior
|
- Responsive behavior
|
||||||
|
|
||||||
|
|
||||||
Do not rewrite Ant Design components unless required.
|
Do not rewrite Ant Design components unless required.
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -568,12 +546,11 @@ When refactoring an existing project:
|
|||||||
3. Move code gradually into feature folders.
|
3. Move code gradually into feature folders.
|
||||||
4. Preserve existing functionality.
|
4. Preserve existing functionality.
|
||||||
5. Improve:
|
5. Improve:
|
||||||
- Type safety
|
- Type safety
|
||||||
- Separation of concerns
|
- Separation of concerns
|
||||||
- API abstraction
|
- API abstraction
|
||||||
- Component reuse
|
- Component reuse
|
||||||
- State management
|
- State management
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -619,4 +596,4 @@ The final project must be:
|
|||||||
|
|
||||||
Always prefer clean architecture over fast implementation.
|
Always prefer clean architecture over fast implementation.
|
||||||
|
|
||||||
Before creating code, understand where the code belongs in this architecture.
|
Before creating code, understand where the code belongs in this architecture.
|
||||||
|
|||||||
Reference in New Issue
Block a user