fix: ShareModal shows blank overlay when factoryId is undefined

When clicking "分享链接" for unlinked plans, factoryId is undefined.
The ShareModal's useEffect returned early without setting hasRelationship,
leaving it as null — none of the three conditional branches rendered,
showing only the backdrop overlay with no content.

Fix: when factoryId is missing, set hasRelationship=false directly to
show the share link generation UI. Also remove the factoryId guard from
generateShortLink since it only needs planId and factoryType.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Chever John 2026-06-30 02:31:57 +08:00
parent 31ea850769
commit 68da2c2c20
No known key found for this signature in database
GPG Key ID: 2894D52ED1211DF0

View File

@ -75,7 +75,14 @@ export function ShareModal({
// 获取当前用户的公司名称和检查合作关系 // 获取当前用户的公司名称和检查合作关系
useEffect(() => { useEffect(() => {
const fetchData = async () => { const fetchData = async () => {
if (!isOpen || !factoryId) return; if (!isOpen) return;
// No factoryId means unlinked plan — skip relationship check, go straight to share link
if (!factoryId) {
setHasRelationship(false);
setIsCheckingRelationship(false);
return;
}
setIsCheckingRelationship(true); setIsCheckingRelationship(true);
@ -132,8 +139,6 @@ export function ShareModal({
// 生成短链30分钟有效 // 生成短链30分钟有效
const generateShortLink = useCallback(async () => { const generateShortLink = useCallback(async () => {
if (!factoryId) return;
setIsGeneratingLink(true); setIsGeneratingLink(true);
try { try {