Skip to content

Commit 068e82d

Browse files
committed
More
1 parent e84b497 commit 068e82d

File tree

21 files changed

+705
-45
lines changed

21 files changed

+705
-45
lines changed

backend/association_membership/handlers/pretix/api.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from django.conf import settings
66

7+
from conferences.models.conference import Conference
8+
79
METHODS = Literal["get"]
810

911

@@ -15,6 +17,13 @@ def __init__(self, organizer: str, event: str):
1517
f"{settings.PRETIX_API}organizers/{self.organizer}/events/{self.event}"
1618
)
1719

20+
@classmethod
21+
def for_conference(cls, conference: Conference):
22+
return cls(
23+
organizer=conference.pretix_organizer_id,
24+
event=conference.pretix_event_id,
25+
)
26+
1827
def _request(
1928
self, endpoint: str, *, method: METHODS = "get", qs: dict[str, str] = None
2029
):
@@ -40,3 +49,9 @@ def get_items(self, qs: dict[str, str]) -> dict:
4049
def get_categories(self) -> dict:
4150
response = self._request("categories")
4251
return response.json()
52+
53+
def get_all_attendee_tickets(self, attendee_email: str) -> list[dict]:
54+
response = self._request(
55+
"tickets/attendee-tickets", qs={"attendee_email": attendee_email}
56+
)
57+
return response.json()

backend/custom_admin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@radix-ui/react-alert-dialog": "^1.1.4",
2222
"@radix-ui/react-dialog": "^1.1.3",
2323
"@radix-ui/react-tabs": "^1.1.2",
24+
"@radix-ui/react-toast": "^1.2.4",
2425
"@radix-ui/react-toolbar": "^1.1.1",
2526
"@radix-ui/themes": "^3.1.6",
2627
"@tiptap/extension-color": "^2.10.3",

backend/custom_admin/pnpm-lock.yaml

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/custom_admin/src/components/invitation-letter-document-builder/builder.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
import * as AlertDialog from "@radix-ui/react-alert-dialog";
2-
import { Button, Flex, Heading, Text, Theme } from "@radix-ui/themes";
1+
import * as Toast from "@radix-ui/react-toast";
2+
import { Button, Heading, Text } from "@radix-ui/themes";
33
import { Box } from "@radix-ui/themes";
4-
import { MoveDown, MoveUp, Plus, Trash } from "lucide-react";
5-
import { Fragment, useEffect, useState } from "react";
6-
import type { InvitationLetterDocumentStructure } from "../../types";
7-
import { Base } from "../shared/base";
8-
import { DjangoAdminLayout } from "../shared/django-admin-layout";
9-
import { Editor } from "./editor";
4+
import { Plus } from "lucide-react";
5+
import { Fragment } from "react";
6+
107
import { EditorSection } from "./editor-section";
11-
import { useInvitationLetterDocumentQuery } from "./invitation-letter-document.generated";
128
import { useLocalData } from "./local-state";
13-
import { useUpdateInvitationLetterDocumentMutation } from "./update-invitation-letter-document.generated";
149

