Skip to content

Commit

Permalink
Merge pull request #1448 from HarryEMartland/mobile-image-prompt-camera
Browse files Browse the repository at this point in the history
Mobile Camera Image Upload
  • Loading branch information
DonKoko authored Nov 27, 2024
2 parents 82febf7 + 7f73f75 commit 3839b0b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/components/assets/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { z } from "zod";
import { updateDynamicTitleAtom } from "~/atoms/dynamic-title-atom";
import { fileErrorAtom, validateFileAtom } from "~/atoms/file";
import type { loader } from "~/routes/_layout+/assets.$assetId_.edit";
import { ACCEPT_SUPPORTED_IMAGES } from "~/utils/constants";
import type { CustomFieldZodSchema } from "~/utils/custom-fields";
import { mergedSchema } from "~/utils/custom-fields";
import { isFormProcessing } from "~/utils/form";
Expand Down Expand Up @@ -195,7 +196,7 @@ export const AssetForm = ({
</p>
<Input
disabled={disabled}
accept="image/png,.png,image/jpeg,.jpg,.jpeg"
accept={ACCEPT_SUPPORTED_IMAGES}
name="mainImage"
type="file"
onChange={validateFile}
Expand Down
3 changes: 2 additions & 1 deletion app/components/kits/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useZorm } from "react-zorm";
import { z } from "zod";
import { updateDynamicTitleAtom } from "~/atoms/dynamic-title-atom";
import { fileErrorAtom, validateFileAtom } from "~/atoms/file";
import { ACCEPT_SUPPORTED_IMAGES } from "~/utils/constants";
import { isFormProcessing } from "~/utils/form";
import { tw } from "~/utils/tw";
import { zodFieldIsRequired } from "~/utils/zod";
Expand Down Expand Up @@ -122,7 +123,7 @@ export default function KitsForm({
</p>
<Input
disabled={disabled}
accept="image/png,.png,image/jpeg,.jpg,.jpeg"
accept={ACCEPT_SUPPORTED_IMAGES}
name="image"
type="file"
onChange={validateFile}
Expand Down
3 changes: 2 additions & 1 deletion app/components/location/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { updateDynamicTitleAtom } from "~/atoms/dynamic-title-atom";
import { fileErrorAtom, validateFileAtom } from "~/atoms/file";
import type { action as editLocationAction } from "~/routes/_layout+/locations.$locationId_.edit";
import type { action as newLocationAction } from "~/routes/_layout+/locations.new";
import { ACCEPT_SUPPORTED_IMAGES } from "~/utils/constants";
import { isFormProcessing } from "~/utils/form";
import { zodFieldIsRequired } from "~/utils/zod";
import { Form } from "../custom-form";
Expand Down Expand Up @@ -91,7 +92,7 @@ export const LocationForm = ({ name, address, description }: Props) => {
</p>
<Input
// disabled={disabled}
accept="image/png,.png,image/jpeg,.jpg,.jpeg"
accept={ACCEPT_SUPPORTED_IMAGES}
name="image"
type="file"
onChange={validateFile}
Expand Down
3 changes: 2 additions & 1 deletion app/components/workspace/edit-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { z } from "zod";
import { updateDynamicTitleAtom } from "~/atoms/dynamic-title-atom";
import { fileErrorAtom, validateFileAtom } from "~/atoms/file";
import type { loader } from "~/routes/_layout+/account-details.workspace.$workspaceId.edit";
import { ACCEPT_SUPPORTED_IMAGES } from "~/utils/constants";
import { isFormProcessing } from "~/utils/form";
import { tw } from "~/utils/tw";
import { zodFieldIsRequired } from "~/utils/zod";
Expand Down Expand Up @@ -111,7 +112,7 @@ export const WorkspaceEditForm = ({
</p>
<Input
// disabled={disabled}
accept="image/png,.png,image/jpeg,.jpg,.jpeg"
accept={ACCEPT_SUPPORTED_IMAGES}
name="image"
type="file"
onChange={validateFile}
Expand Down
3 changes: 2 additions & 1 deletion app/components/workspace/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { updateDynamicTitleAtom } from "~/atoms/dynamic-title-atom";
import { fileErrorAtom, validateFileAtom } from "~/atoms/file";
import { useSearchParams } from "~/hooks/search-params";
import type { loader } from "~/routes/_layout+/account-details.workspace.new";
import { ACCEPT_SUPPORTED_IMAGES } from "~/utils/constants";
import { isFormProcessing } from "~/utils/form";
import { zodFieldIsRequired } from "~/utils/zod";
import { Form } from "../custom-form";
Expand Down Expand Up @@ -101,7 +102,7 @@ export const WorkspaceForm = ({ name, currency, children }: Props) => {
</p>
<Input
// disabled={disabled}
accept="image/png,.png,image/jpeg,.jpg,.jpeg"
accept={ACCEPT_SUPPORTED_IMAGES}
name="image"
type="file"
onChange={validateFile}
Expand Down
3 changes: 2 additions & 1 deletion app/routes/_layout+/account-details.general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
import type { UpdateUserPayload } from "~/modules/user/types";
import { appendToMetaTitle } from "~/utils/append-to-meta-title";
import { checkExhaustiveSwitch } from "~/utils/check-exhaustive-switch";
import { ACCEPT_SUPPORTED_IMAGES } from "~/utils/constants";
import { delay } from "~/utils/delay";
import { sendNotification } from "~/utils/emitter/send-notification.server";
import { ADMIN_EMAIL, SERVER_URL } from "~/utils/env";
Expand Down Expand Up @@ -457,7 +458,7 @@ export default function UserPage() {
<p>Accepts PNG, JPG or JPEG (max.4 MB)</p>
<Input
disabled={disabled}
accept="image/png,.png,image/jpeg,.jpg,.jpeg"
accept={ACCEPT_SUPPORTED_IMAGES}
name="profile-picture"
type="file"
onChange={validateFile}
Expand Down
4 changes: 4 additions & 0 deletions app/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ export const INVITE_EXPIRY_TTL_DAYS = 5;
/** Default length of custom cuid2 */
export const DEFAULT_CUID_LENGTH = 10;
export const LEGACY_CUID_LENGTH = 25;

//Android 14 camera workaround https://stackoverflow.com/a/79163998/1894472
export const ACCEPT_SUPPORTED_IMAGES =
"image/png,.png,image/jpeg,.jpg,.jpeg,android/force-camera-workaround";

0 comments on commit 3839b0b

Please sign in to comment.