refactor(admin/members): dedupe STATUS_LABELS + reactive row update
Promote inline STATUS_LABELS copies (admin/members/index.vue,
member/account.vue) into app/config/memberStatus.js, matching the
app/config/circles.js pattern. Drive admin/members/[id].vue status
select from the same constant — completes the alignment started in
441a5f5.
Use the softer member-facing copy as canonical: "Paused" / "Closed"
instead of "Suspended" / "Cancelled".
Also fix markSlackInvited's non-reactive Object.assign on a plain
object inside a useFetch array — replace with index-find + element
reassignment so the row UI refreshes without a manual reload.
This commit is contained in:
parent
1c8f30fe6f
commit
6a6f036877
4 changed files with 19 additions and 20 deletions
8
app/config/memberStatus.js
Normal file
8
app/config/memberStatus.js
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
export const STATUS_LABELS = {
|
||||||
|
active: "Active",
|
||||||
|
pending_payment: "Payment setup incomplete",
|
||||||
|
suspended: "Paused",
|
||||||
|
cancelled: "Closed",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const statusLabel = (s) => STATUS_LABELS[s] || "Pending";
|
||||||
|
|
@ -63,10 +63,11 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>Status</label>
|
<label>Status</label>
|
||||||
<select v-model="form.status">
|
<select v-model="form.status">
|
||||||
<option value="pending_payment">pending_payment</option>
|
<option
|
||||||
<option value="active">active</option>
|
v-for="(label, value) in STATUS_LABELS"
|
||||||
<option value="suspended">suspended</option>
|
:key="value"
|
||||||
<option value="cancelled">cancelled</option>
|
:value="value"
|
||||||
|
>{{ label }}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|
@ -242,6 +243,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { formatActivity } from '~/utils/activityText'
|
import { formatActivity } from '~/utils/activityText'
|
||||||
|
import { STATUS_LABELS } from '~/config/memberStatus'
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: "admin",
|
layout: "admin",
|
||||||
|
|
|
||||||
|
|
@ -468,6 +468,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { STATUS_LABELS, statusLabel } from "~/config/memberStatus";
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: "admin",
|
layout: "admin",
|
||||||
middleware: "admin",
|
middleware: "admin",
|
||||||
|
|
@ -488,14 +490,6 @@ const statusFilter = ref("");
|
||||||
const sortKey = ref("createdAt");
|
const sortKey = ref("createdAt");
|
||||||
const sortDir = ref("desc");
|
const sortDir = ref("desc");
|
||||||
|
|
||||||
const STATUS_LABELS = {
|
|
||||||
active: "Active",
|
|
||||||
pending_payment: "Payment setup incomplete",
|
|
||||||
suspended: "Suspended",
|
|
||||||
cancelled: "Cancelled",
|
|
||||||
};
|
|
||||||
const statusLabel = (s) => STATUS_LABELS[s] || "Pending";
|
|
||||||
|
|
||||||
const toggleSort = (key) => {
|
const toggleSort = (key) => {
|
||||||
if (sortKey.value === key) {
|
if (sortKey.value === key) {
|
||||||
sortDir.value = sortDir.value === "asc" ? "desc" : "asc";
|
sortDir.value = sortDir.value === "asc" ? "desc" : "asc";
|
||||||
|
|
@ -845,7 +839,8 @@ const markSlackInvited = async (member) => {
|
||||||
body: { slackInvited: true },
|
body: { slackInvited: true },
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
Object.assign(member, res.member);
|
const idx = members.value.findIndex((m) => m._id === member._id);
|
||||||
|
if (idx !== -1) members.value[idx] = { ...members.value[idx], ...res.member };
|
||||||
toast.add({ title: "Marked as Slack invited", color: "success" });
|
toast.add({ title: "Marked as Slack invited", color: "success" });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast.add({
|
toast.add({
|
||||||
|
|
|
||||||
|
|
@ -315,6 +315,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { CONTRIBUTION_PRESETS, getGuidanceLabel, requiresPayment } from '~/config/contributions';
|
import { CONTRIBUTION_PRESETS, getGuidanceLabel, requiresPayment } from '~/config/contributions';
|
||||||
|
import { STATUS_LABELS } from '~/config/memberStatus';
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
middleware: "auth",
|
middleware: "auth",
|
||||||
|
|
@ -417,13 +418,6 @@ const circleOptions = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const STATUS_LABELS = {
|
|
||||||
active: "Active",
|
|
||||||
pending_payment: "Setting up payment",
|
|
||||||
suspended: "Paused",
|
|
||||||
cancelled: "Closed",
|
|
||||||
};
|
|
||||||
|
|
||||||
const formatStatus = (s) => STATUS_LABELS[s] || s;
|
const formatStatus = (s) => STATUS_LABELS[s] || s;
|
||||||
|
|
||||||
const capitalise = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : s);
|
const capitalise = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : s);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue