Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

Refactor Transform type to use union of TRANSFORMS constants in useImageCropUpload and getAvatar

yoginth.com afc22923 a5d9ccca

verified
+4 -14
+2 -2
apps/web/src/hooks/useImageCropUpload.tsx
··· 4 4 import { 5 5 DEFAULT_AVATAR, 6 6 STATIC_IMAGES_URL, 7 - type Transform 7 + type TRANSFORMS 8 8 } from "@hey/data/constants"; 9 9 import { ERRORS } from "@hey/data/errors"; 10 10 import imageKit from "@hey/helpers/imageKit"; ··· 19 19 src: string; 20 20 setSrc: (src: string) => void; 21 21 aspect: number; 22 - transform: Transform; 22 + transform: (typeof TRANSFORMS)[keyof typeof TRANSFORMS]; 23 23 label: "avatar" | "cover"; 24 24 } 25 25
-6
packages/data/constants.ts
··· 66 66 ATTACHMENT: "tr:w-1000" 67 67 } as const; 68 68 69 - export type Transform = (typeof TRANSFORMS)[keyof typeof TRANSFORMS]; 70 - 71 69 export const BANNER_IDS = { 72 70 PRO: "108325599858337195593675454288445399104045325554183036578573525280972584660299" 73 71 } as const; 74 72 75 - export type BannerId = (typeof BANNER_IDS)[keyof typeof BANNER_IDS]; 76 - 77 73 export const PERMISSIONS = { 78 74 SUBSCRIPTION: "0x4BE5b4519814A57E6f9AaFC6afBB37eAEeE35aA3", 79 75 STAFF: "0xA7f2835e54998c6d7d4A0126eC0ebE91b5E43c69" 80 76 } as const; 81 - 82 - export type Permission = (typeof PERMISSIONS)[keyof typeof PERMISSIONS];
+2 -6
packages/helpers/getAvatar.ts
··· 1 - import { 2 - DEFAULT_AVATAR, 3 - TRANSFORMS, 4 - type Transform 5 - } from "@hey/data/constants"; 1 + import { DEFAULT_AVATAR, TRANSFORMS } from "@hey/data/constants"; 6 2 import imageKit from "./imageKit"; 7 3 import sanitizeDStorageUrl from "./sanitizeDStorageUrl"; 8 4 ··· 15 11 16 12 const getAvatar = ( 17 13 entity: EntityWithAvatar | null | undefined, 18 - namedTransform: Transform = TRANSFORMS.AVATAR_SMALL 14 + namedTransform: (typeof TRANSFORMS)[keyof typeof TRANSFORMS] = TRANSFORMS.AVATAR_SMALL 19 15 ): string => { 20 16 if (!entity) { 21 17 return DEFAULT_AVATAR;