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

View File

@ -34,7 +34,7 @@ export default function Home() {
return ( return (
<div className="home"> <div className="home">
<div className="home-header"> <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>
<div className="home-scroll"> <div className="home-scroll">
<div className="template-grid"> <div className="template-grid">

View File

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