Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into feat/allow-multiple-ad…
Browse files Browse the repository at this point in the history
…mins
  • Loading branch information
simon-hng committed Apr 21, 2024
2 parents 34fdb72 + 521387e commit 40ae775
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/application/applicationField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const ApplicationValue = ({ field }: ApplicationFieldProps) => {
</div>
);

case "DROPDOWN":
case "DROPDOWN" || "MULTIPLE_CHOICE":
const value = field.options?.find((opt) => opt.id === field.value?.at(0));
if (value) {
return (
Expand Down Expand Up @@ -95,6 +95,9 @@ const ApplicationValue = ({ field }: ApplicationFieldProps) => {
case "INPUT_TEXT":
return <Input readOnly value={field.value} />;

case "INPUT_NUMBER":
return <Input readOnly value={field.value} />;

case "INPUT_DATE":
return <Input readOnly value={format(new Date(field.value), "PPP")} />;

Expand Down
8 changes: 8 additions & 0 deletions lib/schemas/tally.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ const TallyCheckboxes = z.object({
options: z.array(z.object({ id: z.string(), text: z.string() })).optional(),
});

const TallyMultipleChoice = z.object({
type: z.literal("MULTIPLE_CHOICE"),
value: z.union([z.boolean(), z.string().uuid()]),
options: z.array(z.object({ id: z.string(), text: z.string() })).optional(),
});

const TallyFileUpload = z.object({
type: z.literal("FILE_UPLOAD"),
value: z
Expand Down Expand Up @@ -35,12 +41,14 @@ export const TallyField = z
.and(
z.union([
TallyCheckboxes,
TallyMultipleChoice,
TallyFileUpload,
TallyDropdown,
z.object({
type: z
.literal("TEXTAREA")
.or(z.literal("INPUT_TEXT"))
.or(z.literal("INPUT_NUMBER"))
.or(z.literal("INPUT_DATE"))
.or(z.literal("INPUT_EMAIL"))
.or(z.literal("TEXTAREA"))
Expand Down

0 comments on commit 40ae775

Please sign in to comment.