1510
export const InvitationLetterBuilder = () => {
16-
const { localData, saveChanges, isSaving, addPage } = useLocalData();
11+
const { localData, saveChanges, isSaving, saveFailed, addPage } =
12+
useLocalData();
1713

1814
if (!localData) {
1915
return <Text>Loading...</Text>;

backend/custom_admin/src/components/invitation-letter-document-builder/editor-section.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import * as AlertDialog from "@radix-ui/react-alert-dialog";
22
import { Button, Flex, Heading, Text, Theme } from "@radix-ui/themes";
33
import { Box } from "@radix-ui/themes";
4-
import { MoveDown, MoveUp, Plus, Trash } from "lucide-react";
5-
import { Fragment, useEffect, useState } from "react";
6-
import type { InvitationLetterDocumentStructure } from "../../types";
7-
import { Base } from "../shared/base";
8-
import { DjangoAdminLayout } from "../shared/django-admin-layout";
4+
import { MoveDown, MoveUp, Trash } from "lucide-react";
95
import { Editor } from "./editor";
10-
import { useInvitationLetterDocumentQuery } from "./invitation-letter-document.generated";
116
import { useLocalData } from "./local-state";
12-
import { useUpdateInvitationLetterDocumentMutation } from "./update-invitation-letter-document.generated";
137

148
export const EditorSection = ({
159
title,
@@ -26,7 +20,7 @@ export const EditorSection = ({
2620
const onMoveUp = () => movePageUp(pageId);
2721
const onMoveDown = () => movePageDown(pageId);
2822
const onRemove = () => removePage(pageId);
29-
const onUpdate = () => setContent(pageId, content);
23+
const onUpdate = (content: string) => setContent(pageId, content);
3024

3125
return (
3226
<AlertDialog.Root>

backend/custom_admin/src/components/invitation-letter-document-builder/local-state.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const LocalStateContext = createContext<{
88
localData: any;
99
saveChanges: () => void;
1010
isSaving: boolean;
11+
saveFailed: boolean;
1112
addPage: () => void;
1213
setContent: (pageId: string, content: string) => void;
1314
removePage: (pageId: string) => void;
@@ -17,6 +18,7 @@ export const LocalStateContext = createContext<{
1718
localData: null,
1819
saveChanges: () => {},
1920
isSaving: false,
21+
saveFailed: false,
2022
addPage: () => {},
2123
setContent: () => {},
2224
removePage: () => {},
@@ -137,8 +139,8 @@ const useLoadRemoteData = () => {
137139
return remoteData?.invitationLetterDocument?.dynamicDocument;
138140
};
139141

140-
const useSaveRemoteData = (): [(newData) => void, boolean] => {
141-
const [updateInvitationLetter, { loading: savingChanges }] =
142+
const useSaveRemoteData = (): [(newData) => void, boolean, boolean] => {
143+
const [updateInvitationLetter, { loading: savingChanges, error }] =
142144
useUpdateInvitationLetterDocumentMutation();
143145

144146
return [
@@ -153,13 +155,14 @@ const useSaveRemoteData = (): [(newData) => void, boolean] => {
153155
});
154156
},
155157
savingChanges,
158+
!!error,
156159
];
157160
};
158161

159162
export const LocalStateProvider = ({ children }) => {
160163
const [localData, dispatch] = useReducer(reducer, null);
161164
const remoteData = useLoadRemoteData();
162-
const [saveChanges, isSaving] = useSaveRemoteData();
165+
const [saveChanges, isSaving, saveFailed] = useSaveRemoteData();
163166

164167
useEffect(() => {
165168
if (!remoteData) {
@@ -177,6 +180,7 @@ export const LocalStateProvider = ({ children }) => {
177180
saveChanges(localData);
178181
},
179182
isSaving,
183+
saveFailed,
180184
addPage: () => {
181185
dispatch({ type: ActionType.AddPage });
182186
},

backend/custom_admin/src/components/invitation-letter-document-builder/menu-bar.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
AlignLeft,
77
AlignRight,
88
Bold,
9+
Braces,
910
Italic,
1011
} from "lucide-react";
1112

@@ -69,6 +70,15 @@ export const MenuBar = ({ editor }) => {
6970
</Toolbar.Button>
7071

7172
<Toolbar.Separator className="w-px bg-gray-300 mx-1" />
73+
74+
<Toolbar.Button
75+
onClick={() => editor.chain().focus().setTextAlign("justify").run()}
76+
className={clsx("p-2 rounded hover:bg-gray-200", {
77+
"bg-gray-200": editor.isActive({ textAlign: "justify" }),
78+
})}
79+
>
80+
<Braces size={16} />
81+
</Toolbar.Button>
7282
</Toolbar.Root>
7383
);
7484
};

backend/custom_admin/src/components/invitation-letter-document-builder/root.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import { Heading, Text } from "@radix-ui/themes";
2-
import { Box } from "@radix-ui/themes";
3-
import { Fragment, useEffect, useState } from "react";
41
import { Base } from "../shared/base";
52
import { DjangoAdminLayout } from "../shared/django-admin-layout";
63
import { InvitationLetterBuilder } from "./builder";
7-
import { Editor } from "./editor";
8-
import { useInvitationLetterDocumentQuery } from "./invitation-letter-document.generated";
94
import { LocalStateProvider } from "./local-state";
105

116
export const InvitationLetterDocumentBuilderRoot = () => {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Node } from "@tiptap/core";
2+
3+
const VariableNode = Node.create({
4+
name: "variable-node",
5+
6+
// Your code goes here.
7+
});

backend/custom_admin/src/components/shared/base.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { DndProvider } from "react-dnd";
44
import { HTML5Backend } from "react-dnd-html5-backend";
55

66
import "../shared/styles.css";
7+
import * as Toast from "@radix-ui/react-toast";
78
import { DjangoAdminEditorProvider } from "./django-admin-editor-modal";
89

910
type Props = {

0 commit comments

Comments
 (0)