Add optional resume uploads to social hiring applications.
Let applicants attach PDF/Word/image resumes on team apply, store the file URL with the gig application, and surface it in admin gig apps. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
566d625100
commit
756f02594d
@ -385,6 +385,18 @@ export default function SocialData() {
|
||||
<td>
|
||||
{it.contact}
|
||||
<div style={{ opacity: 0.7 }}>{cell(it.note, 80)}</div>
|
||||
{it.resumeUrl ? (
|
||||
<div style={{ marginTop: 6 }}>
|
||||
<a
|
||||
href={String(it.resumeUrl)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
style={{ fontSize: 12 }}
|
||||
>
|
||||
📎 {String(it.resumeName || '简历附件')}
|
||||
</a>
|
||||
</div>
|
||||
) : null}
|
||||
</td>
|
||||
<td>{it.at}</td>
|
||||
<td>
|
||||
|
||||
@ -309,6 +309,8 @@ SOCIAL_GIG_APPS = _base(
|
||||
_text("name"),
|
||||
_text("contact"),
|
||||
_text("note"),
|
||||
_text("resume_url"),
|
||||
_text("resume_name"),
|
||||
_text("request_id"),
|
||||
_text("created_at", True),
|
||||
],
|
||||
|
||||
@ -1798,6 +1798,9 @@ def add_gig_app(
|
||||
note: str,
|
||||
guest_id: str,
|
||||
request_id: str | None = None,
|
||||
*,
|
||||
resume_url: str = "",
|
||||
resume_name: str = "",
|
||||
) -> dict[str, Any]:
|
||||
import hashlib
|
||||
import json as _json
|
||||
@ -1812,12 +1815,16 @@ def add_gig_app(
|
||||
_json.dumps([guest_id, gig_id, request_id]).encode()
|
||||
).hexdigest()[:32]
|
||||
)
|
||||
resume_u = (resume_url or "").strip()[:800]
|
||||
resume_n = (resume_name or "").strip()[:200]
|
||||
body = {
|
||||
"gig_id": gig_id,
|
||||
"guest_id": guest_id,
|
||||
"name": (name or "").strip()[:64],
|
||||
"contact": (contact or "").strip()[:120],
|
||||
"note": (note or "").strip()[:2000],
|
||||
"resume_url": resume_u,
|
||||
"resume_name": resume_n,
|
||||
"request_id": request_id or "",
|
||||
"created_at": now,
|
||||
}
|
||||
@ -1828,10 +1835,21 @@ def add_gig_app(
|
||||
filter=f"request_id={pb_quote(request_id or '')} && guest_id={pb_quote(guest_id)} && gig_id={pb_quote(gig_id)}",
|
||||
)
|
||||
if existing:
|
||||
if (
|
||||
(existing.get("name"), existing.get("contact"), existing.get("note"))
|
||||
!= (body["name"], body["contact"], body["note"])
|
||||
):
|
||||
prev = (
|
||||
existing.get("name"),
|
||||
existing.get("contact"),
|
||||
existing.get("note") or "",
|
||||
existing.get("resume_url") or "",
|
||||
existing.get("resume_name") or "",
|
||||
)
|
||||
cur = (
|
||||
body["name"],
|
||||
body["contact"],
|
||||
body["note"],
|
||||
body["resume_url"],
|
||||
body["resume_name"],
|
||||
)
|
||||
if prev != cur:
|
||||
raise ValueError("同一请求标识不能用于不同申请")
|
||||
return {
|
||||
"id": existing.get("id"),
|
||||
@ -1839,6 +1857,8 @@ def add_gig_app(
|
||||
"name": existing.get("name"),
|
||||
"contact": existing.get("contact"),
|
||||
"note": existing.get("note") or "",
|
||||
"resumeUrl": existing.get("resume_url") or "",
|
||||
"resumeName": existing.get("resume_name") or "",
|
||||
"guestId": guest_id,
|
||||
"at": existing.get("created_at") or now,
|
||||
}
|
||||
@ -1849,6 +1869,8 @@ def add_gig_app(
|
||||
"name": body["name"],
|
||||
"contact": body["contact"],
|
||||
"note": body["note"],
|
||||
"resumeUrl": body["resume_url"],
|
||||
"resumeName": body["resume_name"],
|
||||
"guestId": guest_id,
|
||||
"at": now,
|
||||
}
|
||||
@ -2087,6 +2109,8 @@ def admin_list_gig_apps(
|
||||
"name": r.get("name"),
|
||||
"contact": r.get("contact"),
|
||||
"note": r.get("note") or "",
|
||||
"resumeUrl": r.get("resume_url") or "",
|
||||
"resumeName": r.get("resume_name") or "",
|
||||
"guestId": r.get("guest_id"),
|
||||
"at": r.get("created_at"),
|
||||
}
|
||||
|
||||
@ -145,6 +145,8 @@ class GigAppIn(BaseModel):
|
||||
name: str = Field(min_length=1, max_length=64)
|
||||
contact: str = Field(min_length=1, max_length=120)
|
||||
note: str = Field(default="", max_length=2000)
|
||||
resumeUrl: str = Field(default="", max_length=800)
|
||||
resumeName: str = Field(default="", max_length=200)
|
||||
requestId: str | None = Field(default=None, min_length=1, max_length=80)
|
||||
|
||||
|
||||
@ -423,19 +425,65 @@ async def upload_media(
|
||||
x_social_guest_id: str | None = Header(default=None),
|
||||
guest: str | None = Query(default=None),
|
||||
):
|
||||
"""Guest-friendly image upload → SeaweedFS S3 (fallback local).
|
||||
"""Guest-friendly upload → SeaweedFS S3 (fallback local).
|
||||
|
||||
Avatar / roster / profile: optional face presence gate (InsightFace → OpenCV).
|
||||
- purpose=avatar|roster|profile: image + optional face gate
|
||||
- purpose=resume|cv|gig-resume: PDF/DOC/DOCX/图片简历,跳过人脸检测
|
||||
"""
|
||||
peer = _guest(x_social_guest_id, guest)
|
||||
purpose_norm = (purpose or "avatar")[:40]
|
||||
is_resume = purpose_norm.lower() in {"resume", "cv", "gig-resume"}
|
||||
ctype = (file.content_type or "").lower()
|
||||
if not ctype.startswith("image/"):
|
||||
raise HTTPException(status_code=400, detail="仅支持图片")
|
||||
raw = await file.read()
|
||||
if not raw:
|
||||
raise HTTPException(status_code=400, detail="空文件")
|
||||
|
||||
if is_resume:
|
||||
name = (file.filename or "resume.pdf").strip() or "resume.pdf"
|
||||
suffix = ("." + name.rsplit(".", 1)[-1].lower()) if "." in name else ""
|
||||
ok_suffix = {".pdf", ".doc", ".docx", ".txt", ".rtf", ".png", ".jpg", ".jpeg", ".webp"}
|
||||
if suffix and suffix not in ok_suffix and not ctype.startswith("image/"):
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="简历仅支持 PDF / Word / 图片",
|
||||
)
|
||||
max_bytes = min(SOCIAL_UPLOAD_MAX_BYTES, 10 * 1024 * 1024)
|
||||
|
||||
def persist_resume():
|
||||
from social_svc.s3_upload import upload_bytes
|
||||
|
||||
return upload_bytes(
|
||||
raw,
|
||||
filename=name,
|
||||
content_type=file.content_type or "application/octet-stream",
|
||||
purpose="resume",
|
||||
guest_id=peer,
|
||||
max_size=max_bytes,
|
||||
)
|
||||
|
||||
try:
|
||||
result = await run_in_threadpool(persist_resume)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=503, detail=f"上传失败: {exc}") from exc
|
||||
return {
|
||||
"ok": True,
|
||||
"success": True,
|
||||
"url": result.url,
|
||||
"object_key": result.object_key,
|
||||
"size": result.size,
|
||||
"content_type": result.content_type,
|
||||
"storage": result.storage,
|
||||
"name": name[:200],
|
||||
"faceOk": False,
|
||||
"faceCheckEnabled": False,
|
||||
"livenessRequired": False,
|
||||
}
|
||||
|
||||
if not ctype.startswith("image/"):
|
||||
raise HTTPException(status_code=400, detail="仅支持图片")
|
||||
max_avatar = min(SOCIAL_UPLOAD_MAX_BYTES, 8 * 1024 * 1024)
|
||||
purpose_norm = (purpose or "avatar")[:40]
|
||||
|
||||
def persist():
|
||||
from social_svc.face_check import (
|
||||
@ -660,6 +708,20 @@ def get_local_liveness(name: str):
|
||||
return FileResponse(path)
|
||||
|
||||
|
||||
@router.get("/files/resume/{name}")
|
||||
def get_local_resume(name: str):
|
||||
"""Serve locally-fallback resume attachments when S3 is unavailable."""
|
||||
from social_svc.config import SOCIAL_UPLOAD_DIR
|
||||
|
||||
safe = Path(name).name
|
||||
if safe != name or ".." in name:
|
||||
raise HTTPException(status_code=400, detail="非法文件名")
|
||||
path = SOCIAL_UPLOAD_DIR / "resumes" / safe
|
||||
if not path.is_file():
|
||||
raise HTTPException(status_code=404, detail="not found")
|
||||
return FileResponse(path)
|
||||
|
||||
|
||||
@router.get("/liveness/audits")
|
||||
def liveness_audits(
|
||||
status: str = Query(default=""),
|
||||
@ -1100,7 +1162,16 @@ def post_gig_apply(
|
||||
raise HTTPException(status_code=400, detail="请填写称呼和联系方式")
|
||||
store.init_db()
|
||||
try:
|
||||
return store.add_gig_app(gig_id, body.name, body.contact, body.note, guest, body.requestId)
|
||||
return store.add_gig_app(
|
||||
gig_id,
|
||||
body.name,
|
||||
body.contact,
|
||||
body.note,
|
||||
guest,
|
||||
body.requestId,
|
||||
resume_url=body.resumeUrl,
|
||||
resume_name=body.resumeName,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=409, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@ -63,6 +63,24 @@ def _client():
|
||||
return _boto
|
||||
|
||||
|
||||
_RESUME_SUFFIX = {".pdf", ".doc", ".docx", ".txt", ".rtf", ".png", ".jpg", ".jpeg", ".webp"}
|
||||
_RESUME_MIME = {
|
||||
".pdf": "application/pdf",
|
||||
".doc": "application/msword",
|
||||
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
".txt": "text/plain",
|
||||
".rtf": "application/rtf",
|
||||
".png": "image/png",
|
||||
".jpg": "image/jpeg",
|
||||
".jpeg": "image/jpeg",
|
||||
".webp": "image/webp",
|
||||
}
|
||||
|
||||
|
||||
def _allow_resume(purpose: str) -> bool:
|
||||
return (purpose or "").strip().lower() in {"resume", "cv", "gig-resume"}
|
||||
|
||||
|
||||
def _object_key(filename: str, purpose: str, guest_id: str) -> str:
|
||||
suffix = Path(filename or "upload.bin").suffix.lower() or ".jpg"
|
||||
img_ok = {".jpg", ".jpeg", ".png", ".webp", ".gif"}
|
||||
@ -73,12 +91,17 @@ def _object_key(filename: str, purpose: str, guest_id: str) -> str:
|
||||
"room-archive",
|
||||
"meetup-archive",
|
||||
}
|
||||
allow_resume = _allow_resume(purpose)
|
||||
if suffix in img_ok:
|
||||
pass
|
||||
elif allow_resume and suffix in _RESUME_SUFFIX:
|
||||
pass
|
||||
elif allow_video and suffix in vid_ok:
|
||||
pass
|
||||
elif allow_video:
|
||||
suffix = ".webm"
|
||||
elif allow_resume:
|
||||
suffix = ".pdf"
|
||||
else:
|
||||
suffix = ".jpg"
|
||||
day = datetime.now(timezone.utc).strftime("%Y/%m/%d")
|
||||
@ -119,9 +142,25 @@ def upload_bytes(
|
||||
"room-archive",
|
||||
"meetup-archive",
|
||||
}
|
||||
allow_resume = _allow_resume(purpose)
|
||||
# Browser FormData Blob parts often arrive as application/octet-stream
|
||||
if ctype.startswith("image/"):
|
||||
pass
|
||||
elif allow_resume and (
|
||||
suffix in _RESUME_SUFFIX
|
||||
or ctype in {
|
||||
"application/pdf",
|
||||
"application/msword",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"application/rtf",
|
||||
"text/plain",
|
||||
"application/octet-stream",
|
||||
}
|
||||
):
|
||||
if suffix not in _RESUME_SUFFIX:
|
||||
# octet-stream without extension → treat as pdf
|
||||
suffix = ".pdf"
|
||||
ctype = _RESUME_MIME.get(suffix) or guessed or "application/pdf"
|
||||
elif allow_video and (
|
||||
ctype.startswith("video/")
|
||||
or suffix in {".webm", ".mp4", ".mov", ".mkv"}
|
||||
@ -139,7 +178,11 @@ def upload_bytes(
|
||||
"image/jpeg" if suffix in {".jpg", ".jpeg", ""} else f"image/{suffix[1:]}"
|
||||
)
|
||||
else:
|
||||
raise ValueError("only images allowed" if not allow_video else "only images/videos allowed")
|
||||
raise ValueError(
|
||||
"only resume files allowed"
|
||||
if allow_resume
|
||||
else ("only images allowed" if not allow_video else "only images/videos allowed")
|
||||
)
|
||||
|
||||
key = _object_key(filename, purpose, guest_id)
|
||||
|
||||
@ -162,21 +205,27 @@ def upload_bytes(
|
||||
|
||||
# Local fallback (dev / S3 off / S3 error)
|
||||
# Live audit assets never land in avatars/
|
||||
sub = (
|
||||
"room-archive"
|
||||
if (purpose or "") in {"room-archive", "meetup-archive"}
|
||||
else (
|
||||
"liveness"
|
||||
if allow_video
|
||||
or ctype.startswith("video/")
|
||||
or (purpose or "").startswith("liveness")
|
||||
else "avatars"
|
||||
)
|
||||
)
|
||||
if (purpose or "") in {"room-archive", "meetup-archive"}:
|
||||
sub = "room-archive"
|
||||
elif allow_resume:
|
||||
sub = "resumes"
|
||||
elif (
|
||||
allow_video
|
||||
or ctype.startswith("video/")
|
||||
or (purpose or "").startswith("liveness")
|
||||
):
|
||||
sub = "liveness"
|
||||
else:
|
||||
sub = "avatars"
|
||||
path = SOCIAL_UPLOAD_DIR / sub / Path(key).name
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_bytes(data)
|
||||
route = "liveness" if sub == "liveness" else "avatar"
|
||||
if sub == "liveness":
|
||||
route = "liveness"
|
||||
elif sub == "resumes":
|
||||
route = "resume"
|
||||
else:
|
||||
route = "avatar"
|
||||
return UploadResult(
|
||||
url=f"/api/social/v1/files/{route}/{path.name}",
|
||||
object_key=str(path),
|
||||
|
||||
@ -1053,10 +1053,22 @@ def add_gig_app(
|
||||
note: str,
|
||||
guest_id: str,
|
||||
request_id: str | None = None,
|
||||
*,
|
||||
resume_url: str = "",
|
||||
resume_name: str = "",
|
||||
) -> dict[str, Any]:
|
||||
from social_svc import pb_data
|
||||
|
||||
return pb_data.add_gig_app(gig_id, name, contact, note, guest_id, request_id)
|
||||
return pb_data.add_gig_app(
|
||||
gig_id,
|
||||
name,
|
||||
contact,
|
||||
note,
|
||||
guest_id,
|
||||
request_id,
|
||||
resume_url=resume_url,
|
||||
resume_name=resume_name,
|
||||
)
|
||||
|
||||
|
||||
def health() -> dict[str, Any]:
|
||||
|
||||
@ -1509,6 +1509,55 @@ html[data-theme="light"] .social-ambient {
|
||||
font-style: normal;
|
||||
font-weight: 650;
|
||||
}
|
||||
.social-apply-resume-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary, #94a3b8);
|
||||
}
|
||||
.social-apply-resume {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
border-radius: 14px;
|
||||
border: 1px dashed color-mix(in srgb, #fff 16%, transparent);
|
||||
background: color-mix(in srgb, #fff 4%, transparent);
|
||||
}
|
||||
.social-apply-resume-label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
font-weight: 650;
|
||||
}
|
||||
.social-apply-resume-input {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
.social-apply-resume-file {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.social-apply-resume-file a {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-height: 40px;
|
||||
color: #5ce1d6;
|
||||
text-decoration: none;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
word-break: break-all;
|
||||
}
|
||||
.social-apply-resume-file a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.social-contribute-btn {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
@ -1,17 +1,26 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo, useRef, useState, type FormEvent } from "react";
|
||||
import {
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
type FormEvent,
|
||||
} from "react";
|
||||
import Link from "next/link";
|
||||
import {
|
||||
ArrowUpRight,
|
||||
BookOpen,
|
||||
BriefcaseBusiness,
|
||||
Check,
|
||||
FileUp,
|
||||
Globe2,
|
||||
HeartHandshake,
|
||||
MapPin,
|
||||
Paperclip,
|
||||
Send,
|
||||
Sparkles,
|
||||
X,
|
||||
} from "lucide-react";
|
||||
import SiteShell from "./SiteShell";
|
||||
import {
|
||||
@ -31,6 +40,10 @@ import { socialTx } from "@social/lib/socialTx";
|
||||
import { useSocialI18n } from "@social/lib/useSocialI18n";
|
||||
import { txGig } from "@social/lib/localizeEntity";
|
||||
|
||||
const RESUME_ACCEPT =
|
||||
".pdf,.doc,.docx,.txt,.rtf,image/png,image/jpeg,image/webp,application/pdf";
|
||||
const RESUME_MAX_BYTES = 10 * 1024 * 1024;
|
||||
|
||||
const NOTE_PROMPTS = [
|
||||
"做过类似项目…",
|
||||
"每周可投入…",
|
||||
@ -49,6 +62,8 @@ function ApplicationForm({ gig }: { gig: SocialGig }) {
|
||||
name: "",
|
||||
contact: "",
|
||||
note: "",
|
||||
resumeUrl: "",
|
||||
resumeName: "",
|
||||
});
|
||||
const [delivery, setDelivery] = useLocalState(
|
||||
`gig-delivery:${gig.id}`,
|
||||
@ -56,21 +71,64 @@ function ApplicationForm({ gig }: { gig: SocialGig }) {
|
||||
);
|
||||
const [status, setStatus] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [uploading, setUploading] = useState(false);
|
||||
const lock = useRef(false);
|
||||
const fileRef = useRef<HTMLInputElement>(null);
|
||||
const filled =
|
||||
Number(Boolean(draft.name.trim())) +
|
||||
Number(Boolean(draft.contact.trim())) +
|
||||
Number(Boolean(draft.note.trim()));
|
||||
Number(Boolean(draft.note.trim())) +
|
||||
Number(Boolean((draft.resumeUrl || "").trim()));
|
||||
const update = (key: keyof typeof draft, value: string) => {
|
||||
setDraft((current) => ({ ...current, [key]: value }));
|
||||
setDelivery("draft");
|
||||
setStatus("");
|
||||
};
|
||||
const clearResume = () => {
|
||||
setDraft((current) => ({
|
||||
...current,
|
||||
resumeUrl: "",
|
||||
resumeName: "",
|
||||
}));
|
||||
setDelivery("draft");
|
||||
if (fileRef.current) fileRef.current.value = "";
|
||||
};
|
||||
const onPickResume = async (file: File | null) => {
|
||||
if (!file || uploading || busy) return;
|
||||
if (file.size > RESUME_MAX_BYTES) {
|
||||
setStatus(socialTx("简历请小于 10MB"));
|
||||
return;
|
||||
}
|
||||
setUploading(true);
|
||||
setStatus("");
|
||||
try {
|
||||
const uploaded = await socialApi.uploadResume(file);
|
||||
if (!uploaded?.url) throw new Error("no url");
|
||||
setDraft((current) => ({
|
||||
...current,
|
||||
resumeUrl: uploaded.url,
|
||||
resumeName: (uploaded.name || file.name).slice(0, 200),
|
||||
}));
|
||||
setDelivery("draft");
|
||||
setStatus(socialTx("简历已上传,可以提交申请了"));
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : "";
|
||||
setStatus(
|
||||
msg && !/^upload failed|^上传失败/i.test(msg)
|
||||
? msg
|
||||
: socialTx("简历上传失败,请重试"),
|
||||
);
|
||||
} finally {
|
||||
setUploading(false);
|
||||
if (fileRef.current) fileRef.current.value = "";
|
||||
}
|
||||
};
|
||||
const submit = async (event: FormEvent) => {
|
||||
event.preventDefault();
|
||||
if (
|
||||
lock.current ||
|
||||
delivery === "sent" ||
|
||||
uploading ||
|
||||
!draft.name.trim() ||
|
||||
!draft.contact.trim()
|
||||
)
|
||||
@ -82,6 +140,8 @@ function ApplicationForm({ gig }: { gig: SocialGig }) {
|
||||
name: draft.name.trim(),
|
||||
contact: draft.contact.trim(),
|
||||
note: draft.note.trim(),
|
||||
resumeUrl: (draft.resumeUrl || "").trim(),
|
||||
resumeName: (draft.resumeName || "").trim(),
|
||||
});
|
||||
setDelivery("sent");
|
||||
setStatus("申请已提交。对方看到后会再联系你——先不急。");
|
||||
@ -105,6 +165,11 @@ function ApplicationForm({ gig }: { gig: SocialGig }) {
|
||||
<div className="social-apply-summary">
|
||||
<em>{socialTx(gig.title)}</em>
|
||||
<span>{socialTx(TEAM_KIND_LABEL[gig.kind || "parttime"])}</span>
|
||||
{draft.resumeName ? (
|
||||
<span className="social-apply-resume-tag">
|
||||
<Paperclip size={12} /> {draft.resumeName}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="social-actions">
|
||||
<Link className="social-btn primary" href={socialPath("/chat")}>
|
||||
@ -148,17 +213,17 @@ function ApplicationForm({ gig }: { gig: SocialGig }) {
|
||||
|
||||
<div
|
||||
className="social-apply-progress"
|
||||
aria-label={`${socialTx("已填")} ${filled} / 3`}
|
||||
aria-label={`${socialTx("已填")} ${filled} / 4`}
|
||||
>
|
||||
<span className="social-apply-progress-track">
|
||||
<i style={{ width: `${(filled / 3) * 100}%` }} />
|
||||
<i style={{ width: `${(filled / 4) * 100}%` }} />
|
||||
</span>
|
||||
<small>
|
||||
{filled === 0
|
||||
? socialTx("先简单介绍自己")
|
||||
: filled < 3
|
||||
? socialTx(`还差 ${3 - filled} 项(简介可选)`)
|
||||
: socialTx("可以提交了")}
|
||||
: filled < 2
|
||||
? socialTx("还差称呼和联系方式")
|
||||
: socialTx("可以提交了(简历可选)")}
|
||||
</small>
|
||||
</div>
|
||||
|
||||
@ -166,7 +231,7 @@ function ApplicationForm({ gig }: { gig: SocialGig }) {
|
||||
className="social-form social-apply-form"
|
||||
onSubmit={(e) => void submit(e)}
|
||||
>
|
||||
<fieldset disabled={busy} className="social-fieldset">
|
||||
<fieldset disabled={busy || uploading} className="social-fieldset">
|
||||
<label>
|
||||
{socialTx("怎么称呼你")}
|
||||
<input
|
||||
@ -221,12 +286,68 @@ function ApplicationForm({ gig }: { gig: SocialGig }) {
|
||||
{draft.note.length}/2000 · 多写一点,对方更容易回你
|
||||
</small>
|
||||
</label>
|
||||
|
||||
<div className="social-apply-resume">
|
||||
<span className="social-apply-resume-label">
|
||||
<Paperclip size={14} />
|
||||
{socialTx("上传简历(可选)")}
|
||||
</span>
|
||||
<p className="social-muted">
|
||||
{socialTx("支持 PDF / Word / 图片,最大 10MB")}
|
||||
</p>
|
||||
<input
|
||||
ref={fileRef}
|
||||
type="file"
|
||||
accept={RESUME_ACCEPT}
|
||||
className="social-apply-resume-input"
|
||||
onChange={(event) =>
|
||||
void onPickResume(event.target.files?.[0] || null)
|
||||
}
|
||||
/>
|
||||
{draft.resumeUrl ? (
|
||||
<div className="social-apply-resume-file">
|
||||
<a
|
||||
href={draft.resumeUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<FileUp size={14} />
|
||||
{draft.resumeName || socialTx("已上传简历")}
|
||||
</a>
|
||||
<button
|
||||
type="button"
|
||||
className="social-btn"
|
||||
onClick={clearResume}
|
||||
aria-label={socialTx("移除简历")}
|
||||
>
|
||||
<X size={14} />
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
className="social-btn"
|
||||
disabled={uploading}
|
||||
onClick={() => fileRef.current?.click()}
|
||||
>
|
||||
<FileUp size={14} />
|
||||
{uploading
|
||||
? socialTx("上传中…")
|
||||
: socialTx("选择简历文件")}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</fieldset>
|
||||
<div className="social-actions">
|
||||
<button
|
||||
type="submit"
|
||||
className="social-btn primary"
|
||||
disabled={busy || !draft.name.trim() || !draft.contact.trim()}
|
||||
disabled={
|
||||
busy ||
|
||||
uploading ||
|
||||
!draft.name.trim() ||
|
||||
!draft.contact.trim()
|
||||
}
|
||||
>
|
||||
<Send size={14} />
|
||||
{busy
|
||||
@ -270,6 +391,25 @@ export default function RoleBoard({
|
||||
const [savedOnly, setSavedOnly] = useState(false);
|
||||
const [saved] = useLocalState<string[]>("saved-roles", []);
|
||||
const [active, setActive] = useState<SocialGig | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const openFromHash = () => {
|
||||
const id = (typeof location !== "undefined" ? location.hash : "").slice(1);
|
||||
if (!id) return;
|
||||
const gig = catalog.gigs.find((g) => g.id === id);
|
||||
if (gig) {
|
||||
setActive(gig);
|
||||
document.getElementById(`gig-${gig.id}`)?.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "center",
|
||||
});
|
||||
}
|
||||
};
|
||||
openFromHash();
|
||||
window.addEventListener("hashchange", openFromHash);
|
||||
return () => window.removeEventListener("hashchange", openFromHash);
|
||||
}, [catalog.gigs]);
|
||||
|
||||
const roles = catalog.gigs.filter(
|
||||
(gig) =>
|
||||
(kind === "all" || gig.kind === kind) &&
|
||||
@ -374,6 +514,7 @@ export default function RoleBoard({
|
||||
return (
|
||||
<article
|
||||
key={gig.id}
|
||||
id={`gig-${gig.id}`}
|
||||
className={`social-hire-row tone-${tone} reveal`}
|
||||
style={{ ["--stagger" as string]: `${index * 45}ms` }}
|
||||
>
|
||||
|
||||
@ -689,9 +689,30 @@ export const socialApi = {
|
||||
throw new Error(lastErr || "join lead failed");
|
||||
},
|
||||
|
||||
/** Resume / CV → SeaweedFS (purpose=resume); PDF / Word / image. */
|
||||
uploadResume: async (file: File) => {
|
||||
const uploaded = await socialApi.uploadAvatar(file, "resume");
|
||||
return {
|
||||
...uploaded,
|
||||
name: file.name.slice(0, 200),
|
||||
} as {
|
||||
ok: boolean;
|
||||
url: string;
|
||||
object_key: string;
|
||||
storage?: string;
|
||||
name: string;
|
||||
};
|
||||
},
|
||||
|
||||
applyGig: (
|
||||
gigId: string,
|
||||
payload: { name: string; contact: string; note?: string },
|
||||
payload: {
|
||||
name: string;
|
||||
contact: string;
|
||||
note?: string;
|
||||
resumeUrl?: string;
|
||||
resumeName?: string;
|
||||
},
|
||||
) =>
|
||||
req(`/gigs/${encodeURIComponent(gigId)}/apply`, {
|
||||
method: "POST",
|
||||
|
||||
@ -312,6 +312,17 @@ export const SOCIAL_PHRASES_EN: Record<string, string> = {
|
||||
"或者看看共创内容找灵感": "Or browse co-create for ideas",
|
||||
"对方看到后会再联系你": "They will follow up after seeing it",
|
||||
"草稿会先留在你这边": "Draft stays on this device first",
|
||||
"上传简历(可选)": "Upload resume (optional)",
|
||||
"支持 PDF / Word / 图片,最大 10MB": "PDF / Word / image, max 10MB",
|
||||
"选择简历文件": "Choose resume file",
|
||||
"已上传简历": "Resume uploaded",
|
||||
"移除简历": "Remove resume",
|
||||
"简历请小于 10MB": "Resume must be under 10MB",
|
||||
"简历上传失败,请重试": "Resume upload failed — please retry",
|
||||
"简历已上传,可以提交申请了": "Resume uploaded — you can submit now",
|
||||
"可以提交了(简历可选)": "Ready to submit (resume optional)",
|
||||
"还差称呼和联系方式": "Name and contact still needed",
|
||||
"上传中…": "Uploading…",
|
||||
"可以再改一版后提交": "Edit another draft, then submit",
|
||||
"不代表已经被录用": "Does not mean you are hired",
|
||||
"申请已先留在本机": "Application saved on this device",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user