fix build
This commit is contained in:
parent
012d8756d8
commit
4180300ab1
@ -97,9 +97,7 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
|
||||
// 模拟 AI API 调用
|
||||
async function runAITest({
|
||||
content,
|
||||
model,
|
||||
temperature: _temperature,
|
||||
maxTokens: _maxTokens
|
||||
model
|
||||
}: {
|
||||
content: string
|
||||
model: string
|
||||
|
@ -3,7 +3,7 @@ import { prisma } from '@/lib/prisma'
|
||||
import { createServerSupabaseClient } from '@/lib/supabase-server'
|
||||
|
||||
// POST /api/users/sync - 同步Supabase用户到Prisma数据库
|
||||
export async function POST(request: NextRequest) {
|
||||
export async function POST(_request: NextRequest) {
|
||||
try {
|
||||
const supabase = await createServerSupabaseClient()
|
||||
const { data: { user: supabaseUser }, error: authError } = await supabase.auth.getUser()
|
||||
@ -64,7 +64,7 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
// GET /api/users/sync - 获取当前用户信息
|
||||
export async function GET(request: NextRequest) {
|
||||
export async function GET(_request: NextRequest) {
|
||||
try {
|
||||
const supabase = await createServerSupabaseClient()
|
||||
const { data: { user: supabaseUser }, error: authError } = await supabase.auth.getUser()
|
||||
|
@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import { useTranslations } from 'next-intl'
|
||||
import { useAuth } from '@/hooks/useAuth'
|
||||
import { createClient } from '@/lib/supabase'
|
||||
@ -57,46 +57,45 @@ export default function ProfilePage() {
|
||||
|
||||
const supabase = createClient()
|
||||
|
||||
const loadProfile = useCallback(async () => {
|
||||
setProfileLoading(true)
|
||||
try {
|
||||
// Get user metadata and profile data
|
||||
const { data: { user: userData }, error: userError } = await supabase.auth.getUser()
|
||||
|
||||
if (userError) throw userError
|
||||
|
||||
const profileData: UserProfile = {
|
||||
id: userData?.id || '',
|
||||
email: userData?.email || '',
|
||||
username: userData?.user_metadata?.username || userData?.user_metadata?.full_name || '',
|
||||
bio: userData?.user_metadata?.bio || '',
|
||||
avatar_url: userData?.user_metadata?.avatar_url || '',
|
||||
language: userData?.user_metadata?.language || 'en'
|
||||
}
|
||||
|
||||
setProfile(profileData)
|
||||
setFormData({
|
||||
username: profileData.username || '',
|
||||
email: profileData.email,
|
||||
bio: profileData.bio || '',
|
||||
currentPassword: '',
|
||||
newPassword: '',
|
||||
confirmPassword: '',
|
||||
language: profileData.language || 'en'
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Error loading profile:', error)
|
||||
setSaveStatus({ type: 'error', message: t('failedToLoadProfile') })
|
||||
} finally {
|
||||
setProfileLoading(false)
|
||||
}
|
||||
}, [supabase, t])
|
||||
|
||||
useEffect(() => {
|
||||
if (!user) return
|
||||
|
||||
const loadProfile = async () => {
|
||||
setProfileLoading(true)
|
||||
try {
|
||||
// Get user metadata and profile data
|
||||
const { data: { user: userData }, error: userError } = await supabase.auth.getUser()
|
||||
|
||||
if (userError) throw userError
|
||||
|
||||
const profileData: UserProfile = {
|
||||
id: userData?.id || '',
|
||||
email: userData?.email || '',
|
||||
username: userData?.user_metadata?.username || userData?.user_metadata?.full_name || '',
|
||||
bio: userData?.user_metadata?.bio || '',
|
||||
avatar_url: userData?.user_metadata?.avatar_url || '',
|
||||
language: userData?.user_metadata?.language || 'en'
|
||||
}
|
||||
|
||||
setProfile(profileData)
|
||||
setFormData({
|
||||
username: profileData.username || '',
|
||||
email: profileData.email,
|
||||
bio: profileData.bio || '',
|
||||
currentPassword: '',
|
||||
newPassword: '',
|
||||
confirmPassword: '',
|
||||
language: profileData.language || 'en'
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Error loading profile:', error)
|
||||
setSaveStatus({ type: 'error', message: t('failedToLoadProfile') })
|
||||
} finally {
|
||||
setProfileLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
loadProfile()
|
||||
}, [user, supabase, t])
|
||||
}, [user, loadProfile])
|
||||
|
||||
const updateProfile = async (field: string, value: string) => {
|
||||
if (!user) return
|
||||
|
@ -81,7 +81,7 @@ export default function PromptPage({ params }: PromptPageProps) {
|
||||
const processedData = {
|
||||
...data,
|
||||
tags: Array.isArray(data.tags)
|
||||
? data.tags.map((tag: any) => typeof tag === 'string' ? tag : tag.name || '')
|
||||
? data.tags.map((tag: string | { name: string }) => typeof tag === 'string' ? tag : tag.name || '')
|
||||
: []
|
||||
}
|
||||
setPrompt(processedData)
|
||||
@ -273,8 +273,8 @@ export default function PromptPage({ params }: PromptPageProps) {
|
||||
<p className="text-xs text-muted-foreground mt-1 line-clamp-2">{prompt?.description || ''}</p>
|
||||
<div className="flex items-center mt-2 space-x-2">
|
||||
{prompt?.tags?.slice(0, 1).map((tag) => (
|
||||
<span key={typeof tag === 'string' ? tag : (tag as any)?.name || ''} className="inline-flex items-center px-1.5 py-0.5 text-xs font-medium bg-primary/10 text-primary rounded">
|
||||
{typeof tag === 'string' ? tag : (tag as any)?.name || ''}
|
||||
<span key={typeof tag === 'string' ? tag : (tag as { name: string })?.name || ''} className="inline-flex items-center px-1.5 py-0.5 text-xs font-medium bg-primary/10 text-primary rounded">
|
||||
{typeof tag === 'string' ? tag : (tag as { name: string })?.name || ''}
|
||||
</span>
|
||||
))}
|
||||
{prompt?.tags && prompt.tags.length > 1 && (
|
||||
@ -349,7 +349,7 @@ export default function PromptPage({ params }: PromptPageProps) {
|
||||
</div>
|
||||
<div className="pt-2 border-t border-border">
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{prompt?.tags?.map((tag: any) => {
|
||||
{prompt?.tags?.map((tag: string | { name: string }) => {
|
||||
const tagName = typeof tag === 'string' ? tag : tag?.name || '';
|
||||
return (
|
||||
<span
|
||||
|
@ -55,7 +55,7 @@ export function EditPromptModal({
|
||||
setDescription(prompt.description || '')
|
||||
// 确保tags是字符串数组
|
||||
const processedTags = Array.isArray(prompt.tags)
|
||||
? prompt.tags.map((tag: any) => typeof tag === 'string' ? tag : tag.name || '')
|
||||
? prompt.tags.map((tag: string | { name: string }) => typeof tag === 'string' ? tag : tag.name || '')
|
||||
: []
|
||||
setTags(processedTags)
|
||||
fetchAvailableTags()
|
||||
|
@ -11,7 +11,7 @@ export function useAuth() {
|
||||
|
||||
useEffect(() => {
|
||||
// 同步用户到Prisma数据库
|
||||
const syncUser = async (_userData: User) => {
|
||||
const syncUser = async () => {
|
||||
try {
|
||||
await fetch('/api/users/sync', {
|
||||
method: 'POST',
|
||||
@ -25,7 +25,7 @@ export function useAuth() {
|
||||
const getUser = async () => {
|
||||
const { data: { user: userData } } = await supabase.auth.getUser()
|
||||
if (userData) {
|
||||
await syncUser(userData)
|
||||
await syncUser()
|
||||
}
|
||||
setUser(userData)
|
||||
setLoading(false)
|
||||
@ -36,7 +36,7 @@ export function useAuth() {
|
||||
const { data: { subscription } } = supabase.auth.onAuthStateChange(async (event, session) => {
|
||||
const userData = session?.user ?? null
|
||||
if (userData && (event === 'SIGNED_IN' || event === 'TOKEN_REFRESHED')) {
|
||||
await syncUser(userData)
|
||||
await syncUser()
|
||||
}
|
||||
setUser(userData)
|
||||
setLoading(false)
|
||||
|
Loading…
Reference in New Issue
Block a user