const { GIGS } = require('./_seed') function text(t) { return [{ type: 'text', text: t }] } async function listTeamGigs({ kind = 'all', keyword } = {}) { const k = String(kind || 'all') const q = String(keyword || '') .trim() .toLowerCase() const gigs = GIGS.filter((g) => { if (k !== 'all' && g.kind !== k) return false if (!q) return true const hay = `${g.title} ${g.role} ${(g.tags || []).join(' ')}`.toLowerCase() return hay.includes(q) }) return { isError: false, content: text( gigs.length ? `找到 ${gigs.length} 个机会。选一个后用 applyTeamGig,或点卡片打开申请页填表。` : '暂时没有匹配机会,换个关键词或打开找搭子页看看。', ), structuredContent: { gigs, pagePath: '/pages/social/team/index', linkText: '打开找搭子', }, handoff: () => ({ query: [ k !== 'all' ? `kind=${encodeURIComponent(k)}` : '', q ? `q=${encodeURIComponent(keyword)}` : '', ] .filter(Boolean) .join('&'), payload: { gigs, kind: k, keyword: keyword || '' }, }), } } module.exports = listTeamGigs