Skip to content

Commit

Permalink
Update overriding of s3 function's formUrl (used by File component) t…
Browse files Browse the repository at this point in the history
…o use function exported by @formio/js instead of old formiojs package
  • Loading branch information
courtneymyers committed Dec 10, 2024
1 parent de60d60 commit 6dde3ac
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 49 deletions.
8 changes: 2 additions & 6 deletions app/client/src/routes/crf2022.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useEffect, useMemo, useRef } from "react";
import { useNavigate, useOutletContext, useParams } from "react-router-dom";
import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
import { Dialog } from "@headlessui/react";
import { Providers } from "@formio/js";
import { Formio, Form } from "@formio/react";
import s3 from "formiojs/providers/storage/s3";
import clsx from "clsx";
import { cloneDeep, isEqual } from "lodash";
import icons from "uswds/img/sprite.svg";
Expand Down Expand Up @@ -54,18 +54,14 @@ function useFormioSubmissionQueryAndMutation(rebateId: string | undefined) {
/**
* Change the formUrl the File component's `uploadFile` uses, so the s3
* upload PUT request is routed through the server app.
*
* https://github.com/formio/formio.js/blob/master/src/components/file/File.js#L760
* https://github.com/formio/formio.js/blob/master/src/providers/storage/s3.js#L5
* https://github.com/formio/formio.js/blob/master/src/providers/storage/xhr.js#L90
*/
Formio.Providers.providers.storage.s3 = function (formio: {
formUrl: string;
[field: string]: unknown;
}) {
const s3Formio = cloneDeep(formio);
s3Formio.formUrl = `${serverUrl}/api/formio/2022/s3/crf/${mongoId}/${comboKey}`;
return s3(s3Formio);
return Providers.providers.storage.s3(s3Formio);
};

return Promise.resolve(res);
Expand Down
8 changes: 2 additions & 6 deletions app/client/src/routes/frf2022.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useEffect, useMemo, useRef } from "react";
import { useNavigate, useOutletContext, useParams } from "react-router-dom";
import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
import { Dialog } from "@headlessui/react";
import { Providers } from "@formio/js";
import { Formio, Form } from "@formio/react";
import s3 from "formiojs/providers/storage/s3";
import clsx from "clsx";
import { cloneDeep, isEqual } from "lodash";
import icons from "uswds/img/sprite.svg";
Expand Down Expand Up @@ -54,18 +54,14 @@ function useFormioSubmissionQueryAndMutation(mongoId: string | undefined) {
/**
* Change the formUrl the File component's `uploadFile` uses, so the s3
* upload PUT request is routed through the server app.
*
* https://github.com/formio/formio.js/blob/master/src/components/file/File.js#L760
* https://github.com/formio/formio.js/blob/master/src/providers/storage/s3.js#L5
* https://github.com/formio/formio.js/blob/master/src/providers/storage/xhr.js#L90
*/
Formio.Providers.providers.storage.s3 = function (formio: {
formUrl: string;
[field: string]: unknown;
}) {
const s3Formio = cloneDeep(formio);
s3Formio.formUrl = `${serverUrl}/api/formio/2022/s3/frf/${mongoId}/${comboKey}`;
return s3(s3Formio);
return Providers.providers.storage.s3(s3Formio);
};

const data = { ...res.submission?.data };
Expand Down
8 changes: 2 additions & 6 deletions app/client/src/routes/frf2023.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useEffect, useMemo, useRef } from "react";
import { useNavigate, useOutletContext, useParams } from "react-router-dom";
import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
import { Dialog } from "@headlessui/react";
import { Providers } from "@formio/js";
import { Formio, Form } from "@formio/react";
import s3 from "formiojs/providers/storage/s3";
import clsx from "clsx";
import { cloneDeep, isEqual } from "lodash";
import icons from "uswds/img/sprite.svg";
Expand Down Expand Up @@ -54,18 +54,14 @@ function useFormioSubmissionQueryAndMutation(mongoId: string | undefined) {
/**
* Change the formUrl the File component's `uploadFile` uses, so the s3
* upload PUT request is routed through the server app.
*
* https://github.com/formio/formio.js/blob/master/src/components/file/File.js#L760
* https://github.com/formio/formio.js/blob/master/src/providers/storage/s3.js#L5
* https://github.com/formio/formio.js/blob/master/src/providers/storage/xhr.js#L90
*/
Formio.Providers.providers.storage.s3 = function (formio: {
formUrl: string;
[field: string]: unknown;
}) {
const s3Formio = cloneDeep(formio);
s3Formio.formUrl = `${serverUrl}/api/formio/2023/s3/frf/${mongoId}/${comboKey}`;
return s3(s3Formio);
return Providers.providers.storage.s3(s3Formio);
};

return Promise.resolve(res);
Expand Down
8 changes: 2 additions & 6 deletions app/client/src/routes/frf2024.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useEffect, useMemo, useRef } from "react";
import { useNavigate, useOutletContext, useParams } from "react-router-dom";
import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
import { Dialog } from "@headlessui/react";
import { Providers } from "@formio/js";
import { Formio, Form } from "@formio/react";
import s3 from "formiojs/providers/storage/s3";
import clsx from "clsx";
import { cloneDeep, isEqual } from "lodash";
import icons from "uswds/img/sprite.svg";
Expand Down Expand Up @@ -54,18 +54,14 @@ function useFormioSubmissionQueryAndMutation(mongoId: string | undefined) {
/**
* Change the formUrl the File component's `uploadFile` uses, so the s3
* upload PUT request is routed through the server app.
*
* https://github.com/formio/formio.js/blob/master/src/components/file/File.js#L760
* https://github.com/formio/formio.js/blob/master/src/providers/storage/s3.js#L5
* https://github.com/formio/formio.js/blob/master/src/providers/storage/xhr.js#L90
*/
Formio.Providers.providers.storage.s3 = function (formio: {
formUrl: string;
[field: string]: unknown;
}) {
const s3Formio = cloneDeep(formio);
s3Formio.formUrl = `${serverUrl}/api/formio/2024/s3/frf/${mongoId}/${comboKey}`;
return s3(s3Formio);
return Providers.providers.storage.s3(s3Formio);
};

return Promise.resolve(res);
Expand Down
8 changes: 2 additions & 6 deletions app/client/src/routes/helpdesk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
useQuery,
useMutation,
} from "@tanstack/react-query";
import { Providers } from "@formio/js";
import { Formio, Form } from "@formio/react";
import s3 from "formiojs/providers/storage/s3";
import clsx from "clsx";
import { cloneDeep } from "lodash";
import icon from "uswds/img/usa-icons-bg/search--white.svg";
Expand Down Expand Up @@ -405,18 +405,14 @@ export function Helpdesk() {
/**
* Change the formUrl the File component's `uploadFile` uses, so the s3
* upload PUT request is routed through the server app.
*
* https://github.com/formio/formio.js/blob/master/src/components/file/File.js#L760
* https://github.com/formio/formio.js/blob/master/src/providers/storage/s3.js#L5
* https://github.com/formio/formio.js/blob/master/src/providers/storage/xhr.js#L90
*/
Formio.Providers.providers.storage.s3 = function (formio: {
formUrl: string;
[field: string]: unknown;
}) {
const s3Formio = cloneDeep(formio);
s3Formio.formUrl = `${serverUrl}/api/help/formio/s3/${rebateYear}/${formType}`;
return s3(s3Formio);
return Providers.providers.storage.s3(s3Formio);
};

return Promise.resolve(res);
Expand Down
8 changes: 2 additions & 6 deletions app/client/src/routes/prf2022.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useEffect, useMemo, useRef } from "react";
import { useNavigate, useOutletContext, useParams } from "react-router-dom";
import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
import { Dialog } from "@headlessui/react";
import { Providers } from "@formio/js";
import { Formio, Form } from "@formio/react";
import s3 from "formiojs/providers/storage/s3";
import clsx from "clsx";
import { cloneDeep, isEqual } from "lodash";
import icons from "uswds/img/sprite.svg";
Expand Down Expand Up @@ -54,18 +54,14 @@ function useFormioSubmissionQueryAndMutation(rebateId: string | undefined) {
/**
* Change the formUrl the File component's `uploadFile` uses, so the s3
* upload PUT request is routed through the server app.
*
* https://github.com/formio/formio.js/blob/master/src/components/file/File.js#L760
* https://github.com/formio/formio.js/blob/master/src/providers/storage/s3.js#L5
* https://github.com/formio/formio.js/blob/master/src/providers/storage/xhr.js#L90
*/
Formio.Providers.providers.storage.s3 = function (formio: {
formUrl: string;
[field: string]: unknown;
}) {
const s3Formio = cloneDeep(formio);
s3Formio.formUrl = `${serverUrl}/api/formio/2022/s3/prf/${mongoId}/${comboKey}`;
return s3(s3Formio);
return Providers.providers.storage.s3(s3Formio);
};

return Promise.resolve(res);
Expand Down
8 changes: 2 additions & 6 deletions app/client/src/routes/prf2023.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useEffect, useMemo, useRef } from "react";
import { useNavigate, useOutletContext, useParams } from "react-router-dom";
import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
import { Dialog } from "@headlessui/react";
import { Providers } from "@formio/js";
import { Formio, Form } from "@formio/react";
import s3 from "formiojs/providers/storage/s3";
import clsx from "clsx";
import { cloneDeep, isEqual } from "lodash";
import icons from "uswds/img/sprite.svg";
Expand Down Expand Up @@ -54,18 +54,14 @@ function useFormioSubmissionQueryAndMutation(rebateId: string | undefined) {
/**
* Change the formUrl the File component's `uploadFile` uses, so the s3
* upload PUT request is routed through the server app.
*
* https://github.com/formio/formio.js/blob/master/src/components/file/File.js#L760
* https://github.com/formio/formio.js/blob/master/src/providers/storage/s3.js#L5
* https://github.com/formio/formio.js/blob/master/src/providers/storage/xhr.js#L90
*/
Formio.Providers.providers.storage.s3 = function (formio: {
formUrl: string;
[field: string]: unknown;
}) {
const s3Formio = cloneDeep(formio);
s3Formio.formUrl = `${serverUrl}/api/formio/2023/s3/prf/${mongoId}/${comboKey}`;
return s3(s3Formio);
return Providers.providers.storage.s3(s3Formio);
};

return Promise.resolve(res);
Expand Down
8 changes: 2 additions & 6 deletions app/client/src/routes/prf2024.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useEffect, useMemo, useRef } from "react";
import { useNavigate, useOutletContext, useParams } from "react-router-dom";
import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
import { Dialog } from "@headlessui/react";
import { Providers } from "@formio/js";
import { Formio, Form } from "@formio/react";
import s3 from "formiojs/providers/storage/s3";
import clsx from "clsx";
import { cloneDeep, isEqual } from "lodash";
import icons from "uswds/img/sprite.svg";
Expand Down Expand Up @@ -54,18 +54,14 @@ function useFormioSubmissionQueryAndMutation(rebateId: string | undefined) {
/**
* Change the formUrl the File component's `uploadFile` uses, so the s3
* upload PUT request is routed through the server app.
*
* https://github.com/formio/formio.js/blob/master/src/components/file/File.js#L760
* https://github.com/formio/formio.js/blob/master/src/providers/storage/s3.js#L5
* https://github.com/formio/formio.js/blob/master/src/providers/storage/xhr.js#L90
*/
Formio.Providers.providers.storage.s3 = function (formio: {
formUrl: string;
[field: string]: unknown;
}) {
const s3Formio = cloneDeep(formio);
s3Formio.formUrl = `${serverUrl}/api/formio/2024/s3/prf/${mongoId}/${comboKey}`;
return s3(s3Formio);
return Providers.providers.storage.s3(s3Formio);
};

return Promise.resolve(res);
Expand Down
1 change: 0 additions & 1 deletion app/client/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="vite/client" />

declare module "formiojs/providers/storage/s3";
declare module "@formio/react";

0 comments on commit 6dde3ac

Please sign in to comment.