Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: PDF sharing bug #198

Merged
merged 106 commits into from
Nov 7, 2023
Merged
Changes from 1 commit
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
8d21714
Style: fixed odia title (#104)
prtkjakhar May 9, 2023
beec8fe
Feat chat history (#106)
geeky-abhishek May 9, 2023
69137b3
Delete .env.production
geeky-abhishek May 9, 2023
61e535f
UI changes (#112)
geeky-abhishek May 10, 2023
fb95fbc
fix: conversation id (#115)
geeky-abhishek May 11, 2023
3c16d52
Merge branch 'production' into main
geeky-abhishek May 11, 2023
f9192d4
Added down time page (#117)
prtkjakhar May 11, 2023
091ed6e
Update ContextProvider.tsx (#118)
prtkjakhar May 11, 2023
585157e
Feat dialer popup (#120)
prtkjakhar May 12, 2023
939e319
Merge branch 'production' into main
geeky-abhishek May 12, 2023
ad9f44b
Added Auth header (#122)
prtkjakhar May 12, 2023
425947c
Merge branch 'production' into main
geeky-abhishek May 15, 2023
5db5d56
chore: msgId display for testing (#127)
geeky-abhishek May 16, 2023
ecfa55c
Feat dsply msg (#128)
geeky-abhishek May 16, 2023
e8e157c
Merge branch 'production' into main
geeky-abhishek May 17, 2023
129d6eb
chore: fixed userID bug (#130)
prtkjakhar May 23, 2023
4af2c31
Feat fcm (#133)
prtkjakhar May 23, 2023
b4e863b
fix: update in conversation api (#135)
prtkjakhar May 29, 2023
5caf66f
fix: added firebase event for msg delay (#136)
prtkjakhar May 29, 2023
cd31282
fix: flagsmith init inside useeffect (#140)
geeky-abhishek Jun 1, 2023
5e0760b
Merge branch 'production' into main
geeky-abhishek Jun 1, 2023
8b9f282
Added query log and splash screen log (#143)
prtkjakhar Jun 2, 2023
3c79987
Feat trans (#134)
prtkjakhar Jun 5, 2023
6796a5b
Merge branch 'production' into main
geeky-abhishek Jun 5, 2023
8defe56
Fix: fcm logic updated (#146)
prtkjakhar Jun 7, 2023
8eb2122
Feat: Added example questions to flagsmith (#147)
prtkjakhar Jun 8, 2023
bf0929e
Feat: Feature Pop Up (#148)
prtkjakhar Jun 12, 2023
eaaf5c0
Merge branch 'production' into main
geeky-abhishek Jun 12, 2023
0dfb454
fix: empty feature details bug (#152)
prtkjakhar Jun 12, 2023
13d1d3b
Merge branch 'production' into main
geeky-abhishek Jun 12, 2023
80c4a8b
fix: handled new history api (#157)
prtkjakhar Jun 21, 2023
27cfafd
fix: no internet error for otp verify in offline (#158)
geeky-abhishek Jun 28, 2023
9ad530b
feat:Speech to text added (#114)
geeky-abhishek Sep 8, 2023
4508a91
Fix chat history (#166)
prtkjakhar Sep 13, 2023
0052a3c
modified label.ask_me in or (#167)
prtkjakhar Sep 14, 2023
f59e057
Minor UI fix (#168)
prtkjakhar Sep 14, 2023
9d15259
Minor UI fix (#169)
prtkjakhar Sep 18, 2023
a5159b1
Merge branch 'production' into main
prtkjakhar Sep 18, 2023
3898b8f
Fix odia translations (#171)
prtkjakhar Sep 18, 2023
e4be1dc
welcome text centered (#173)
prtkjakhar Sep 20, 2023
fce0f6f
chat history pdf api updated
prtkjakhar Sep 20, 2023
b4ec921
Merge branch 'production' into main
prtkjakhar Sep 20, 2023
96b75be
pdf opening
prtkjakhar Sep 21, 2023
117aab8
Merge branch 'main' of https://github.com/AmakrushAI/app
prtkjakhar Sep 21, 2023
c6e2c53
Merge branch 'production' into main
prtkjakhar Sep 21, 2023
f508a27
pdfurl defined two times fixed
prtkjakhar Sep 21, 2023
c40debe
added target in anchor
prtkjakhar Sep 21, 2023
84c1c07
added object url back
prtkjakhar Sep 21, 2023
e3f600f
Merge branch 'production' into main
prtkjakhar Sep 21, 2023
fd2a6d7
added pdfUrl back
prtkjakhar Sep 21, 2023
33e177d
merge main
prtkjakhar Sep 21, 2023
b315a6f
Merge branch 'production' into main
prtkjakhar Sep 21, 2023
6d05890
added toast message if no pdf link
prtkjakhar Sep 21, 2023
c958285
minor fixes
prtkjakhar Sep 21, 2023
48e0aa7
Merge branch 'main' of https://github.com/AmakrushAI/app
prtkjakhar Sep 21, 2023
26282ed
Merge branch 'production' into main
prtkjakhar Sep 21, 2023
1accc3f
fixed manual link
prtkjakhar Sep 21, 2023
f0cec7a
added android handshake for sharing
prtkjakhar Sep 21, 2023
cbcc2d1
android handshake function added
prtkjakhar Sep 21, 2023
7bee713
android handshake function added
prtkjakhar Sep 21, 2023
99d8b62
android handshake added
prtkjakhar Sep 21, 2023
d756020
added android handshake function
prtkjakhar Sep 21, 2023
7d2bd79
minor ui fix
prtkjakhar Sep 21, 2023
5e512d7
updated chat history url
prtkjakhar Sep 25, 2023
9eed839
downloaded pdf opening in new tab
prtkjakhar Sep 26, 2023
60d9ac5
added firebase logs for download, share clicks
prtkjakhar Sep 26, 2023
770c89d
Merge branch 'production' into main
prtkjakhar Sep 26, 2023
dc0f2cd
added error handling if shareUrl not implemented in android
prtkjakhar Sep 26, 2023
5d4494b
Merge branch 'production' into main
prtkjakhar Sep 26, 2023
cab4ad2
Updated shareUrl error message in both langs
prtkjakhar Sep 26, 2023
6e99b75
Merge branch 'production' into main
prtkjakhar Sep 26, 2023
a18507c
sending phoneNumber in asr API
prtkjakhar Sep 27, 2023
91b7c4e
ui enhancements
prtkjakhar Oct 6, 2023
e508b87
tts working
prtkjakhar Oct 6, 2023
5528887
changes for flutter
prtkjakhar Oct 9, 2023
c6ae1ab
changes for flutter
prtkjakhar Oct 9, 2023
848938f
changes for flutter
prtkjakhar Oct 9, 2023
8a35ff3
changes for flutter
prtkjakhar Oct 9, 2023
9bf45b9
added tts loader
prtkjakhar Oct 9, 2023
df95f10
added flutter handshake
prtkjakhar Oct 10, 2023
a859f0c
flutter handshake changed
prtkjakhar Oct 10, 2023
e80f123
flutter handshake changed
prtkjakhar Oct 10, 2023
ba80ae0
flutter handshake functions changed
prtkjakhar Oct 10, 2023
729d7fb
flutter handshake functions changed
prtkjakhar Oct 10, 2023
5e30de3
flutter handshake functions changed
prtkjakhar Oct 10, 2023
c0449bc
flutter handshake functions changed
prtkjakhar Oct 10, 2023
eef08bf
flutter handshake functions changed
prtkjakhar Oct 10, 2023
172bb7f
changed flutter handshake
prtkjakhar Oct 10, 2023
08c49a0
added audio playback from flagsmith
prtkjakhar Oct 10, 2023
0ee4fc1
added flutter download channel
prtkjakhar Oct 11, 2023
df101bf
added flutter download channel
prtkjakhar Oct 11, 2023
01a7c5b
removed tts
prtkjakhar Oct 11, 2023
a501ca6
Merge branch 'production' into main
prtkjakhar Oct 11, 2023
f7b2c16
removed tts
prtkjakhar Oct 11, 2023
4affe40
added tts
prtkjakhar Oct 11, 2023
f7b6a70
added pause icon to tts
prtkjakhar Oct 17, 2023
218e8ee
added incrementaudioused api
prtkjakhar Oct 17, 2023
96bf7a8
Merge branch 'production' into main
prtkjakhar Oct 17, 2023
501aa60
minor fix
prtkjakhar Oct 17, 2023
4cdca90
Merge branch 'production' into main
prtkjakhar Oct 17, 2023
7270b0e
folder restructured
prtkjakhar Oct 19, 2023
36dd605
Feat PWA (#197)
prtkjakhar Oct 25, 2023
1839e0f
added install pwa modal
prtkjakhar Oct 25, 2023
ce5284c
Added timeTaken API
prtkjakhar Nov 2, 2023
1b16eb1
Added timeTaken API
prtkjakhar Nov 2, 2023
fc9a9d3
pdf sharing now
prtkjakhar Nov 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
UI changes (#112)
* style: minor ui changes

* fix: delete history page fix and flagsmith self hoasted added

---------

Co-authored-by: Prateek Jakhar <prtkjakhar@gmail.com>
geeky-abhishek and prtkjakhar authored May 10, 2023
commit 61e535faf1086b8790aca76535ac3044f7216be1
2 changes: 2 additions & 0 deletions apps/amakrushi/lang/en.json
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@
"label.click":"Reload",
"label.new_chat":"New chat",
"label.confirm_delete":"Are you sure you want to delete this conversation?",
"label.no_history":"No Chats",
"message.no_history":"Your Chat History with AI will come here",
"message.socket_disconnect_msg": "to connect again.",
"message.enter_mobile":"Enter Mobile Number",
"message.register_message":"If you are already registered then use your mobile number to login.",
2 changes: 2 additions & 0 deletions apps/amakrushi/lang/or.json
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@
"label.click":"ସତେଜ କରନ୍ତୁ",
"label.new_chat":"ନୂଆ ଚାଟ୍",
"label.confirm_delete":"ଆପଣ ନିଶ୍ଚିତ କି ଆପଣ ଏହି ବାର୍ତ୍ତାଳାପକୁ ବିଲୋପ କରିବାକୁ ଚାହୁଁଛନ୍ତି?",
"label.no_history":"କ chat ଣସି ଚାଟ୍ ନାହିଁ |",
"message.no_history":"AI ସହିତ ଆପଣଙ୍କର ଚାଟ୍ ଇତିହାସ ଏଠାକୁ ଆସିବ |",
"message.socket_disconnect_msg": "ପୁନର୍ବାର ସଂଯୋଗ କରିବାକୁ |",
"message.enter_mobile":"ମୋବାଇଲ୍ ନମ୍ବର ପ୍ରବେଶ କରନ୍ତୁ |",
"message.register_message":"ଯୋଡି ଆପଣ ପୂର୍ବରୁ ପଞ୍ଜୀକୃତ ହୋଇଛନ୍ତି ତେବେ ଲଗଇନ୍ କରିବା ପାଇଁ ଆପଣଙ୍କର ମୋବାଇଲ ନମ୍ବର ବ୍ୟବହାର କରନ୍ତୁ |",
24 changes: 24 additions & 0 deletions apps/amakrushi/src/components/HistoryPage/index.module.css
Original file line number Diff line number Diff line change
@@ -31,4 +31,28 @@
font-size: 4.265vh;
font-weight: 700;
color: var(--secondarygreen);
}

.noHistory{
height: 35vh;
display: flex;
flex-direction: column;
justify-content: center;
}

.noHistory div{
margin-top: 4vh;
margin-left: 2vh;
font-family: 'Mulish-Bold';
font-size: 4vh;
text-align: center;
color: var(--grey);
}
.noHistory p{
margin-top: 4vh;
margin-left: 2vh;
font-family: 'Mulish-Bold';
font-size: 1.65vh;
text-align: center;
color: var(--secondarygreen);
}
47 changes: 34 additions & 13 deletions apps/amakrushi/src/components/HistoryPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styles from './index.module.css';
import React, { useEffect, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import searchIcon from '../../assets/icons/search.svg';
import { Input, InputGroup, InputLeftElement } from '@chakra-ui/react';
import ChatItem from '../chat-item';
@@ -31,13 +31,16 @@ const HistoryPage: NextPage = () => {
}/user/conversations/${localStorage.getItem('userID')}`
)
.then((res) => {
const sortedConversations = _.filter(res?.data,conv=>conv?.conversationId !==null).sort(
const sortedConversations = _.filter(
res?.data,
(conv) => conv?.conversationId !== null
).sort(
//@ts-ignore
(a, b) => new Date(b.createdAt) - new Date(a.createdAt)
);
//@ts-ignore
//@ts-ignore
setConversations(sortedConversations);
console.log('conversations:', sortedConversations);
console.log('hie', sortedConversations);
})
.catch((error) => {
//@ts-ignore
@@ -47,6 +50,16 @@ const HistoryPage: NextPage = () => {
});
}, []);

// Function to delete conversation by conversationId
const deleteConversationById = useCallback((conversationIdToDelete: any) => {
const filteredConversations = [...conversations].filter(
(conversation: any) => conversation.conversationId !== conversationIdToDelete
);
setConversations(filteredConversations);
}, [conversations]);



if (!flags?.show_chat_history_page?.enabled) {
return <ComingSoonPage />;
} else
@@ -61,15 +74,23 @@ const HistoryPage: NextPage = () => {
<Input type="text" placeholder="Search" />
</InputGroup> */}
<div>
{conversations.map((conv:any, key) => {
return (
<ChatItem
key={key}
name={conv.query}
conversationId={conv.conversationId}
/>
);
})}
{conversations.length > 0
? conversations.map((conv: any) => {
return (
<ChatItem
key={conv.id}
name={conv.query}
conversationId={conv.conversationId}
deleteConversationById={deleteConversationById}
/>
);
})
: (
<div className={styles.noHistory}>
<div>{t('label.no_history')}</div>
<p>{t('message.no_history')}</p>
</div>
)}
</div>
</div>
<Menu />
2 changes: 1 addition & 1 deletion apps/amakrushi/src/components/MorePage/FAQPage/index.tsx
Original file line number Diff line number Diff line change
@@ -158,7 +158,7 @@ const FAQPage: React.FC = () => {
<div className={styles.footer}>
{t('message.dial_description')}
</div>
<a href="tel:155333" className={styles.footerTitle}>
<a href={`tel:${flags.dialer_number.value}`} className={styles.footerTitle}>
<div className={styles.callIconBox}>
<Image src={callIcon} alt="callIcon" layout="responsive" />
</div>
57 changes: 31 additions & 26 deletions apps/amakrushi/src/components/chat-item/index.tsx
Original file line number Diff line number Diff line change
@@ -12,7 +12,11 @@ import { v4 as uuidv4 } from 'uuid';
import { AppContext } from '../../context';
import { useLocalization } from '../../hooks';

const ChatItem: React.FC<ChatItemPropsType> = ({ name, conversationId }) => {
const ChatItem: React.FC<ChatItemPropsType> = ({
name,
conversationId,
deleteConversationById,
}) => {
const context = useContext(AppContext);
const t = useLocalization();
const [isConversationDeleted, setIsConversationDeleted] = useState(false);
@@ -24,34 +28,35 @@ const ChatItem: React.FC<ChatItemPropsType> = ({ name, conversationId }) => {
}, [context, conversationId]);

const deleteConversation = useCallback(() => {
const confirmed = window?.confirm(`${t("label.confirm_delete")}`);
if(confirmed){
const confirmed = window?.confirm(`${t('label.confirm_delete')}`);
if (confirmed) {
axios
.get(
`${
process.env.NEXT_PUBLIC_BASE_URL
}/user/conversations/delete/${localStorage.getItem(
'userID'
)}/${conversationId}`
)
.then((res) => {
console.log('deleting conversation')
if (conversationId === sessionStorage.getItem('conversationId')) {
const newConversationId= uuidv4();
sessionStorage.setItem('conversationId',newConversationId);
context?.setConversationId(newConversationId);
context?.setMessages([]);
}
setIsConversationDeleted(true);
})
.catch((error) => {
//@ts-ignore
logEvent(analytics, 'console_error', {
error_message: error.message,
.get(
`${
process.env.NEXT_PUBLIC_BASE_URL
}/user/conversations/delete/${localStorage.getItem(
'userID'
)}/${conversationId}`
)
.then((res) => {
console.log('deleting conversation');
if (conversationId === sessionStorage.getItem('conversationId')) {
const newConversationId = uuidv4();
sessionStorage.setItem('conversationId', newConversationId);
context?.setConversationId(newConversationId);
context?.setMessages([]);
}
deleteConversationById(conversationId);
setIsConversationDeleted(true);
})
.catch((error) => {
//@ts-ignore
logEvent(analytics, 'console_error', {
error_message: error.message,
});
});
});
}
}, [context, conversationId, t]);
}, [context, conversationId, deleteConversationById, t]);

return (
<>
28 changes: 28 additions & 0 deletions apps/amakrushi/src/components/chat-message-item/index.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
.messageTriangleRight {
content: ' ';
margin-right: 1vh;
position: absolute;
width: 0;
height: 0;
left: auto;
right: -20px;
top: 0px;
bottom: auto;
border: 20px solid;
border-color: var(--secondarygreen) transparent transparent transparent;
}

.messageTriangleLeft {
margin-left: 1vh;
content: ' ';
position: absolute;
width: 0;
height: 0;
left: -20px;
right: auto;
top: 0px;
bottom: auto;
border: 22px solid;
border-color: white transparent transparent transparent;
}

.onHover {
font-weight: bold;
color: var(--secondarygreen);
54 changes: 35 additions & 19 deletions apps/amakrushi/src/components/chat-message-item/index.tsx
Original file line number Diff line number Diff line change
@@ -32,39 +32,44 @@ import { ChatMessageItemPropType } from '../../types';
import { getFormatedTime } from '../../utils/getUtcTime';
import { useLocalization } from '../../hooks/useLocalization';
import { getReactionUrl } from '../../utils/getUrls';
import { useFlags } from 'flagsmith/react';


const getToastMessage=(t:any,reaction:number):string=>{
if(reaction===1)
return t('toast.reaction_like');
if(reaction===-1)
return t('toast.reaction_dislike')
return t('toast.reaction_reset')
}
const getToastMessage = (t: any, reaction: number): string => {
if (reaction === 1) return t('toast.reaction_like');
if (reaction === -1) return '';
return t('toast.reaction_reset');
};
const ChatMessageItem: FC<ChatMessageItemPropType> = ({
currentUser,
message,
onSend,
}) => {
const flags = useFlags(['dialer_number']);
const t = useLocalization();
const context = useContext(AppContext);
const [reaction, setReaction] = useState(message?.content?.data?.reaction);

useEffect(() => {
setReaction(message?.content?.data?.reaction);

}, [message?.content?.data?.reaction]);


}, [message?.content?.data?.reaction]);

const onLikeDislike = useCallback(
({ value, msgId }: { value: 0 | 1 | -1; msgId: string }) => {
let url = getReactionUrl({ msgId, reaction: value });

axios
.get(url)
.then((res: any) => {
toast.success(`${getToastMessage(t,value)}`);
if (value === -1) {
const dial = window?.confirm(
`Please call ${flags.dialer_number.value} to resolve your query with Ama Krushi Call centre`
);
if (dial) {
const anchor = document.createElement('a');
anchor.href = `tel:${flags.dialer_number.value}`;
anchor.click();
}
} else toast.success(`${getToastMessage(t, value)}`);
})
.catch((error: any) => {
//@ts-ignore
@@ -73,7 +78,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
});
});
},
[t]
[flags.dialer_number.value, t]
);

const feedbackHandler = useCallback(
@@ -100,7 +105,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
},
[onLikeDislike, reaction]
);

const getLists = useCallback(
({ choices, isDisabled }: { choices: any; isDisabled: boolean }) => {
console.log('qwer12:', { choices, isDisabled });
@@ -118,7 +123,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
toast.error(`${t('message.cannot_answer_again')}`);
} else {
if (context?.messages?.[0]?.exampleOptions) {
console.log('clearing chat')
console.log('clearing chat');
context?.setMessages([]);
}
context?.sendMessage(choice.text);
@@ -145,7 +150,18 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
return <Typing />;
case 'text':
return (
<div style={{ display: 'flex', flexDirection: 'column' }}>
<div
style={{
display: 'flex',
flexDirection: 'column',
position: 'relative',
}}>
<div
className={
content?.data?.position === 'right'
? styles.messageTriangleRight
: styles.messageTriangleLeft
}></div>
<Bubble type="text">
<span
className="onHover"
5 changes: 4 additions & 1 deletion apps/amakrushi/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ const App = ({
pageProps,
flagsmithState,
}: AppProps & { flagsmithState: any }) => {
console.log("asdfg:",{flagsmithState})
const router = useRouter();
const { isAuthenticated, login } = useLogin();
const [launch, setLaunch] = useState(true);
@@ -96,7 +97,9 @@ const App = ({

App.getInitialProps = async () => {
await flagsmith.init({
environmentID: process.env.NEXT_PUBLIC_ENVIRONMENT_ID,
api:process.env.NEXT_PUBLIC_FLAGSMITH_API,
environmentID: process.env.NEXT_PUBLIC_ENVIRONMENT_ID

});
return { flagsmithState: flagsmith.getState() };
};
1 change: 1 addition & 0 deletions apps/amakrushi/src/types/chat-item/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type ChatItemPropsType = {
name: string;
conversationId: string | null;
deleteConversationById: any;
};
1 change: 1 addition & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
"NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID",
"NEXT_PUBLIC_FIREBASE_APP_ID",
"NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID",
"NEXT_PUBLIC_FLAGSMITH_API",
"ANALYZE",
"NEXT_PUBLIC_ENVIRONMENT_ID",
"NEXT_PUBLIC_BASE_URL",