Compare commits

..

No commits in common. "d5fa97e3f2fa01682cc9319a0f92a44ff99fc24c" and "c162612e62e65f8b32e70dc76179228771e78687" have entirely different histories.

3 changed files with 17 additions and 40 deletions

View File

@ -1,4 +1,4 @@
import { api, Template } from '@/services/api';
import { api } from '@/services/api';
import { auth } from '@/services/auth';
import { useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';
@ -10,9 +10,8 @@ import './index.css';
export default function Create() {
const { templateCode } = useParams();
const [isLoggedIn, setIsLoggedIn] = useState<boolean>(false);
const [loginRedirecting, setLoginRedirecting] = useState(false);
const [template, setTemplate] = useState<Template | null>(null);
const [loginRedirecting, setLoginRedirecting] = useState(false);
useEffect(() => {
const checkLogin = async () => {
@ -23,17 +22,6 @@ export default function Create() {
checkLogin();
}, []);
useEffect(() => {
const fetchTemplate = async () => {
if (!templateCode) {
return;
}
const template = await api.getTemplate(templateCode);
setTemplate(template);
};
fetchTemplate();
}, [templateCode]);
const { t } = useI18n();
const [loading, setLoading] = useState(false);
@ -57,7 +45,7 @@ export default function Create() {
alert('Template code not set');
return;
}
if (!image1 || (template?.imageCount === 2 && !image2)) {
if (!image1 || !image2) {
alert('Upload two images');
return;
}
@ -76,7 +64,7 @@ export default function Create() {
templateCode: templateCode,
metadata: {
cb_url: cbUrl,
imageUrls: [image1, image2 || ''],
imageUrls: [image1, image2],
},
});
if (checkout && checkout.url) {
@ -102,14 +90,6 @@ export default function Create() {
);
}
if (!template) {
return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh' }}>
<div>Loading...</div>
</div>
);
}
return (
<div className="friends-photo">
{/* 上传区域 */}
@ -124,25 +104,23 @@ export default function Create() {
auth.login(window.location.pathname);
}}
/>
{template?.imageCount === 2 && (
<UploadCard
disabled={!isLoggedIn}
imageUrl={image2}
title={t('friendsPhoto.selectFriendPhoto')}
onUploadSuccess={setImage2}
onLogin={() => {
setLoginRedirecting(true);
auth.login(window.location.pathname);
}}
/>
)}
<UploadCard
disabled={!isLoggedIn}
imageUrl={image2}
title={t('friendsPhoto.selectFriendPhoto')}
onUploadSuccess={setImage2}
onLogin={() => {
setLoginRedirecting(true);
auth.login(window.location.pathname);
}}
/>
</div>
{/* 固定底部按钮 */}
<div className="submit-section">
<button
className={`submit-button ${(!image1 || (template?.imageCount === 2 && !image2) || loading) && isLoggedIn ? 'disabled' : ''}`}
disabled={(!image1 || (template?.imageCount === 2 && !image2) || loading) && isLoggedIn}
className={`submit-button ${(!image1 || !image2 || loading) && isLoggedIn ? 'disabled' : ''}`}
disabled={(!image1 || !image2 || loading) && isLoggedIn}
onClick={handleSubmit}
>
{isLoggedIn === false ? (

View File

@ -34,7 +34,7 @@ export default function Home() {
return (
<div className="home">
<div className="home-header">
New User 50% Off : <span className="coupon-text">NEWUSER</span>
New User 50% Off : <span className="coupon-text">BESTAI1ST</span>
</div>
<div className="home-scroll">
<div className="template-grid">

View File

@ -38,7 +38,6 @@ export interface Template {
imagePrompt?: string; // 图片生成提示词
createdAt?: string; // 创建时间
lastStripeSyncAt?: string; // 最后同步Stripe时间
imageCount?: number; // 图片数量
}
/**