fix: fix styles

This commit is contained in:
SD 2024-12-20 18:53:05 +04:00
parent 52fba3a879
commit 87b14e8716
10 changed files with 79 additions and 76 deletions

View File

@ -23,22 +23,22 @@ export const apiRequest = async <T = any, K = any>(
return response.data; return response.data;
} catch (err) { } catch (err) {
// const { const {
// response: { response: {
// status: responseCode = null, status: responseCode = null,
// statusText = '', statusText = '',
// data: { message = '', status: errorKey = '' } = {}, data,
// } = {}, } = {},
// code: statusCode = '', code: statusCode = '',
// } = err as AxiosError; } = err as AxiosError;
//
// throw new Error( throw new Error(
// JSON.stringify({ JSON.stringify({
// statusCode, statusCode,
// statusMessage: message || statusText, statusMessage: statusText,
// responseCode, responseCode,
// errorKey, details: data
// }), }),
// ); );
} }
}; };

View File

@ -15,9 +15,9 @@ import { getStorageValue } from '../../hooks/useLocalStorage';
import { AUTH_TOKEN_KEY, SESSION_DATA } from '../../constants/common'; import { AUTH_TOKEN_KEY, SESSION_DATA } from '../../constants/common';
import { ScheduleModal } from '../Modals/ScheduleModal'; import { ScheduleModal } from '../Modals/ScheduleModal';
import { ScheduleModalResult } from '../Modals/ScheduleModalResult'; import { ScheduleModalResult } from '../Modals/ScheduleModalResult';
import SignalrConnection from "../../lib/signalr-connection"; import SignalrConnection from '../../lib/signalr-connection';
import {useRouter} from "../../navigation"; import { useRouter } from '../../navigation';
import {useLocalStorage} from "../../hooks/useLocalStorage"; import { useLocalStorage } from '../../hooks/useLocalStorage';
type ExpertDetailsProps = { type ExpertDetailsProps = {
expert: ExpertDetails; expert: ExpertDetails;
@ -38,30 +38,28 @@ export const ExpertCard: FC<ExpertDetailsProps> = ({ expert, locale, expertId })
const isRus = locale === Locale.ru; const isRus = locale === Locale.ru;
const { publicCoachDetails: { tags = [], sessionCost = 0, sessionDuration = 0, coachLanguages = [] , id, botUserId} } = expert || {}; const { publicCoachDetails: { tags = [], sessionCost = 0, sessionDuration = 0, coachLanguages = [] , id, botUserId} } = expert || {};
const [jwt] = useLocalStorage(AUTH_TOKEN_KEY, ''); const [jwt] = useLocalStorage(AUTH_TOKEN_KEY, '');
const { joinChatPerson, addListener } = SignalrConnection(); const { joinChatPerson, addListener, closeConnection } = SignalrConnection();
const router = useRouter(); const router = useRouter();
const onConnected = (flag: boolean)=>{ const onConnected = (flag: boolean)=>{
if (flag){ if (flag){
console.log('here');
} }
} }
useEffect(() => { useEffect(() => {
addListener('onConnected', onConnected) addListener('onConnected', onConnected);
document?.addEventListener('show_pay_form', handleShowPayForm);
return () => {
closeConnection();
document?.removeEventListener('show_pay_form', handleShowPayForm);
}
}, []); }, []);
const handleJoinChat = () =>{ const handleJoinChat = (id: number) => {
joinChatPerson(id).then((res: any) =>{ joinChatPerson(id).then((res: any) => {
console.log('RES', res) router.push(`/account/messages/${res.id}` as string);
router.push(`/account/messages/${res.id}`);
})
}
const handleJoinAIChat = () =>{
joinChatPerson(botUserId).then((res: any) =>{
console.log('RES', res)
router.push(`/account/messages/${res.id}`);
}) })
} }
@ -74,7 +72,7 @@ export const ExpertCard: FC<ExpertDetailsProps> = ({ expert, locale, expertId })
} else { } else {
setShowSchedulerModal(false); setShowSchedulerModal(false);
const showAuth = new Event('show_auth_enter'); 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'); setMode('pay');
} }
useEffect(() => {
document.addEventListener('show_pay_form', handleShowPayForm);
return () => {
document.removeEventListener('show_pay_form', handleShowPayForm);
};
}, []);
const onSchedulerHandle = () => { const onSchedulerHandle = () => {
setMode('data'); setMode('data');
setShowSchedulerModal(true); setShowSchedulerModal(true);
@ -116,11 +107,16 @@ export const ExpertCard: FC<ExpertDetailsProps> = ({ expert, locale, expertId })
</div> </div>
</div> </div>
</div> </div>
{jwt && (
<div className="expert-card__wrap-btn"> <div className="expert-card__wrap-btn">
<Button className="btn-apply" onClick={onSchedulerHandle}> <Button className="btn-apply" onClick={() => handleJoinChat(id)}>
<img src="/images/calendar-outline.svg" className="" alt="" /> {i18nText('chat.join', locale)}
{i18nText('schedule', locale)}
</Button> </Button>
{botUserId && (
<Button className="btn-apply" onClick={() => handleJoinChat(botUserId)}>
{i18nText('chat.joinAI', locale)}
</Button>
)}
{/* {/*
<a href="#" className="btn-video"> <a href="#" className="btn-video">
<img src="/images/videocam-outline.svg" className="" alt=""/> <img src="/images/videocam-outline.svg" className="" alt=""/>
@ -128,6 +124,7 @@ export const ExpertCard: FC<ExpertDetailsProps> = ({ expert, locale, expertId })
</a> </a>
*/} */}
</div> </div>
)}
</div> </div>
<div className="expert-info"> <div className="expert-info">
{/* <h2 className="title-h2">{}</h2> */} {/* <h2 className="title-h2">{}</h2> */}
@ -158,19 +155,6 @@ export const ExpertCard: FC<ExpertDetailsProps> = ({ expert, locale, expertId })
<div className="wrap-btn-prise__text"> <div className="wrap-btn-prise__text">
{`${sessionCost}`} <span>/ {`${sessionDuration}${isRus ? 'мин' : 'min'}`}</span> {`${sessionCost}`} <span>/ {`${sessionDuration}${isRus ? 'мин' : 'min'}`}</span>
</div> </div>
{jwt && (
<div className="w-100" style={{textAlign: 'end'}}>
<FilledYellowButton
onClick={handleJoinChat}
>{i18nText('chat.join', locale)}</FilledYellowButton>
&nbsp;
{botUserId && (
<FilledYellowButton
onClick={handleJoinAIChat}>{i18nText('chat.joinAI', locale)}</FilledYellowButton>
)}
</div>
)}
</div> </div>
<ScheduleModal <ScheduleModal
open={showSchedulerModal} open={showSchedulerModal}

View File

@ -185,6 +185,10 @@ export default {
sessionWishes: 'Schreiben Sie Ihre Wünsche zur Sitzung', sessionWishes: 'Schreiben Sie Ihre Wünsche zur Sitzung',
successPayment: 'Erfolgreiche Zahlung', successPayment: 'Erfolgreiche Zahlung',
errorPayment: 'Zahlungsfehler', errorPayment: 'Zahlungsfehler',
chat: {
join: 'Chat starten',
joinAI: 'Start AI chat'
},
errors: { errors: {
invalidEmail: 'Die E-Mail-Adresse ist ungültig', invalidEmail: 'Die E-Mail-Adresse ist ungültig',
emptyEmail: 'Bitte geben Sie Ihre E-Mail ein', emptyEmail: 'Bitte geben Sie Ihre E-Mail ein',

View File

@ -185,6 +185,10 @@ export default {
sessionWishes: 'Write your wishes about the session', sessionWishes: 'Write your wishes about the session',
successPayment: 'Successful Payment', successPayment: 'Successful Payment',
errorPayment: 'Payment Error', errorPayment: 'Payment Error',
chat: {
join: 'Start chat',
joinAI: 'Start AI chat'
},
errors: { errors: {
invalidEmail: 'The email address is not valid', invalidEmail: 'The email address is not valid',
emptyEmail: 'Please enter your E-mail', emptyEmail: 'Please enter your E-mail',

View File

@ -185,6 +185,10 @@ export default {
sessionWishes: 'Escribe tus deseos sobre la sesión', sessionWishes: 'Escribe tus deseos sobre la sesión',
successPayment: 'Pago Exitoso', successPayment: 'Pago Exitoso',
errorPayment: 'Error de Pago', errorPayment: 'Error de Pago',
chat: {
join: 'Empezar un chat',
joinAI: 'Start AI chat'
},
errors: { errors: {
invalidEmail: 'La dirección de correo electrónico no es válida', invalidEmail: 'La dirección de correo electrónico no es válida',
emptyEmail: 'Introduce tu correo electrónico', emptyEmail: 'Introduce tu correo electrónico',

View File

@ -185,6 +185,10 @@ export default {
sessionWishes: 'Écrivez vos souhaits concernant la session', sessionWishes: 'Écrivez vos souhaits concernant la session',
successPayment: 'Paiement Réussi', successPayment: 'Paiement Réussi',
errorPayment: 'Erreur de Paiement', errorPayment: 'Erreur de Paiement',
chat: {
join: 'Commencer la discussion',
joinAI: 'Start AI chat'
},
errors: { errors: {
invalidEmail: 'L\'adresse e-mail n\'est pas valide', invalidEmail: 'L\'adresse e-mail n\'est pas valide',
emptyEmail: 'Veuillez saisir votre e-mail', emptyEmail: 'Veuillez saisir votre e-mail',

View File

@ -185,6 +185,10 @@ export default {
sessionWishes: 'Scrivi i tuoi desideri riguardo alla sessione', sessionWishes: 'Scrivi i tuoi desideri riguardo alla sessione',
successPayment: 'Pagamento Riuscito', successPayment: 'Pagamento Riuscito',
errorPayment: 'Errore di Pagamento', errorPayment: 'Errore di Pagamento',
chat: {
join: 'Avvia chat',
joinAI: 'Start AI chat'
},
errors: { errors: {
invalidEmail: 'L\'indirizzo e-mail non è valido', invalidEmail: 'L\'indirizzo e-mail non è valido',
emptyEmail: 'Inserisci l\'e-mail', emptyEmail: 'Inserisci l\'e-mail',

View File

@ -186,8 +186,8 @@ export default {
successPayment: 'Успешная оплата', successPayment: 'Успешная оплата',
errorPayment: 'Ошибка оплаты', errorPayment: 'Ошибка оплаты',
chat: { chat: {
join: 'начать чат', join: 'Начать чат',
joinAI: 'начать чат с ИИ' joinAI: 'Начать чат с ИИ'
}, },
errors: { errors: {
invalidEmail: 'Адрес электронной почты недействителен', invalidEmail: 'Адрес электронной почты недействителен',

View File

@ -1,9 +1,7 @@
import { HubConnection, HubConnectionBuilder, LogLevel } from '@microsoft/signalr'; import { HubConnection, HubConnectionBuilder, LogLevel } from '@microsoft/signalr';
import {AUTH_TOKEN_KEY} from "../constants/common"; import { IHttpConnectionOptions } from "@microsoft/signalr/src/IHttpConnectionOptions";
import {IHttpConnectionOptions} from "@microsoft/signalr/src/IHttpConnectionOptions"; import { AUTH_TOKEN_KEY, BASE_URL } from '../constants/common';
import {IChatMessage} from "../types/chat"; import { IChatMessage } from '../types/chat';
const URL = 'https://api.bbuddy.expert/api/hubs/chat'
const chatMessageMethodName = 'ReceiveMessage'; const chatMessageMethodName = 'ReceiveMessage';
const chatUserStatusChangeMethodName = 'chatUserStatusChange'; const chatUserStatusChangeMethodName = 'chatUserStatusChange';
@ -33,7 +31,7 @@ class SignalConnector {
accessTokenFactory: () => localStorage.getItem(AUTH_TOKEN_KEY) accessTokenFactory: () => localStorage.getItem(AUTH_TOKEN_KEY)
} as IHttpConnectionOptions; } as IHttpConnectionOptions;
this.connection = new HubConnectionBuilder() this.connection = new HubConnectionBuilder()
.withUrl(URL, options) .withUrl(`${BASE_URL}/hubs/chat`, options)
.withAutomaticReconnect() .withAutomaticReconnect()
.configureLogging(LogLevel.Debug) .configureLogging(LogLevel.Debug)
.build(); .build();
@ -52,7 +50,7 @@ class SignalConnector {
this.events[name] = func; this.events[name] = func;
} }
public closeConnection = () =>{ public closeConnection = () => {
this.connection.stop(); this.connection.stop();
} }

View File

@ -823,6 +823,7 @@ a {
flex: 0 0 100%; flex: 0 0 100%;
display: flex; display: flex;
gap: 16px; gap: 16px;
flex-direction: column;
.btn-apply, .btn-apply,
.btn-video { .btn-video {