Skip to content

Commit

Permalink
fix: resolve the infinite redirect issue on the edit page (#546)
Browse files Browse the repository at this point in the history
* style: fix agreement accept model

* fix: sovle the rerender of the edit page
  • Loading branch information
xingwanying authored Nov 30, 2024
1 parent 63f5813 commit bc76d17
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 28 deletions.
64 changes: 39 additions & 25 deletions client/app/factory/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ import DeployBotModal from './components/DeployBotModal';
import Markdown from '@/components/Markdown';
import AgreementZhCN from '../../../.kiwi/zh-CN/agreement.md';
import AgreementEN from '../../../.kiwi/en/agreement.md';
import AgreementJA from '../../../.kiwi/ja/agreement.md';
import AgreementKO from '../../../.kiwi/ko/agreement.md';
import AgreementZhTW from '../../../.kiwi/zh-TW/agreement.md';

const API_HOST = process.env.NEXT_PUBLIC_API_DOMAIN;
enum VisibleTypeEnum {
Expand Down Expand Up @@ -81,6 +84,12 @@ export default function Edit() {
switch (language) {
case 'zh-CN':
return AgreementZhCN;
case 'zh-TW':
return AgreementZhTW;
case 'ja':
return AgreementJA;
case 'ko':
return AgreementKO;
case 'en':
return AgreementEN;
default:
Expand All @@ -89,7 +98,10 @@ export default function Edit() {
}, [language]);

useEffect(() => {
if (!user || status !== 'success' || user.id.startsWith('client|')) {
if (status === 'pending') {
return;
}
if (!user || user.id.startsWith('client|')) {
router.push(`${apiDomain}/api/auth/login`);
} else {
if (!user?.agreement_accepted) {
Expand Down Expand Up @@ -631,30 +643,32 @@ export default function Edit() {
{I18N.app.page.agreementLabel}
</Checkbox>
</div>
<div className="flex-1 text-right space-x-2">
<Button
radius="full"
variant="bordered"
color="default"
className="border-gray-700 text-gray-700"
onPress={() => {
router.push('/factory/list');
}}
>
{I18N.components.BotCreateFrom.quXiao}
</Button>
<Button
isDisabled={!agreementAccepted}
radius="full"
isLoading={acceptAgreementLoading}
color="default"
onPress={() => {
onAcceptAgreement();
}}
className="bg-gray-700 text-white "
>
{I18N.components.BotCreateFrom.queRen}
</Button>
<div className="flex-1 text-right">
<div className="flex items-center justify-end px-4 space-x-2">
<Button
radius="full"
variant="bordered"
color="default"
className="border-gray-700 text-gray-700"
onPress={() => {
router.push('/factory/list');
}}
>
{I18N.components.BotCreateFrom.quXiao}
</Button>
<Button
isDisabled={!agreementAccepted}
radius="full"
isLoading={acceptAgreementLoading}
color="default"
onPress={() => {
onAcceptAgreement();
}}
className="bg-gray-700 text-white "
>
{I18N.components.BotCreateFrom.queRen}
</Button>
</div>
</div>
</ModalFooter>
</>
Expand Down
4 changes: 2 additions & 2 deletions server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ langserve
langchain_community>=0.2.11
langchain>=0.2.12
langchain_google_genai
PyGithub
GitPython
PyGithub==2.3.0
GitPython>=3.1.43
python-multipart
httpx[socks]
supabase
Expand Down
3 changes: 2 additions & 1 deletion server/setup_python.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
python3 -m pip install --upgrade pip
pip3 install --no-cache-dir -r requirements.txt

0 comments on commit bc76d17

Please sign in to comment.