Skip to content

Commit

Permalink
fix: remove error navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
acnormun committed Feb 5, 2025
1 parent d1b1774 commit 8604b3e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 32 deletions.
20 changes: 8 additions & 12 deletions src/pages/Channel.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { Button, Flex, IconCheck, Text, toast } from "@vtex/shoreline";
import { Button, Flex, IconCheck, Text } from "@vtex/shoreline";
import iconWhatsapp from '../assets/channels/whatsapp.svg';
import store from "../store/provider.store";
import { setWhatsAppIntegrated } from "../store/userSlice";
// import { startFacebookLogin } from "../utils/facebook/login";
// import { useSelector } from "react-redux";
// import { selectProject } from "../store/projectSlice";
// import { selectToken } from "../store/authSlice";
import { startFacebookLogin } from "../utils/facebook/login";
import { useSelector } from "react-redux";
import { selectProject } from "../store/projectSlice";
import { selectToken } from "../store/authSlice";

export function Channel({ isIntegrated }: Readonly<{ isIntegrated: boolean }>) {
// const project_uuid = useSelector(selectProject)
// const token = useSelector(selectToken)
const project_uuid = useSelector(selectProject)
const token = useSelector(selectToken)
const callFacebookSDK = () => {
toast.critical(t('integration.channels.whatsapp.error'));
store.dispatch(setWhatsAppIntegrated(true))
// startFacebookLogin(project_uuid, token)
startFacebookLogin(project_uuid, token)
}
return (
<Flex
Expand Down
4 changes: 1 addition & 3 deletions src/pages/Setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ export function Setup() {
initializeProject();
}, [initializeProject]);

return (
<></>
)
return(<></>)
}
12 changes: 7 additions & 5 deletions src/pages/agent/AgentBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ import {
Textarea,
Tooltip,
} from '@vtex/shoreline';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { agentLoading, getAgent, selectProject } from '../../store/projectSlice';
import { isAgentIntegrated, isWhatsAppIntegrated } from '../../store/userSlice';
import { useAgentBuilderSetup } from '../setup/useAgentBuilderSetup';
import { useUserSetup } from '../setup/useUserSetup';
import { AgentBuilderSkeleton } from './AgentBuilderSkeleton';
import { Channel } from '../Channel';
import { useNavigate } from 'react-router-dom';
Expand All @@ -50,12 +51,12 @@ export function AgentBuilder() {
const isAgentLoading = useSelector(agentLoading)
const agentIntegrated = useSelector(isAgentIntegrated)
const { buildAgent } = useAgentBuilderSetup();
// const { initializeUser } = useUserSetup();
const { initializeUser } = useUserSetup();
const navigate = useNavigate()

// useEffect(() => {
// initializeUser();
// }, [initializeUser]);
useEffect(() => {
initializeUser();
}, [initializeUser]);

const isValidURL = (url: string) => {
const urlPattern = /^[^\s]+\.com([/?#].*)?$/i;
Expand Down Expand Up @@ -83,6 +84,7 @@ export function AgentBuilder() {
const payload = Object.fromEntries(
Object.entries(form).filter(([_, value]) => value.trim())
);
console.log('funfou')
buildAgent(payload, project);
}
};
Expand Down
1 change: 0 additions & 1 deletion src/pages/setup/useAgentBuilderSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export function useAgentBuilderSetup() {

if (response.error) {
toast.critical(t('agent.error'));
navigate('/dash');
} else {
toast.success(t('agent.success'))
navigate('/dash');
Expand Down
3 changes: 1 addition & 2 deletions src/pages/setup/useUserSetup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useNavigate } from 'react-router-dom';
import { setFeatureIntegrated, setUser, setWhatsAppIntegrated } from '../../store/userSlice';
import { checkProject, createUserAndProject, fetchUserData } from '../../services/user.service';
import { setErrorTest, setToken } from '../../store/authSlice';
import { setToken } from '../../store/authSlice';
import store from '../../store/provider.store';
import { getToken } from '../../services/auth.service';
import { setAgent, setFlowsChannelUuid, setProjectUuid, setWppCloudAppUuid } from '../../store/projectSlice';
Expand All @@ -19,7 +19,6 @@ export function useUserSetup() {
const {token, error} = await getToken();
if (error) {
console.error("Token não encontrado");
store.dispatch(setErrorTest(false))
navigate('/setup-error');
return;
}
Expand Down
10 changes: 3 additions & 7 deletions src/store/authSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@ const authSlice = createSlice({
name: 'auth',
initialState: {
token: '',
base_address: '',
errorTest: true
base_address: ''
},
reducers: {
setToken: (state, action) => {
state.token = action.payload;
},
setBaseAddress: (state, action) => {
state.base_address = action.payload
},
setErrorTest: (state, action) => {
state.errorTest = action.payload
},
}
},
});



export const { setToken, setBaseAddress, setErrorTest } = authSlice.actions;
export const { setToken, setBaseAddress } = authSlice.actions;

export const selectToken = (state: any) => state.auth.token
export const selectBaseAddress = (state: any) => state.auth.selectBaseAddress
Expand Down
2 changes: 0 additions & 2 deletions src/utils/facebook/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ export function startFacebookLogin(project_uuid: string, token: string) {
const fbAppId = getEnv("VITE_APP_FACEBOOK_APP_ID");
const configId = getEnv("VITE_APP_WHATSAPP_FACEBOOK_APP_ID");

console.log('tokens: ', fbAppId, configId)

if (!fbAppId) {
console.error("Facebook App ID is missing.");
return;
Expand Down

0 comments on commit 8604b3e

Please sign in to comment.