feat(board): replace profile board section with posts list
This commit is contained in:
parent
5bdc3244bd
commit
61d33f5db3
1 changed files with 169 additions and 97 deletions
|
|
@ -165,73 +165,48 @@
|
||||||
<div class="section-label">Board</div>
|
<div class="section-label">Board</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>Topics</label>
|
<label>Slack Handle</label>
|
||||||
<CooperativeTagSelector
|
<input
|
||||||
v-model="formData.boardTopics"
|
v-model="formData.boardSlackHandle"
|
||||||
:tags="cooperativeTags"
|
type="text"
|
||||||
@suggest="openTagSuggest('cooperative')"
|
placeholder="@yourslackname"
|
||||||
/>
|
/>
|
||||||
<PrivacyToggle v-model="formData.boardPrivacy" />
|
<div class="field-help">
|
||||||
</div>
|
Shown on your board posts so other members can reach out.
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<label>Details</label>
|
|
||||||
<textarea
|
|
||||||
v-model="formData.boardDetails"
|
|
||||||
rows="3"
|
|
||||||
placeholder="What are you hoping to connect about?"
|
|
||||||
maxlength="300"
|
|
||||||
></textarea>
|
|
||||||
<div class="char-count">
|
|
||||||
{{ formData.boardDetails?.length || 0 }} / 300
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="toggle-field">
|
<div class="posts-header">
|
||||||
<USwitch
|
<div class="posts-heading">Your Posts</div>
|
||||||
v-model="formData.boardOfferPeerSupport"
|
<NuxtLink to="/board" class="posts-new-link">+ New Post</NuxtLink>
|
||||||
aria-label="Offer Peer Support"
|
|
||||||
/>
|
|
||||||
<div class="toggle-label">
|
|
||||||
Offer Peer Support
|
|
||||||
<span class="toggle-sub"
|
|
||||||
>Share your Slack handle so other members can reach out</span
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="formData.boardOfferPeerSupport" class="connections-panel">
|
<div v-if="myPosts.length === 0" class="posts-empty">
|
||||||
<div class="field">
|
No posts yet.
|
||||||
<label>Availability</label>
|
<NuxtLink to="/board" class="posts-empty-link">
|
||||||
<textarea
|
Visit the Board
|
||||||
v-model="formData.boardAvailability"
|
</NuxtLink>
|
||||||
rows="3"
|
to share what you're seeking or offering.
|
||||||
placeholder="e.g. Weekday afternoons ET"
|
</div>
|
||||||
></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="field">
|
<ul v-else class="posts-list">
|
||||||
<label>Slack Handle</label>
|
<li v-for="post in myPosts" :key="post._id" class="post-item">
|
||||||
<input
|
<div class="post-body">
|
||||||
v-model="formData.boardSlackHandle"
|
<div class="post-title">{{ post.title }}</div>
|
||||||
type="text"
|
<div class="post-excerpt">{{ postExcerpt(post) }}</div>
|
||||||
placeholder="@yourslackname"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<label>Personal Message</label>
|
|
||||||
<textarea
|
|
||||||
v-model="formData.boardPersonalMessage"
|
|
||||||
rows="3"
|
|
||||||
maxlength="200"
|
|
||||||
placeholder="Brief note shown alongside your Slack handle"
|
|
||||||
></textarea>
|
|
||||||
<div class="char-count">
|
|
||||||
{{ formData.boardPersonalMessage?.length || 0 }} / 200
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="post-actions">
|
||||||
</div>
|
<NuxtLink to="/board" class="post-action">Edit</NuxtLink>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="post-action post-action-danger"
|
||||||
|
@click="handleDeletePost(post)"
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</PageSection>
|
</PageSection>
|
||||||
|
|
||||||
<PageSection divider="top">
|
<PageSection divider="top">
|
||||||
|
|
@ -296,6 +271,8 @@ definePageMeta({
|
||||||
|
|
||||||
const { memberData, checkMemberStatus } = useAuth();
|
const { memberData, checkMemberStatus } = useAuth();
|
||||||
const { openLoginModal } = useLoginModal();
|
const { openLoginModal } = useLoginModal();
|
||||||
|
const { posts: myPosts, fetchPosts, deletePost } = useBoardPosts();
|
||||||
|
const toast = useToast();
|
||||||
|
|
||||||
const availableGhosts = [
|
const availableGhosts = [
|
||||||
{ value: "disbelieving", label: "Disbelieving", image: "/ghosties/Ghost-Disbelieving.png" },
|
{ value: "disbelieving", label: "Disbelieving", image: "/ghosties/Ghost-Disbelieving.png" },
|
||||||
|
|
@ -316,9 +293,6 @@ const { data: tagsData } = await useFetch("/api/tags");
|
||||||
const craftTags = computed(() =>
|
const craftTags = computed(() =>
|
||||||
(tagsData.value?.tags || []).filter((t) => t.pool === "craft"),
|
(tagsData.value?.tags || []).filter((t) => t.pool === "craft"),
|
||||||
);
|
);
|
||||||
const cooperativeTags = computed(() =>
|
|
||||||
(tagsData.value?.tags || []).filter((t) => t.pool === "cooperative"),
|
|
||||||
);
|
|
||||||
|
|
||||||
const showTagSuggestModal = ref(false);
|
const showTagSuggestModal = ref(false);
|
||||||
const tagSuggestPool = ref("");
|
const tagSuggestPool = ref("");
|
||||||
|
|
@ -339,13 +313,7 @@ const formData = reactive({
|
||||||
showInDirectory: true,
|
showInDirectory: true,
|
||||||
craftTags: [],
|
craftTags: [],
|
||||||
craftTagsPrivacy: "members",
|
craftTagsPrivacy: "members",
|
||||||
boardTopics: [],
|
|
||||||
boardPrivacy: "members",
|
|
||||||
boardDetails: "",
|
|
||||||
boardOfferPeerSupport: false,
|
|
||||||
boardAvailability: "",
|
|
||||||
boardSlackHandle: "",
|
boardSlackHandle: "",
|
||||||
boardPersonalMessage: "",
|
|
||||||
pronounsPrivacy: "members",
|
pronounsPrivacy: "members",
|
||||||
timeZonePrivacy: "members",
|
timeZonePrivacy: "members",
|
||||||
avatarPrivacy: "members",
|
avatarPrivacy: "members",
|
||||||
|
|
@ -388,12 +356,7 @@ const loadProfile = () => {
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
const board = memberData.value.board || {};
|
const board = memberData.value.board || {};
|
||||||
formData.boardTopics = Array.isArray(board.topics) ? [...board.topics] : [];
|
|
||||||
formData.boardOfferPeerSupport = board.offerPeerSupport ?? false;
|
|
||||||
formData.boardAvailability = board.availability || "";
|
|
||||||
formData.boardSlackHandle = board.slackHandle || "";
|
formData.boardSlackHandle = board.slackHandle || "";
|
||||||
formData.boardPersonalMessage = board.personalMessage || "";
|
|
||||||
formData.boardDetails = board.details || "";
|
|
||||||
|
|
||||||
const privacy = memberData.value.privacy || {};
|
const privacy = memberData.value.privacy || {};
|
||||||
formData.pronounsPrivacy = privacy.pronouns || "members";
|
formData.pronounsPrivacy = privacy.pronouns || "members";
|
||||||
|
|
@ -403,7 +366,6 @@ const loadProfile = () => {
|
||||||
formData.bioPrivacy = privacy.bio || "members";
|
formData.bioPrivacy = privacy.bio || "members";
|
||||||
formData.locationPrivacy = privacy.location || "members";
|
formData.locationPrivacy = privacy.location || "members";
|
||||||
formData.craftTagsPrivacy = privacy.craftTags || "members";
|
formData.craftTagsPrivacy = privacy.craftTags || "members";
|
||||||
formData.boardPrivacy = privacy.board || "members";
|
|
||||||
|
|
||||||
const notifs = memberData.value.notifications || {};
|
const notifs = memberData.value.notifications || {};
|
||||||
formData.notifications.events = notifs.events ?? true;
|
formData.notifications.events = notifs.events ?? true;
|
||||||
|
|
@ -418,23 +380,10 @@ const handleSubmit = async () => {
|
||||||
saveError.value = null;
|
saveError.value = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Promise.all([
|
await $fetch("/api/members/profile", {
|
||||||
$fetch("/api/members/profile", {
|
method: "PATCH",
|
||||||
method: "PATCH",
|
body: { ...formData },
|
||||||
body: { ...formData },
|
});
|
||||||
}),
|
|
||||||
$fetch("/api/members/me/board", {
|
|
||||||
method: "PATCH",
|
|
||||||
body: {
|
|
||||||
topics: formData.boardTopics,
|
|
||||||
offerPeerSupport: formData.boardOfferPeerSupport,
|
|
||||||
availability: formData.boardAvailability,
|
|
||||||
slackHandle: formData.boardSlackHandle,
|
|
||||||
personalMessage: formData.boardPersonalMessage,
|
|
||||||
details: formData.boardDetails,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
|
|
||||||
saveSuccess.value = true;
|
saveSuccess.value = true;
|
||||||
|
|
||||||
|
|
@ -477,8 +426,33 @@ onMounted(async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadProfile();
|
loadProfile();
|
||||||
|
|
||||||
|
if (memberId.value) {
|
||||||
|
await fetchPosts({ author: memberId.value });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const postExcerpt = (post) => {
|
||||||
|
const text = post.seeking || post.offering || "";
|
||||||
|
if (text.length <= 80) return text;
|
||||||
|
return text.slice(0, 80).trimEnd() + "...";
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeletePost = async (post) => {
|
||||||
|
if (!window.confirm(`Delete "${post.title}"?`)) return;
|
||||||
|
try {
|
||||||
|
await deletePost(post._id);
|
||||||
|
await fetchPosts({ author: memberId.value });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Delete post error:", error);
|
||||||
|
toast.add({
|
||||||
|
title: "Failed to delete post",
|
||||||
|
description: error.data?.message || "Please try again.",
|
||||||
|
color: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
if (saveSuccessTimer) clearTimeout(saveSuccessTimer);
|
if (saveSuccessTimer) clearTimeout(saveSuccessTimer);
|
||||||
});
|
});
|
||||||
|
|
@ -612,13 +586,111 @@ useHead({
|
||||||
margin-top: 1px;
|
margin-top: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---- CONNECTIONS PANEL ---- */
|
/* ---- FIELD HELPER TEXT ---- */
|
||||||
.connections-panel {
|
.field-help {
|
||||||
border: 1px dashed var(--border);
|
font-size: 11px;
|
||||||
padding: 12px 16px;
|
color: var(--text-faint);
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
margin-bottom: 12px;
|
}
|
||||||
background: var(--surface);
|
|
||||||
|
/* ---- YOUR POSTS LIST ---- */
|
||||||
|
.posts-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-top: 20px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.posts-heading {
|
||||||
|
font-size: 11px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
color: var(--text-dim);
|
||||||
|
}
|
||||||
|
|
||||||
|
.posts-new-link {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--candle);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.posts-new-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.posts-empty {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-faint);
|
||||||
|
padding: 12px 0;
|
||||||
|
border-top: 1px dashed var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.posts-empty-link {
|
||||||
|
color: var(--candle);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.posts-empty-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.posts-list {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border-top: 1px dashed var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 10px 0;
|
||||||
|
border-bottom: 1px dashed var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-body {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-title {
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text);
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-excerpt {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text-faint);
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-action {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--candle);
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
padding: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: none;
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-action:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-action-danger {
|
||||||
|
color: var(--ember);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---- DISABLED BUTTON ---- */
|
/* ---- DISABLED BUTTON ---- */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue