Fix manual signup flow
Adjusted the manual signup flow to prevent users from being redirected to the profile completion page after logging in. This resolves an issue where users who registered manually were repeatedly prompted for information they had already provided.
This commit is contained in:
parent
dc896299ca
commit
13261836a0
@ -7,6 +7,11 @@ export type Json =
|
|||||||
| Json[]
|
| Json[]
|
||||||
|
|
||||||
export type Database = {
|
export type Database = {
|
||||||
|
// Allows to automatically instantiate createClient with right options
|
||||||
|
// instead of createClient<Database, { PostgrestVersion: 'XX' }>(URL, KEY)
|
||||||
|
__InternalSupabase: {
|
||||||
|
PostgrestVersion: "12.2.3 (519615d)"
|
||||||
|
}
|
||||||
public: {
|
public: {
|
||||||
Tables: {
|
Tables: {
|
||||||
"1001_amore_conselheira": {
|
"1001_amore_conselheira": {
|
||||||
@ -561,6 +566,195 @@ export type Database = {
|
|||||||
}
|
}
|
||||||
Relationships: []
|
Relationships: []
|
||||||
}
|
}
|
||||||
|
n8n_chat_dolceamore: {
|
||||||
|
Row: {
|
||||||
|
id: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Insert: {
|
||||||
|
id?: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Update: {
|
||||||
|
id?: number
|
||||||
|
message?: Json
|
||||||
|
session_id?: string
|
||||||
|
}
|
||||||
|
Relationships: []
|
||||||
|
}
|
||||||
|
n8n_chat_dolceamoree: {
|
||||||
|
Row: {
|
||||||
|
id: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Insert: {
|
||||||
|
id?: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Update: {
|
||||||
|
id?: number
|
||||||
|
message?: Json
|
||||||
|
session_id?: string
|
||||||
|
}
|
||||||
|
Relationships: []
|
||||||
|
}
|
||||||
|
n8n_chat_histories: {
|
||||||
|
Row: {
|
||||||
|
id: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Insert: {
|
||||||
|
id?: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Update: {
|
||||||
|
id?: number
|
||||||
|
message?: Json
|
||||||
|
session_id?: string
|
||||||
|
}
|
||||||
|
Relationships: []
|
||||||
|
}
|
||||||
|
n8n_chat_histories_primeade: {
|
||||||
|
Row: {
|
||||||
|
id: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Insert: {
|
||||||
|
id?: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Update: {
|
||||||
|
id?: number
|
||||||
|
message?: Json
|
||||||
|
session_id?: string
|
||||||
|
}
|
||||||
|
Relationships: []
|
||||||
|
}
|
||||||
|
n8n_chat_primevl: {
|
||||||
|
Row: {
|
||||||
|
id: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Insert: {
|
||||||
|
id?: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Update: {
|
||||||
|
id?: number
|
||||||
|
message?: Json
|
||||||
|
session_id?: string
|
||||||
|
}
|
||||||
|
Relationships: []
|
||||||
|
}
|
||||||
|
n8n_chat_qnn01: {
|
||||||
|
Row: {
|
||||||
|
id: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Insert: {
|
||||||
|
id?: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Update: {
|
||||||
|
id?: number
|
||||||
|
message?: Json
|
||||||
|
session_id?: string
|
||||||
|
}
|
||||||
|
Relationships: []
|
||||||
|
}
|
||||||
|
n8n_chat_recanto: {
|
||||||
|
Row: {
|
||||||
|
id: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Insert: {
|
||||||
|
id?: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Update: {
|
||||||
|
id?: number
|
||||||
|
message?: Json
|
||||||
|
session_id?: string
|
||||||
|
}
|
||||||
|
Relationships: []
|
||||||
|
}
|
||||||
|
n8n_chat_samambaia: {
|
||||||
|
Row: {
|
||||||
|
id: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Insert: {
|
||||||
|
id?: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Update: {
|
||||||
|
id?: number
|
||||||
|
message?: Json
|
||||||
|
session_id?: string
|
||||||
|
}
|
||||||
|
Relationships: []
|
||||||
|
}
|
||||||
|
n8n_fila_mensagens: {
|
||||||
|
Row: {
|
||||||
|
id: number
|
||||||
|
id_mensagem: string
|
||||||
|
mensagem: string
|
||||||
|
telefone: string
|
||||||
|
timestamp: string
|
||||||
|
}
|
||||||
|
Insert: {
|
||||||
|
id?: number
|
||||||
|
id_mensagem: string
|
||||||
|
mensagem: string
|
||||||
|
telefone: string
|
||||||
|
timestamp: string
|
||||||
|
}
|
||||||
|
Update: {
|
||||||
|
id?: number
|
||||||
|
id_mensagem?: string
|
||||||
|
mensagem?: string
|
||||||
|
telefone?: string
|
||||||
|
timestamp?: string
|
||||||
|
}
|
||||||
|
Relationships: []
|
||||||
|
}
|
||||||
|
n8n_historico_mensagens: {
|
||||||
|
Row: {
|
||||||
|
created_at: string
|
||||||
|
id: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Insert: {
|
||||||
|
created_at?: string
|
||||||
|
id?: number
|
||||||
|
message: Json
|
||||||
|
session_id: string
|
||||||
|
}
|
||||||
|
Update: {
|
||||||
|
created_at?: string
|
||||||
|
id?: number
|
||||||
|
message?: Json
|
||||||
|
session_id?: string
|
||||||
|
}
|
||||||
|
Relationships: []
|
||||||
|
}
|
||||||
pagamentos_mercadopago: {
|
pagamentos_mercadopago: {
|
||||||
Row: {
|
Row: {
|
||||||
created_at: string
|
created_at: string
|
||||||
@ -647,6 +841,24 @@ export type Database = {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
profiles: {
|
||||||
|
Row: {
|
||||||
|
document_number: string | null
|
||||||
|
full_name: string | null
|
||||||
|
id: string
|
||||||
|
}
|
||||||
|
Insert: {
|
||||||
|
document_number?: string | null
|
||||||
|
full_name?: string | null
|
||||||
|
id: string
|
||||||
|
}
|
||||||
|
Update: {
|
||||||
|
document_number?: string | null
|
||||||
|
full_name?: string | null
|
||||||
|
id?: string
|
||||||
|
}
|
||||||
|
Relationships: []
|
||||||
|
}
|
||||||
status_pagamento_mensal: {
|
status_pagamento_mensal: {
|
||||||
Row: {
|
Row: {
|
||||||
ano: number
|
ano: number
|
||||||
@ -792,10 +1004,10 @@ export type Database = {
|
|||||||
Returns: unknown
|
Returns: unknown
|
||||||
}
|
}
|
||||||
conselheiraamore: {
|
conselheiraamore: {
|
||||||
Args: { query_embedding: string; match_count?: number; filter?: Json }
|
Args: { filter?: Json; match_count?: number; query_embedding: string }
|
||||||
Returns: {
|
Returns: {
|
||||||
id: number
|
|
||||||
content: string
|
content: string
|
||||||
|
id: number
|
||||||
metadata: Json
|
metadata: Json
|
||||||
similarity: number
|
similarity: number
|
||||||
}[]
|
}[]
|
||||||
@ -854,11 +1066,11 @@ export type Database = {
|
|||||||
}
|
}
|
||||||
registrar_usuario: {
|
registrar_usuario: {
|
||||||
Args:
|
Args:
|
||||||
| { nome: string; empresa: string; email: string; senha: string }
|
| { email: string; empresa: string; nome: string; senha: string }
|
||||||
| {
|
| {
|
||||||
nome: string
|
|
||||||
empresa: string
|
|
||||||
email: string
|
email: string
|
||||||
|
empresa: string
|
||||||
|
nome: string
|
||||||
senha: string
|
senha: string
|
||||||
whatsapp: string
|
whatsapp: string
|
||||||
}
|
}
|
||||||
@ -910,21 +1122,25 @@ export type Database = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DefaultSchema = Database[Extract<keyof Database, "public">]
|
type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">
|
||||||
|
|
||||||
|
type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">]
|
||||||
|
|
||||||
export type Tables<
|
export type Tables<
|
||||||
DefaultSchemaTableNameOrOptions extends
|
DefaultSchemaTableNameOrOptions extends
|
||||||
| keyof (DefaultSchema["Tables"] & DefaultSchema["Views"])
|
| keyof (DefaultSchema["Tables"] & DefaultSchema["Views"])
|
||||||
| { schema: keyof Database },
|
| { schema: keyof DatabaseWithoutInternals },
|
||||||
TableName extends DefaultSchemaTableNameOrOptions extends {
|
TableName extends DefaultSchemaTableNameOrOptions extends {
|
||||||
schema: keyof Database
|
schema: keyof DatabaseWithoutInternals
|
||||||
}
|
}
|
||||||
? keyof (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
|
? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
|
||||||
Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
|
DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
|
||||||
: never = never,
|
: never = never,
|
||||||
> = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
|
> = DefaultSchemaTableNameOrOptions extends {
|
||||||
? (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
|
schema: keyof DatabaseWithoutInternals
|
||||||
Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
|
}
|
||||||
|
? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
|
||||||
|
DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
|
||||||
Row: infer R
|
Row: infer R
|
||||||
}
|
}
|
||||||
? R
|
? R
|
||||||
@ -942,14 +1158,16 @@ export type Tables<
|
|||||||
export type TablesInsert<
|
export type TablesInsert<
|
||||||
DefaultSchemaTableNameOrOptions extends
|
DefaultSchemaTableNameOrOptions extends
|
||||||
| keyof DefaultSchema["Tables"]
|
| keyof DefaultSchema["Tables"]
|
||||||
| { schema: keyof Database },
|
| { schema: keyof DatabaseWithoutInternals },
|
||||||
TableName extends DefaultSchemaTableNameOrOptions extends {
|
TableName extends DefaultSchemaTableNameOrOptions extends {
|
||||||
schema: keyof Database
|
schema: keyof DatabaseWithoutInternals
|
||||||
}
|
}
|
||||||
? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
|
? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
|
||||||
: never = never,
|
: never = never,
|
||||||
> = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
|
> = DefaultSchemaTableNameOrOptions extends {
|
||||||
? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
schema: keyof DatabaseWithoutInternals
|
||||||
|
}
|
||||||
|
? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
||||||
Insert: infer I
|
Insert: infer I
|
||||||
}
|
}
|
||||||
? I
|
? I
|
||||||
@ -965,14 +1183,16 @@ export type TablesInsert<
|
|||||||
export type TablesUpdate<
|
export type TablesUpdate<
|
||||||
DefaultSchemaTableNameOrOptions extends
|
DefaultSchemaTableNameOrOptions extends
|
||||||
| keyof DefaultSchema["Tables"]
|
| keyof DefaultSchema["Tables"]
|
||||||
| { schema: keyof Database },
|
| { schema: keyof DatabaseWithoutInternals },
|
||||||
TableName extends DefaultSchemaTableNameOrOptions extends {
|
TableName extends DefaultSchemaTableNameOrOptions extends {
|
||||||
schema: keyof Database
|
schema: keyof DatabaseWithoutInternals
|
||||||
}
|
}
|
||||||
? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
|
? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
|
||||||
: never = never,
|
: never = never,
|
||||||
> = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
|
> = DefaultSchemaTableNameOrOptions extends {
|
||||||
? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
schema: keyof DatabaseWithoutInternals
|
||||||
|
}
|
||||||
|
? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
||||||
Update: infer U
|
Update: infer U
|
||||||
}
|
}
|
||||||
? U
|
? U
|
||||||
@ -988,14 +1208,16 @@ export type TablesUpdate<
|
|||||||
export type Enums<
|
export type Enums<
|
||||||
DefaultSchemaEnumNameOrOptions extends
|
DefaultSchemaEnumNameOrOptions extends
|
||||||
| keyof DefaultSchema["Enums"]
|
| keyof DefaultSchema["Enums"]
|
||||||
| { schema: keyof Database },
|
| { schema: keyof DatabaseWithoutInternals },
|
||||||
EnumName extends DefaultSchemaEnumNameOrOptions extends {
|
EnumName extends DefaultSchemaEnumNameOrOptions extends {
|
||||||
schema: keyof Database
|
schema: keyof DatabaseWithoutInternals
|
||||||
}
|
}
|
||||||
? keyof Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
|
? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
|
||||||
: never = never,
|
: never = never,
|
||||||
> = DefaultSchemaEnumNameOrOptions extends { schema: keyof Database }
|
> = DefaultSchemaEnumNameOrOptions extends {
|
||||||
? Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
|
schema: keyof DatabaseWithoutInternals
|
||||||
|
}
|
||||||
|
? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
|
||||||
: DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"]
|
: DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"]
|
||||||
? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions]
|
? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions]
|
||||||
: never
|
: never
|
||||||
@ -1003,14 +1225,16 @@ export type Enums<
|
|||||||
export type CompositeTypes<
|
export type CompositeTypes<
|
||||||
PublicCompositeTypeNameOrOptions extends
|
PublicCompositeTypeNameOrOptions extends
|
||||||
| keyof DefaultSchema["CompositeTypes"]
|
| keyof DefaultSchema["CompositeTypes"]
|
||||||
| { schema: keyof Database },
|
| { schema: keyof DatabaseWithoutInternals },
|
||||||
CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
|
CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
|
||||||
schema: keyof Database
|
schema: keyof DatabaseWithoutInternals
|
||||||
}
|
}
|
||||||
? keyof Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
|
? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
|
||||||
: never = never,
|
: never = never,
|
||||||
> = PublicCompositeTypeNameOrOptions extends { schema: keyof Database }
|
> = PublicCompositeTypeNameOrOptions extends {
|
||||||
? Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
|
schema: keyof DatabaseWithoutInternals
|
||||||
|
}
|
||||||
|
? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
|
||||||
: PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"]
|
: PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"]
|
||||||
? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions]
|
? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions]
|
||||||
: never
|
: never
|
||||||
|
|||||||
@ -131,70 +131,87 @@ const CompleteProfile = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center min-h-screen bg-gray-50 px-4">
|
<div className="min-h-screen bg-gradient-to-br from-background via-primary/5 to-accent/10 flex items-center justify-center p-4">
|
||||||
<Card className="w-full max-w-md">
|
<div className="w-full max-w-md">
|
||||||
<CardHeader className="space-y-1 text-center">
|
<Card className="glass-card border-white/10 backdrop-blur-xl bg-white/80 dark:bg-gray-900/80 shadow-2xl">
|
||||||
<CardTitle className="text-2xl font-bold">Complete seu Perfil</CardTitle>
|
<CardHeader className="space-y-2 text-center pb-6">
|
||||||
<CardDescription>
|
<CardTitle className="text-2xl font-bold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||||
Para continuar, precisamos de algumas informações obrigatórias para configurar sua conta
|
Complete seu Perfil
|
||||||
</CardDescription>
|
</CardTitle>
|
||||||
</CardHeader>
|
<CardDescription className="text-muted-foreground/80">
|
||||||
<CardContent>
|
Para continuar, precisamos de algumas informações obrigatórias para configurar sua conta
|
||||||
<form onSubmit={handleSubmit} className="space-y-4">
|
</CardDescription>
|
||||||
<div className="space-y-2">
|
</CardHeader>
|
||||||
<Label htmlFor="nome">Nome Completo *</Label>
|
<CardContent className="space-y-6">
|
||||||
<Input
|
<form onSubmit={handleSubmit} className="space-y-5">
|
||||||
id="nome"
|
<div className="space-y-2">
|
||||||
type="text"
|
<Label htmlFor="nome" className="text-sm font-medium text-foreground/90">
|
||||||
placeholder="Seu nome completo"
|
Nome Completo *
|
||||||
value={nome}
|
</Label>
|
||||||
onChange={(e) => setNome(e.target.value)}
|
<Input
|
||||||
required
|
id="nome"
|
||||||
disabled={isLoading}
|
type="text"
|
||||||
/>
|
placeholder="Seu nome completo"
|
||||||
</div>
|
value={nome}
|
||||||
|
onChange={(e) => setNome(e.target.value)}
|
||||||
|
required
|
||||||
|
disabled={isLoading}
|
||||||
|
className="glass-input border-white/20 bg-white/50 backdrop-blur-sm focus:border-primary/50 focus:ring-primary/20"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label htmlFor="empresa">Empresa (Opcional)</Label>
|
<Label htmlFor="empresa" className="text-sm font-medium text-foreground/90">
|
||||||
<Input
|
Empresa (Opcional)
|
||||||
id="empresa"
|
</Label>
|
||||||
type="text"
|
<Input
|
||||||
placeholder="Nome da sua empresa"
|
id="empresa"
|
||||||
value={empresa}
|
type="text"
|
||||||
onChange={(e) => setEmpresa(e.target.value)}
|
placeholder="Nome da sua empresa"
|
||||||
disabled={isLoading}
|
value={empresa}
|
||||||
/>
|
onChange={(e) => setEmpresa(e.target.value)}
|
||||||
</div>
|
disabled={isLoading}
|
||||||
|
className="glass-input border-white/20 bg-white/50 backdrop-blur-sm focus:border-primary/50 focus:ring-primary/20"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label htmlFor="whatsapp">WhatsApp *</Label>
|
<Label htmlFor="whatsapp" className="text-sm font-medium text-foreground/90">
|
||||||
<Input
|
WhatsApp *
|
||||||
id="whatsapp"
|
</Label>
|
||||||
type="tel"
|
<Input
|
||||||
placeholder="(11) 99999-9999"
|
id="whatsapp"
|
||||||
value={whatsapp}
|
type="tel"
|
||||||
onChange={(e) => handleWhatsappChange(e.target.value)}
|
placeholder="(11) 99999-9999"
|
||||||
required
|
value={whatsapp}
|
||||||
|
onChange={(e) => handleWhatsappChange(e.target.value)}
|
||||||
|
required
|
||||||
|
disabled={isLoading}
|
||||||
|
className="glass-input border-white/20 bg-white/50 backdrop-blur-sm focus:border-primary/50 focus:ring-primary/20"
|
||||||
|
/>
|
||||||
|
<p className="text-xs text-muted-foreground/70">
|
||||||
|
Necessário para integração com WhatsApp e notificações
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
className="w-full glass-button bg-gradient-to-r from-primary to-accent hover:shadow-lg hover:shadow-primary/25 transition-all duration-300"
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
/>
|
>
|
||||||
<p className="text-xs text-muted-foreground">
|
{isLoading ? "Salvando..." : "Completar Perfil"}
|
||||||
Necessário para integração com WhatsApp e notificações
|
</Button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div className="glass-card p-4 border-primary/10 bg-primary/5">
|
||||||
|
<p className="text-sm text-primary/90">
|
||||||
|
<strong className="text-primary">Por que estes dados?</strong><br />
|
||||||
|
Nome e WhatsApp são necessários para configurar automaticamente seu workspace e integrações personalizadas.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
</CardContent>
|
||||||
<Button type="submit" className="w-full" disabled={isLoading}>
|
</Card>
|
||||||
{isLoading ? "Salvando..." : "Completar Perfil"}
|
</div>
|
||||||
</Button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<div className="mt-4 p-3 bg-blue-50 rounded-lg">
|
|
||||||
<p className="text-sm text-blue-800">
|
|
||||||
<strong>Por que estes dados?</strong><br />
|
|
||||||
Nome e WhatsApp são necessários para configurar automaticamente seu workspace e integrações personalizadas.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -0,0 +1,41 @@
|
|||||||
|
-- Criar trigger para automaticamente criar usuário na tabela usuarios quando se cadastra manualmente
|
||||||
|
CREATE OR REPLACE FUNCTION public.handle_manual_user_signup()
|
||||||
|
RETURNS trigger
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
SECURITY DEFINER
|
||||||
|
SET search_path = public
|
||||||
|
AS $$
|
||||||
|
BEGIN
|
||||||
|
-- Verificar se o usuário tem dados completos no raw_user_meta_data (cadastro manual)
|
||||||
|
IF NEW.raw_user_meta_data IS NOT NULL AND
|
||||||
|
NEW.raw_user_meta_data->>'nome' IS NOT NULL AND
|
||||||
|
NEW.raw_user_meta_data->>'whatsapp' IS NOT NULL AND
|
||||||
|
NEW.email IS NOT NULL THEN
|
||||||
|
|
||||||
|
-- Inserir na tabela usuarios
|
||||||
|
INSERT INTO public.usuarios (id, email, nome, empresa, whatsapp)
|
||||||
|
VALUES (
|
||||||
|
NEW.id,
|
||||||
|
NEW.email,
|
||||||
|
NEW.raw_user_meta_data->>'nome',
|
||||||
|
COALESCE(NEW.raw_user_meta_data->>'empresa', ''),
|
||||||
|
NEW.raw_user_meta_data->>'whatsapp'
|
||||||
|
)
|
||||||
|
ON CONFLICT (id) DO UPDATE SET
|
||||||
|
nome = EXCLUDED.nome,
|
||||||
|
empresa = EXCLUDED.empresa,
|
||||||
|
whatsapp = EXCLUDED.whatsapp,
|
||||||
|
email = EXCLUDED.email;
|
||||||
|
|
||||||
|
RETURN NEW;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- Criar trigger que será executado quando um usuário é inserido na tabela auth.users
|
||||||
|
DROP TRIGGER IF EXISTS on_auth_user_created_manual ON auth.users;
|
||||||
|
CREATE TRIGGER on_auth_user_created_manual
|
||||||
|
AFTER INSERT ON auth.users
|
||||||
|
FOR EACH ROW EXECUTE FUNCTION public.handle_manual_user_signup();
|
||||||
Loading…
Reference in New Issue
Block a user