mirror of
https://github.com/Luchexx/wacrm.git
synced 2026-11-02 09:19:51 +00:00
Merge pull request #5 from ArnasDon/perf/use-get-session-client-side
perf: use getSession() instead of getUser() in client components
This commit is contained in:
commit
aaaddf0d5a
@ -25,8 +25,9 @@ export default function InboxPage() {
|
|||||||
const checkConnection = async () => {
|
const checkConnection = async () => {
|
||||||
const supabase = createClient();
|
const supabase = createClient();
|
||||||
const {
|
const {
|
||||||
data: { user },
|
data: { session },
|
||||||
} = await supabase.auth.getUser();
|
} = await supabase.auth.getSession();
|
||||||
|
const user = session?.user;
|
||||||
|
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|
||||||
|
|||||||
@ -85,8 +85,9 @@ export default function PipelinesPage() {
|
|||||||
setCreating(true);
|
setCreating(true);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { user },
|
data: { session },
|
||||||
} = await supabase.auth.getUser();
|
} = await supabase.auth.getSession();
|
||||||
|
const user = session?.user;
|
||||||
if (!user) {
|
if (!user) {
|
||||||
setCreating(false);
|
setCreating(false);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -223,8 +223,9 @@ export function ContactDetailView({
|
|||||||
setSavingNote(true);
|
setSavingNote(true);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { user },
|
data: { session },
|
||||||
} = await supabase.auth.getUser();
|
} = await supabase.auth.getSession();
|
||||||
|
const user = session?.user;
|
||||||
if (!user) {
|
if (!user) {
|
||||||
toast.error('Not authenticated');
|
toast.error('Not authenticated');
|
||||||
setSavingNote(false);
|
setSavingNote(false);
|
||||||
|
|||||||
@ -87,8 +87,9 @@ export function ContactForm({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
data: { user },
|
data: { session },
|
||||||
} = await supabase.auth.getUser();
|
} = await supabase.auth.getSession();
|
||||||
|
const user = session?.user;
|
||||||
if (!user) throw new Error('Not authenticated');
|
if (!user) throw new Error('Not authenticated');
|
||||||
|
|
||||||
let contactId = contact?.id;
|
let contactId = contact?.id;
|
||||||
|
|||||||
@ -123,8 +123,9 @@ export function ImportModal({ open, onOpenChange, onImported }: ImportModalProps
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
data: { user },
|
data: { session },
|
||||||
} = await supabase.auth.getUser();
|
} = await supabase.auth.getSession();
|
||||||
|
const user = session?.user;
|
||||||
if (!user) throw new Error('Not authenticated');
|
if (!user) throw new Error('Not authenticated');
|
||||||
|
|
||||||
let imported = 0;
|
let imported = 0;
|
||||||
|
|||||||
@ -84,8 +84,9 @@ export function ContactSidebar({ contact }: ContactSidebarProps) {
|
|||||||
|
|
||||||
const supabase = createClient();
|
const supabase = createClient();
|
||||||
const {
|
const {
|
||||||
data: { user },
|
data: { session },
|
||||||
} = await supabase.auth.getUser();
|
} = await supabase.auth.getSession();
|
||||||
|
const user = session?.user;
|
||||||
|
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from("contact_notes")
|
.from("contact_notes")
|
||||||
|
|||||||
@ -96,8 +96,9 @@ export function DealForm({
|
|||||||
await supabase.from("deals").update(payload).eq("id", deal.id);
|
await supabase.from("deals").update(payload).eq("id", deal.id);
|
||||||
} else {
|
} else {
|
||||||
const {
|
const {
|
||||||
data: { user },
|
data: { session },
|
||||||
} = await supabase.auth.getUser();
|
} = await supabase.auth.getSession();
|
||||||
|
const user = session?.user;
|
||||||
if (user) {
|
if (user) {
|
||||||
await supabase
|
await supabase
|
||||||
.from("deals")
|
.from("deals")
|
||||||
|
|||||||
@ -92,8 +92,9 @@ export function PipelineSettings({
|
|||||||
async function handleAddStage() {
|
async function handleAddStage() {
|
||||||
if (!newStageName.trim()) return;
|
if (!newStageName.trim()) return;
|
||||||
const {
|
const {
|
||||||
data: { user },
|
data: { session },
|
||||||
} = await supabase.auth.getUser();
|
} = await supabase.auth.getSession();
|
||||||
|
const user = session?.user;
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|
||||||
const { data } = await supabase
|
const { data } = await supabase
|
||||||
|
|||||||
@ -49,7 +49,7 @@ export function TagManager() {
|
|||||||
async function fetchTags() {
|
async function fetchTags() {
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const { data: { user } } = await supabase.auth.getUser();
|
const { data: { session } } = await supabase.auth.getSession(); const user = session?.user;
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
@ -76,7 +76,7 @@ export function TagManager() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
const { data: { user } } = await supabase.auth.getUser();
|
const { data: { session } } = await supabase.auth.getSession(); const user = session?.user;
|
||||||
if (!user) {
|
if (!user) {
|
||||||
toast.error('Not authenticated');
|
toast.error('Not authenticated');
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -77,7 +77,7 @@ export function TemplateManager() {
|
|||||||
async function fetchTemplates() {
|
async function fetchTemplates() {
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const { data: { user } } = await supabase.auth.getUser();
|
const { data: { session } } = await supabase.auth.getSession(); const user = session?.user;
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
@ -108,7 +108,7 @@ export function TemplateManager() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
const { data: { user } } = await supabase.auth.getUser();
|
const { data: { session } } = await supabase.auth.getSession(); const user = session?.user;
|
||||||
if (!user) {
|
if (!user) {
|
||||||
toast.error('Not authenticated');
|
toast.error('Not authenticated');
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -56,7 +56,7 @@ export function WhatsAppConfig() {
|
|||||||
async function fetchConfig() {
|
async function fetchConfig() {
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const { data: { user } } = await supabase.auth.getUser();
|
const { data: { session } } = await supabase.auth.getSession(); const user = session?.user;
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
@ -97,7 +97,7 @@ export function WhatsAppConfig() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
const { data: { user } } = await supabase.auth.getUser();
|
const { data: { session } } = await supabase.auth.getSession(); const user = session?.user;
|
||||||
if (!user) {
|
if (!user) {
|
||||||
toast.error('Not authenticated');
|
toast.error('Not authenticated');
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user