Skip to content

Commit 65cfa55

Browse files
authored
refactor(frontend): move profile converter to utils (#661)
1 parent 48f0aec commit 65cfa55

5 files changed

Lines changed: 7 additions & 6 deletions

File tree

frontend/app/routes/api.profile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import {
1111
TOOL_WIDGET,
1212
} from '@shared/types'
1313
import { getWalletAddress, normalizeWalletAddress } from '@shared/utils'
14+
import { convertToConfiguration } from '@shared/utils/profile-converter'
1415
import { APP_BASEPATH } from '~/lib/constants.js'
1516
import type { ApiError } from '~/lib/helpers'
1617
import { INVALID_PAYLOAD_ERROR } from '~/lib/helpers'
1718
import type { SaveResult } from '~/lib/types'
1819
import { ConfigStorageService } from '~/utils/config-storage.server.js'
1920
import { createInteractiveGrant } from '~/utils/open-payments.server.js'
20-
import { convertToConfiguration } from '~/utils/profile-converter'
2121
import { sanitizeProfileFields } from '~/utils/sanitize.server'
2222
import { commitSession, getSession } from '~/utils/session.server.js'
2323
import { walletSchema } from '~/utils/validate.server'

frontend/app/routes/api.profiles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import type {
1414
} from '@shared/types'
1515
import { TOOLS } from '@shared/types'
1616
import { getWalletAddress, normalizeWalletAddress } from '@shared/utils'
17+
import { convertToProfiles } from '@shared/utils/profile-converter'
1718
import { INVALID_PAYLOAD_ERROR } from '~/lib/helpers'
1819
import type { GetProfilesResult } from '~/lib/types'
19-
import { convertToProfiles } from '~/utils/profile-converter'
2020
import { walletSchema } from '~/utils/validate.server'
2121
import type { Route } from './+types/api.profiles'
2222

shared/types/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "@shared/types",
33
"version": "0.0.1",
4+
"type": "module",
45
"private": true
56
}

shared/utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@shared/utils",
33
"version": "0.0.1",
4+
"type": "module",
45
"private": true,
56
"devDependencies": {
67
"@interledger/open-payments": "^7.4.0",
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,20 @@ function convertToProfile<T extends Tool>(
2626
return config.offerwall as ToolProfile<T>
2727
}
2828

29+
const now = new Date().toISOString()
2930
return {
3031
$version: '0.0.1',
3132
$name: config.versionName,
32-
$modifiedAt: '',
33+
$modifiedAt: now,
3334
...getToolProfile(config, tool),
3435
} as ToolProfile<T>
3536
}
3637

3738
/** @legacy */
3839
export function convertToConfigLegacy<T extends Tool>(
39-
walletAddress: string,
40+
_walletAddress: string,
4041
profile: ToolProfile<T>,
4142
): Partial<ElementConfigType> {
42-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
43-
const { $name, $version, $modifiedAt, ...rest } = profile
4443
if ('thumbnail' in profile) {
4544
return {
4645
bannerFontName: profile.font.name,

0 commit comments

Comments
 (0)