fix: fix styles
This commit is contained in:
parent
52fba3a879
commit
87b14e8716
|
@ -23,22 +23,22 @@ export const apiRequest = async <T = any, K = any>(
|
|||
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
// const {
|
||||
// response: {
|
||||
// status: responseCode = null,
|
||||
// statusText = '',
|
||||
// data: { message = '', status: errorKey = '' } = {},
|
||||
// } = {},
|
||||
// code: statusCode = '',
|
||||
// } = err as AxiosError;
|
||||
//
|
||||
// throw new Error(
|
||||
// JSON.stringify({
|
||||
// statusCode,
|
||||
// statusMessage: message || statusText,
|
||||
// responseCode,
|
||||
// errorKey,
|
||||
// }),
|
||||
// );
|
||||
const {
|
||||
response: {
|
||||
status: responseCode = null,
|
||||
statusText = '',
|
||||
data,
|
||||
} = {},
|
||||
code: statusCode = '',
|
||||
} = err as AxiosError;
|
||||
|
||||
throw new Error(
|
||||
JSON.stringify({
|
||||
statusCode,
|
||||
statusMessage: statusText,
|
||||
responseCode,
|
||||
details: data
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -15,9 +15,9 @@ import { getStorageValue } from '../../hooks/useLocalStorage';
|
|||
import { AUTH_TOKEN_KEY, SESSION_DATA } from '../../constants/common';
|
||||
import { ScheduleModal } from '../Modals/ScheduleModal';
|
||||
import { ScheduleModalResult } from '../Modals/ScheduleModalResult';
|
||||
import SignalrConnection from "../../lib/signalr-connection";
|
||||
import {useRouter} from "../../navigation";
|
||||
import {useLocalStorage} from "../../hooks/useLocalStorage";
|
||||
import SignalrConnection from '../../lib/signalr-connection';
|
||||
import { useRouter } from '../../navigation';
|
||||
import { useLocalStorage } from '../../hooks/useLocalStorage';
|
||||
|
||||
type ExpertDetailsProps = {
|
||||
expert: ExpertDetails;
|
||||
|
@ -38,30 +38,28 @@ export const ExpertCard: FC<ExpertDetailsProps> = ({ expert, locale, expertId })
|
|||
const isRus = locale === Locale.ru;
|
||||
const { publicCoachDetails: { tags = [], sessionCost = 0, sessionDuration = 0, coachLanguages = [] , id, botUserId} } = expert || {};
|
||||
const [jwt] = useLocalStorage(AUTH_TOKEN_KEY, '');
|
||||
const { joinChatPerson, addListener } = SignalrConnection();
|
||||
const { joinChatPerson, addListener, closeConnection } = SignalrConnection();
|
||||
const router = useRouter();
|
||||
|
||||
const onConnected = (flag: boolean)=>{
|
||||
if (flag){
|
||||
|
||||
console.log('here');
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
addListener('onConnected', onConnected)
|
||||
addListener('onConnected', onConnected);
|
||||
document?.addEventListener('show_pay_form', handleShowPayForm);
|
||||
|
||||
return () => {
|
||||
closeConnection();
|
||||
document?.removeEventListener('show_pay_form', handleShowPayForm);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleJoinChat = () =>{
|
||||
joinChatPerson(id).then((res: any) =>{
|
||||
console.log('RES', res)
|
||||
router.push(`/account/messages/${res.id}`);
|
||||
})
|
||||
}
|
||||
|
||||
const handleJoinAIChat = () =>{
|
||||
joinChatPerson(botUserId).then((res: any) =>{
|
||||
console.log('RES', res)
|
||||
router.push(`/account/messages/${res.id}`);
|
||||
const handleJoinChat = (id: number) => {
|
||||
joinChatPerson(id).then((res: any) => {
|
||||
router.push(`/account/messages/${res.id}` as string);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -74,7 +72,7 @@ export const ExpertCard: FC<ExpertDetailsProps> = ({ expert, locale, expertId })
|
|||
} else {
|
||||
setShowSchedulerModal(false);
|
||||
const showAuth = new Event('show_auth_enter');
|
||||
document.dispatchEvent(showAuth);
|
||||
document?.dispatchEvent(showAuth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,13 +82,6 @@ export const ExpertCard: FC<ExpertDetailsProps> = ({ expert, locale, expertId })
|
|||
setMode('pay');
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
document.addEventListener('show_pay_form', handleShowPayForm);
|
||||
return () => {
|
||||
document.removeEventListener('show_pay_form', handleShowPayForm);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const onSchedulerHandle = () => {
|
||||
setMode('data');
|
||||
setShowSchedulerModal(true);
|
||||
|
@ -116,11 +107,16 @@ export const ExpertCard: FC<ExpertDetailsProps> = ({ expert, locale, expertId })
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{jwt && (
|
||||
<div className="expert-card__wrap-btn">
|
||||
<Button className="btn-apply" onClick={onSchedulerHandle}>
|
||||
<img src="/images/calendar-outline.svg" className="" alt="" />
|
||||
{i18nText('schedule', locale)}
|
||||
<Button className="btn-apply" onClick={() => handleJoinChat(id)}>
|
||||
{i18nText('chat.join', locale)}
|
||||
</Button>
|
||||
{botUserId && (
|
||||
<Button className="btn-apply" onClick={() => handleJoinChat(botUserId)}>
|
||||
{i18nText('chat.joinAI', locale)}
|
||||
</Button>
|
||||
)}
|
||||
{/*
|
||||
<a href="#" className="btn-video">
|
||||
<img src="/images/videocam-outline.svg" className="" alt=""/>
|
||||
|
@ -128,6 +124,7 @@ export const ExpertCard: FC<ExpertDetailsProps> = ({ expert, locale, expertId })
|
|||
</a>
|
||||
*/}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="expert-info">
|
||||
{/* <h2 className="title-h2">{}</h2> */}
|
||||
|
@ -158,19 +155,6 @@ export const ExpertCard: FC<ExpertDetailsProps> = ({ expert, locale, expertId })
|
|||
<div className="wrap-btn-prise__text">
|
||||
{`${sessionCost}€`} <span>/ {`${sessionDuration}${isRus ? 'мин' : 'min'}`}</span>
|
||||
</div>
|
||||
{jwt && (
|
||||
<div className="w-100" style={{textAlign: 'end'}}>
|
||||
|
||||
<FilledYellowButton
|
||||
onClick={handleJoinChat}
|
||||
>{i18nText('chat.join', locale)}</FilledYellowButton>
|
||||
|
||||
{botUserId && (
|
||||
<FilledYellowButton
|
||||
onClick={handleJoinAIChat}>{i18nText('chat.joinAI', locale)}</FilledYellowButton>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<ScheduleModal
|
||||
open={showSchedulerModal}
|
||||
|
|
|
@ -185,6 +185,10 @@ export default {
|
|||
sessionWishes: 'Schreiben Sie Ihre Wünsche zur Sitzung',
|
||||
successPayment: 'Erfolgreiche Zahlung',
|
||||
errorPayment: 'Zahlungsfehler',
|
||||
chat: {
|
||||
join: 'Chat starten',
|
||||
joinAI: 'Start AI chat'
|
||||
},
|
||||
errors: {
|
||||
invalidEmail: 'Die E-Mail-Adresse ist ungültig',
|
||||
emptyEmail: 'Bitte geben Sie Ihre E-Mail ein',
|
||||
|
|
|
@ -185,6 +185,10 @@ export default {
|
|||
sessionWishes: 'Write your wishes about the session',
|
||||
successPayment: 'Successful Payment',
|
||||
errorPayment: 'Payment Error',
|
||||
chat: {
|
||||
join: 'Start chat',
|
||||
joinAI: 'Start AI chat'
|
||||
},
|
||||
errors: {
|
||||
invalidEmail: 'The email address is not valid',
|
||||
emptyEmail: 'Please enter your E-mail',
|
||||
|
|
|
@ -185,6 +185,10 @@ export default {
|
|||
sessionWishes: 'Escribe tus deseos sobre la sesión',
|
||||
successPayment: 'Pago Exitoso',
|
||||
errorPayment: 'Error de Pago',
|
||||
chat: {
|
||||
join: 'Empezar un chat',
|
||||
joinAI: 'Start AI chat'
|
||||
},
|
||||
errors: {
|
||||
invalidEmail: 'La dirección de correo electrónico no es válida',
|
||||
emptyEmail: 'Introduce tu correo electrónico',
|
||||
|
|
|
@ -185,6 +185,10 @@ export default {
|
|||
sessionWishes: 'Écrivez vos souhaits concernant la session',
|
||||
successPayment: 'Paiement Réussi',
|
||||
errorPayment: 'Erreur de Paiement',
|
||||
chat: {
|
||||
join: 'Commencer la discussion',
|
||||
joinAI: 'Start AI chat'
|
||||
},
|
||||
errors: {
|
||||
invalidEmail: 'L\'adresse e-mail n\'est pas valide',
|
||||
emptyEmail: 'Veuillez saisir votre e-mail',
|
||||
|
|
|
@ -185,6 +185,10 @@ export default {
|
|||
sessionWishes: 'Scrivi i tuoi desideri riguardo alla sessione',
|
||||
successPayment: 'Pagamento Riuscito',
|
||||
errorPayment: 'Errore di Pagamento',
|
||||
chat: {
|
||||
join: 'Avvia chat',
|
||||
joinAI: 'Start AI chat'
|
||||
},
|
||||
errors: {
|
||||
invalidEmail: 'L\'indirizzo e-mail non è valido',
|
||||
emptyEmail: 'Inserisci l\'e-mail',
|
||||
|
|
|
@ -186,8 +186,8 @@ export default {
|
|||
successPayment: 'Успешная оплата',
|
||||
errorPayment: 'Ошибка оплаты',
|
||||
chat: {
|
||||
join: 'начать чат',
|
||||
joinAI: 'начать чат с ИИ'
|
||||
join: 'Начать чат',
|
||||
joinAI: 'Начать чат с ИИ'
|
||||
},
|
||||
errors: {
|
||||
invalidEmail: 'Адрес электронной почты недействителен',
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { HubConnection, HubConnectionBuilder, LogLevel } from '@microsoft/signalr';
|
||||
import {AUTH_TOKEN_KEY} from "../constants/common";
|
||||
import {IHttpConnectionOptions} from "@microsoft/signalr/src/IHttpConnectionOptions";
|
||||
import {IChatMessage} from "../types/chat";
|
||||
|
||||
const URL = 'https://api.bbuddy.expert/api/hubs/chat'
|
||||
import { IHttpConnectionOptions } from "@microsoft/signalr/src/IHttpConnectionOptions";
|
||||
import { AUTH_TOKEN_KEY, BASE_URL } from '../constants/common';
|
||||
import { IChatMessage } from '../types/chat';
|
||||
|
||||
const chatMessageMethodName = 'ReceiveMessage';
|
||||
const chatUserStatusChangeMethodName = 'chatUserStatusChange';
|
||||
|
@ -33,7 +31,7 @@ class SignalConnector {
|
|||
accessTokenFactory: () => localStorage.getItem(AUTH_TOKEN_KEY)
|
||||
} as IHttpConnectionOptions;
|
||||
this.connection = new HubConnectionBuilder()
|
||||
.withUrl(URL, options)
|
||||
.withUrl(`${BASE_URL}/hubs/chat`, options)
|
||||
.withAutomaticReconnect()
|
||||
.configureLogging(LogLevel.Debug)
|
||||
.build();
|
||||
|
@ -52,7 +50,7 @@ class SignalConnector {
|
|||
this.events[name] = func;
|
||||
}
|
||||
|
||||
public closeConnection = () =>{
|
||||
public closeConnection = () => {
|
||||
this.connection.stop();
|
||||
}
|
||||
|
||||
|
|
|
@ -823,6 +823,7 @@ a {
|
|||
flex: 0 0 100%;
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
flex-direction: column;
|
||||
|
||||
.btn-apply,
|
||||
.btn-video {
|
||||
|
|
Loading…
Reference in New Issue