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

Dev #709, #710, #711 #712

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 18 additions & 4 deletions app/src/client/app/PlayGroundPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,19 @@ const PlayGroundPage = ({ user }: { user: User }) => {
useEffect(() => {
if (formSubmitMsg && currentChatDetails) {
if (!currentChatDetails.userRespondedWithNextAction) {
setTriggerChatFormSubmitMsg(formSubmitMsg);
try {
const decodedMessage = decodeURIComponent(formSubmitMsg);
setTriggerChatFormSubmitMsg(decodedMessage);
} catch (err: any) {
console.log('Error: ' + err.message);
setNotificationErrorMessage('There was an error processing your message. Please start a new chat.');
updateCurrentChat({
id: activeChatId,
data: {
isChatTerminated: true,
},
});
}
}
removeQueryParameters();
}
Expand Down Expand Up @@ -197,9 +209,11 @@ const PlayGroundPage = ({ user }: { user: User }) => {
/>
</>
) : (
<div className='z-[999999] absolute inset-0 flex items-center justify-center bg-white bg-opacity-50'>
<Loader />
</div>
!currentChatDetails.isChatTerminated && (
<div className='z-[10000] absolute inset-0 flex items-center justify-center bg-white bg-opacity-50'>
<Loader />
</div>
)
)}
</div>
) : (
Expand Down
2 changes: 1 addition & 1 deletion app/src/client/components/NotificationBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const NotificationBox: React.FC<NotificationBoxProps> = ({ type, message, onClic
const isSuccess = type === 'success';

return (
<div className='fixed inset-0 flex items-center justify-center z-50 p-16 backdrop-blur-sm bg-airt-font-base/30'>
<div className='fixed inset-0 flex items-center justify-center z-[10000] p-16 backdrop-blur-sm bg-airt-font-base/30'>
<div className='bg-airt-primary rounded-lg shadow-lg p-8 m-4 max-w-sm mx-auto'>
<h2 className='text-xl font-bold mb-4 text-airt-font-base'>{isSuccess ? 'Success' : 'Error'}</h2>
<p className='text-airt-font-base'>{message}</p>
Expand Down
25 changes: 15 additions & 10 deletions app/src/client/components/SelectTeamToChat.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useState, useEffect, useRef } from 'react';
import { useHistory } from 'react-router-dom';
import Select from 'react-select';
import { type Chat } from 'wasp/entities';
import { SelectedModelSchema } from '../interfaces/BuildPageInterfaces';
import { CreateNewChatProps } from '../interfaces/PlaygroundPageInterface';
import NotificationBox from './NotificationBox';
import { SelectInput } from './form/SelectInput';
import TextareaAutosize from 'react-textarea-autosize';
import { createNewChat } from 'wasp/client/operations';

Expand All @@ -18,8 +18,8 @@ const SelectTeamToChat = ({ userTeams }: any) => {
const [isSubmitting, setIsSubmitting] = useState(false);
const isRedirecting = useRef(false);

const handleTeamChange = (value: string) => {
setTeam(value);
const handleTeamChange = (selectedOption: { value: string; label: string } | null) => {
setTeam(selectedOption ? selectedOption.value : '');
};

const handleMessageChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
Expand Down Expand Up @@ -51,7 +51,8 @@ const SelectTeamToChat = ({ userTeams }: any) => {
};
const chat: Chat = await createNewChat(props);
isRedirecting.current = true;
history.push(`/playground/${chat.uuid}?initiateChatMsg=${message}`);
const encodedMessage = encodeURIComponent(message);
history.push(`/playground/${chat.uuid}?initiateChatMsg=${encodedMessage}`);
} catch (err: any) {
setNotificationErrorMessage(`Error creating chat. Please try again later.`);
console.log('Error: ' + err.message);
Expand All @@ -70,7 +71,12 @@ const SelectTeamToChat = ({ userTeams }: any) => {
setNotificationErrorMessage(null);
};

const options = allTeams ? allTeams.map((team: SelectedModelSchema) => team.json_str.name) : [];
const options = allTeams
? allTeams.map((team: SelectedModelSchema) => ({
value: team.json_str.name,
label: team.json_str.name,
}))
: [];

return (
<div className='lg:mx-auto max-w-screen-2xl p-4 md:p-6 2xl:p-10'>
Expand All @@ -81,14 +87,13 @@ const SelectTeamToChat = ({ userTeams }: any) => {
<label className='text-airt-primary' htmlFor='selectTeam'>
Select Team
</label>
<SelectInput
<Select
id='selectTeam'
value={team}
options={options}
onChange={handleTeamChange}
propertyTypes={null}
handleAddProperty={() => {}}
isRequired={true}
className='pt-1 pb-1'
value={options.find((option) => option.value === team) || null}
isSearchable={true}
/>
{formError.team && <div style={{ color: 'red' }}>{formError.team}</div>}
<label className='mt-2 text-airt-primary inline-block' htmlFor='setSystemMessage'>
Expand Down
149 changes: 0 additions & 149 deletions app/src/client/components/form/SelectInput.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion auth_callout/packages/auth-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "module",
"main": "./lib/index.js",
"devDependencies": {
"@types/node": "^22.5.2"
"@types/node": "^22.5.3"
},
"dependencies": {
"@prisma/client": "^5.19.0",
Expand Down
22 changes: 11 additions & 11 deletions auth_callout/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading