@gladpros/proposals
Version:
Proposal management module for GladPros applications
189 lines (145 loc) โข 4.17 kB
Markdown
# @gladpros/proposals
A comprehensive proposal management module for GladPros applications, providing complete CRUD operations, status tracking, and business logic for proposals.
## Features
- ๐ Complete proposal lifecycle management
- ๐ฐ Automatic price calculations and currency formatting
- ๐ Status tracking and analytics
- ๐ Advanced filtering and search
- ๐ File attachments support
- ๐ง Email notifications
- ๐ฑ Responsive React components
- ๐ TypeScript support with full type safety
## ๐ฆ Installation
```bash
npm install @gladpros/proposals
# or
yarn add @gladpros/proposals
# or
pnpm add @gladpros/proposals
```
## ๐ ๏ธ Peer Dependencies
This package requires the following peer dependencies:
```json
{
"react": "^18.0.0 || ^19.0.0",
"react-dom": "^18.0.0 || ^19.0.0",
"next": "^14.0.0 || ^15.0.0"
}
```
## ๐ Prerequisites
This module requires the following packages:
- `@gladpros/ui` - UI components library
- `@gladpros/auth` - Authentication module
And a database with the `propostas` table. See the database schema in the main GladPros repository for details.
## Quick Start
```tsx
import { ProposalProvider, useProposals, ProposalList } from '@gladpros/proposals'
function App() {
return (
<ProposalProvider>
<MyProposalsApp />
</ProposalProvider>
)
}
function MyProposalsApp() {
const { proposals, createProposal, updateProposal } = useProposals()
return (
<div>
<ProposalList proposals={proposals} />
<button onClick={() => createProposal(newProposalData)}>
Create Proposal
</button>
</div>
)
}
```
## API Reference
### Core Types
```typescript
interface Proposal {
id: string
title: string
description: string
clientId: string
status: ProposalStatus
value: number
items: ProposalItem[]
// ... more fields
}
enum ProposalStatus {
DRAFT = 'DRAFT',
SENT = 'SENT',
VIEWED = 'VIEWED',
ACCEPTED = 'ACCEPTED',
REJECTED = 'REJECTED',
EXPIRED = 'EXPIRED',
CANCELLED = 'CANCELLED'
}
```
### Hooks
#### `useProposals()`
Main hook for proposal management.
```tsx
const {
proposals, // Array of proposals
loading, // Loading state
error, // Error message
createProposal, // Create new proposal
updateProposal, // Update existing proposal
deleteProposal, // Delete proposal
getProposal, // Get single proposal
filterProposals // Filter proposals
} = useProposals()
```
### Components
#### `ProposalList`
Display list of proposals with filtering.
```tsx
<ProposalList
proposals={proposals}
onProposalClick={(proposal) => console.log(proposal)}
filters={activeFilters}
/>
```
#### `ProposalForm`
Form for creating/editing proposals.
```tsx
<ProposalForm
initialData={proposal}
onSubmit={handleSubmit}
onCancel={handleCancel}
/>
```
### Utilities
#### Currency Formatting
```typescript
import { formatCurrency, calculateProposalTotal } from '@gladpros/proposals/utils'
const formatted = formatCurrency(1234.56, 'BRL') // "R$ 1.234,56"
const total = calculateProposalTotal(proposal.items)
```
## Development
```bash
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Run tests
npm run test
```
## Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## License
MIT ยฉ GladPros Team
---
*๐ฆ Primeira publicaรงรฃo automรกtica - 12 de setembro de 2025*
## ๐ Links
- [GitHub Repository](https://github.com/Gladiston-Porto/gladpros-proposals)
- [Issues](https://github.com/Gladiston-Porto/gladpros-proposals/issues)
- [Discussions](https://github.com/Gladiston-Porto/gladpros-proposals/discussions)
- [Main GladPros Repository](https://github.com/Gladiston-Porto/GladPros)