fix: fixup leads
This commit is contained in:
@@ -30,10 +30,16 @@ func (h *Handler) Create(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "requête invalide"})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "requête invalide"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l, err := h.store.Create(Lead{
|
|
||||||
|
lead := Lead{
|
||||||
Telegram: sanitize(req.Telegram),
|
Telegram: sanitize(req.Telegram),
|
||||||
Message: sanitize(req.Message),
|
}
|
||||||
})
|
|
||||||
|
if msg := sanitize(req.Message); msg != "" {
|
||||||
|
lead.Message = &msg
|
||||||
|
}
|
||||||
|
|
||||||
|
l, err := h.store.Create(lead)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "erreur serveur"})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "erreur serveur"})
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func (s Status) Valid() bool {
|
|||||||
type Lead struct {
|
type Lead struct {
|
||||||
ID string `gorm:"type:uuid;primaryKey" json:"id"`
|
ID string `gorm:"type:uuid;primaryKey" json:"id"`
|
||||||
Telegram string `gorm:"size:120;not null" json:"telegram"`
|
Telegram string `gorm:"size:120;not null" json:"telegram"`
|
||||||
Message string `gorm:"size:2000" json:"message"`
|
Message *string `gorm:"size:2000" json:"message"`
|
||||||
Status Status `gorm:"size:20;not null;index" json:"status"`
|
Status Status `gorm:"size:20;not null;index" json:"status"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-4
@@ -46,9 +46,8 @@ export type Role = 'admin' | 'client'
|
|||||||
|
|
||||||
export interface Lead {
|
export interface Lead {
|
||||||
id: string
|
id: string
|
||||||
company: string
|
Telegram: string
|
||||||
email: string
|
message?: string
|
||||||
message: string
|
|
||||||
status: string
|
status: string
|
||||||
created_at: string
|
created_at: string
|
||||||
}
|
}
|
||||||
@@ -124,7 +123,7 @@ export const api = {
|
|||||||
expired_at: string
|
expired_at: string
|
||||||
}>('GET', '/auth/me'), logout: () => request<{ status: string }>('POST', '/auth/logout'),
|
}>('GET', '/auth/me'), logout: () => request<{ status: string }>('POST', '/auth/logout'),
|
||||||
|
|
||||||
createLead: (telegram: string, message: string) =>
|
createLead: (telegram: string, message?: string) =>
|
||||||
request<Lead>('POST', '/leads', { telegram, message }),
|
request<Lead>('POST', '/leads', { telegram, message }),
|
||||||
listLeads: () => request<{ items: Lead[] }>('GET', '/leads'),
|
listLeads: () => request<{ items: Lead[] }>('GET', '/leads'),
|
||||||
setLeadStatus: (id: string, status: string) =>
|
setLeadStatus: (id: string, status: string) =>
|
||||||
|
|||||||
@@ -314,9 +314,6 @@ export function Demos() {
|
|||||||
<Text color="gray.500">Aucune donnée.</Text>
|
<Text color="gray.500">Aucune donnée.</Text>
|
||||||
)}
|
)}
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
|
||||||
<Button onClick={closeDetails}>Fermer</Button>
|
|
||||||
</ModalFooter>
|
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -81,8 +81,7 @@ export function Leads() {
|
|||||||
<Tbody>
|
<Tbody>
|
||||||
{leads.map((l) => (
|
{leads.map((l) => (
|
||||||
<Tr key={l.id}>
|
<Tr key={l.id}>
|
||||||
<Td fontWeight="medium">{l.company}</Td>
|
<Td fontWeight="medium">{l.Telegram}</Td>
|
||||||
<Td>{l.email}</Td>
|
|
||||||
<Td>
|
<Td>
|
||||||
<Badge>{l.status}</Badge>
|
<Badge>{l.status}</Badge>
|
||||||
</Td>
|
</Td>
|
||||||
|
|||||||
Reference in New Issue
Block a user