Skip to content

Commit

Permalink
feat(web): port field preview template (#942)
Browse files Browse the repository at this point in the history
  • Loading branch information
leeyeh authored Oct 24, 2023
1 parent 1286a95 commit 01dced6
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 18 deletions.
142 changes: 136 additions & 6 deletions next/web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions next/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"antd": "^4.24.8",
"axios": "^0.24.0",
"classnames": "^2.3.1",
"dompurify": "^3.0.6",
"github-markdown-css": "^5.1.0",
"handlebars": "^4.7.8",
"highlight.js": "^11.6.0",
"immer": "^9.0.12",
"lodash-es": "^4.17.21",
Expand All @@ -48,6 +50,7 @@
},
"devDependencies": {
"@hookform/devtools": "^4.0.2",
"@types/dompurify": "^3.0.4",
"@types/lodash-es": "^4.17.5",
"@types/react": "^17.0.38",
"@types/react-beautiful-dnd": "^13.1.2",
Expand Down
12 changes: 10 additions & 2 deletions next/web/src/App/Admin/Tickets/Ticket/TicketDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ export function TicketDetail() {
disabled={updating}
/>

<CustomFieldsSection ticketId={ticket.id} categoryId={ticket.categoryId} />
<CustomFieldsSection
ticketId={ticket.id}
categoryId={ticket.categoryId}
author={ticket.author}
/>

<MetadataSection metadata={ticket.metaData} />
</Col>
Expand Down Expand Up @@ -314,15 +318,17 @@ function transformField(field: TicketField_v1) {
type: field.type,
label: field.variants[0]?.title || 'unknown',
options: field.variants[0]?.options?.map(([value, label]) => ({ label, value })),
previewTemplate: field.preview_template,
};
}

interface CustomFieldsSectionProps {
ticketId: string;
categoryId: string;
author?: UserSchema;
}

function CustomFieldsSection({ ticketId, categoryId }: CustomFieldsSectionProps) {
function CustomFieldsSection({ ticketId, categoryId, author }: CustomFieldsSectionProps) {
const { data: formFieldIds, isLoading: loadingFormFieldIds } = useFormFieldIds(categoryId);

const { data: fieldValues, isLoading: loadingFieldValues } = useTicketFieldValues(ticketId);
Expand Down Expand Up @@ -382,6 +388,7 @@ function CustomFieldsSection({ ticketId, categoryId }: CustomFieldsSectionProps)
values={fieldValueMap}
updating={updating}
onChange={handleUpdate}
user={author}
/>
</>
)}
Expand All @@ -393,6 +400,7 @@ function CustomFieldsSection({ ticketId, categoryId }: CustomFieldsSectionProps)
values={fieldValueMap}
updating={updating}
onChange={handleUpdate}
user={author}
/>
</>
)}
Expand Down
1 change: 1 addition & 0 deletions next/web/src/App/Admin/Tickets/Ticket/api1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface TicketField_v1 {
title: string;
options?: [string, string][];
}[];
preview_template?: string;
}

export function useTicketFields_v1(
Expand Down
Loading

0 comments on commit 01dced6

Please sign in to comment.