Skip to content

Commit b1854d9

Browse files
feat: some improvement to function names
1 parent ecf7ced commit b1854d9

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

src/features/users/PageAdminUsers.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ export default function PageAdminUsers() {
107107
.map((user) => (
108108
<DataListRow as={LinkBox} key={user.id} withHover>
109109
<DataListCell w="auto">
110-
<Avatar size="sm" name={user.email ?? ''} />
110+
<Avatar
111+
size="sm"
112+
name={user.email ?? ''}
113+
src={user.image ?? undefined}
114+
/>
111115
</DataListCell>
112116
<DataListCell flex={2}>
113117
<DataListText fontWeight="bold">

src/files/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const fetchFile = async (url: string, metadata?: string[]) => {
2424
const fileResponse = await fetch(url, {
2525
cache: 'no-cache',
2626
});
27+
2728
if (!fileResponse.ok) {
2829
throw new Error('Could not fetch the file');
2930
}

src/files/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { env } from '@/env.mjs';
22

3-
export const isFileUrlValidBucket = async (url: string) => {
3+
/**
4+
* Check if the provided string starts with the bucket public URL
5+
* @param url The URL to check
6+
* @returns true if the provided `url` matches the bucket public URL
7+
*/
8+
export const doesFileUrlMatchesBucket = async (url: string) => {
49
return url.startsWith(env.S3_BUCKET_PUBLIC_URL);
510
};

src/server/routers/account.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from '@/features/account/schemas';
1313
import { zVerificationCodeValidate } from '@/features/auth/schemas';
1414
import { VALIDATION_TOKEN_EXPIRATION_IN_MINUTES } from '@/features/auth/utils';
15-
import { isFileUrlValidBucket } from '@/files/utils';
15+
import { doesFileUrlMatchesBucket } from '@/files/utils';
1616
import i18n from '@/lib/i18n/server';
1717
import {
1818
deleteUsedCode,
@@ -61,7 +61,7 @@ export const accountRouter = createTRPCRouter({
6161
try {
6262
ctx.logger.info('Updating the user');
6363

64-
if (input.image && !isFileUrlValidBucket(input.image)) {
64+
if (input.image && !doesFileUrlMatchesBucket(input.image)) {
6565
ctx.logger.error('Avatar URL do not match S3 bucket URL');
6666
throw new TRPCError({
6767
code: 'BAD_REQUEST',

0 commit comments

Comments
 (0)