Add owner chip for unpaid submissions
This commit is contained in:
@@ -130,7 +130,7 @@ def row_to_my_order(row: sqlite3.Row) -> dict:
|
|||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
submission_choices = {}
|
submission_choices = {}
|
||||||
|
|
||||||
return {
|
result = {
|
||||||
"id": row["id"],
|
"id": row["id"],
|
||||||
"title": row["title"],
|
"title": row["title"],
|
||||||
"description": row["description"],
|
"description": row["description"],
|
||||||
@@ -145,3 +145,8 @@ def row_to_my_order(row: sqlite3.Row) -> dict:
|
|||||||
"paid": bool(row["paid"]) if row["paid"] is not None else False,
|
"paid": bool(row["paid"]) if row["paid"] is not None else False,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if "has_unpaid_submissions" in row.keys() and row["has_unpaid_submissions"] is not None:
|
||||||
|
result["has_unpaid_submissions"] = bool(row["has_unpaid_submissions"])
|
||||||
|
|
||||||
|
return result
|
||||||
|
|||||||
@@ -674,7 +674,12 @@ def get_my_orders(
|
|||||||
uot.submission_token,
|
uot.submission_token,
|
||||||
s.choices_json,
|
s.choices_json,
|
||||||
s.accepted,
|
s.accepted,
|
||||||
s.paid
|
s.paid,
|
||||||
|
CASE
|
||||||
|
WHEN uot.admin_token IS NOT NULL THEN
|
||||||
|
(SELECT COUNT(*) FROM submissions s2 WHERE s2.group_order_id = go.id AND s2.accepted = 1 AND (s2.paid IS NULL OR s2.paid = 0))
|
||||||
|
ELSE 0
|
||||||
|
END AS has_unpaid_submissions
|
||||||
FROM user_order_tokens uot
|
FROM user_order_tokens uot
|
||||||
JOIN group_orders go ON go.id = uot.group_order_id
|
JOIN group_orders go ON go.id = uot.group_order_id
|
||||||
LEFT JOIN submissions s ON s.submission_token = uot.submission_token
|
LEFT JOIN submissions s ON s.submission_token = uot.submission_token
|
||||||
|
|||||||
@@ -104,6 +104,9 @@ export default function HomeOrdersTable({
|
|||||||
<Space size={8} align="center">
|
<Space size={8} align="center">
|
||||||
<Text strong>{item.title || item.id}</Text>
|
<Text strong>{item.title || item.id}</Text>
|
||||||
{item.is_owner ? <Tag color="geekblue">Owner</Tag> : null}
|
{item.is_owner ? <Tag color="geekblue">Owner</Tag> : null}
|
||||||
|
{item.is_owner && item.has_unpaid_submissions ? (
|
||||||
|
<Tag color="volcano">Open payments</Tag>
|
||||||
|
) : null}
|
||||||
{state === "paid" ? <Tag color="green">Paid</Tag> : null}
|
{state === "paid" ? <Tag color="green">Paid</Tag> : null}
|
||||||
{state === "unpaid" ? (
|
{state === "unpaid" ? (
|
||||||
<Tag color="volcano">Unpaid</Tag>
|
<Tag color="volcano">Unpaid</Tag>
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ export type Order = OrderBase & {
|
|||||||
is_owner: boolean;
|
is_owner: boolean;
|
||||||
is_participant: boolean;
|
is_participant: boolean;
|
||||||
};
|
};
|
||||||
|
has_unpaid_submissions?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type OrderAdminView = OrderBase & {
|
export type OrderAdminView = OrderBase & {
|
||||||
|
|||||||
Reference in New Issue
Block a user