Skip to content

Commit

Permalink
feat(envited.ascs.digital): Add ramda mapIndexed
Browse files Browse the repository at this point in the history
Signed-off-by: Jeroen Branje <[email protected]>
  • Loading branch information
jeroenbranje committed Feb 29, 2024
1 parent 40b825d commit 514e3c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/envited.ascs.digital/common/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export {
extractTypeFromCredential,
slugify,
createRandomString,
mapIndexed,
} from './utils'
4 changes: 3 additions & 1 deletion apps/envited.ascs.digital/common/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pathOr, times } from 'ramda'
import { addIndex, map, pathOr, times } from 'ramda'

export const extractIdFromCredential = pathOr('', ['credentialSubject', 'id'])

Expand All @@ -21,3 +21,5 @@ export const createRandomString = (length: number) => {

return result
}

export const mapIndexed = addIndex(map)
5 changes: 3 additions & 2 deletions apps/envited.ascs.digital/modules/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Controller, SubmitHandler, useFieldArray, useForm } from 'react-hook-fo
import { useTranslation } from '../../common/i18n'
import { useNotification } from '../../common/notifications'
import { File, Profile as ProfileType } from '../../common/types'
import { mapIndexed } from '../../common/utils'
import { updateProfileForm } from './Profile.actions'
import { ProfileSchema } from './Profile.schema'

Expand Down Expand Up @@ -362,7 +363,7 @@ export const Profile: FC<ProfileProps> = ({ profile, memberCategories }) => {
<p className="mt-1 text-sm leading-6 text-gray-600 dark:text-gray-400">{t('[Description] offerings')}</p>

<div className="mt-10 grid grid-cols-1 gap-x-6 gap-y-8">
{offeringFields.map((field, index) => (
{mapIndexed((field: any, index: number) => (
<div key={field.id} className="border-t">
<div className="flex justify-between py-4">
<h3 className="font-bold text-gray-400">
Expand Down Expand Up @@ -449,7 +450,7 @@ export const Profile: FC<ProfileProps> = ({ profile, memberCategories }) => {
/>
</div>
</div>
))}
))(offeringFields)}
{offeringFields.length < 5 && (
<button
type="button"
Expand Down

0 comments on commit 514e3c8

Please sign in to comment.