Skip to content

Commit fd9f45c

Browse files
committed
Merge branch 'v4.0'
2 parents 0572910 + f191a9b commit fd9f45c

File tree

351 files changed

+74473
-169631
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

351 files changed

+74473
-169631
lines changed

.eslintrc-base

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
// "fixMixedExportsWithInlineTypeSpecifier": true
5757
// }
5858
// ],
59+
"@typescript-eslint/switch-exhaustiveness-check": "error",
5960
"no-mixed-spaces-and-tabs": ["off"],
6061
// "react/react-in-jsx-scope": 0,
6162
"react/react-in-jsx-scope": "off",

legacy-packages/webapp/src/ui/components/pages/Profile/Ctrl/ProfileCtrl.tsx

Lines changed: 25 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import { t } from '@lingui/macro'
2-
import {
3-
isEdgeNodeOfType,
4-
narrowNodeType,
5-
} from '@moodlenet/common/dist/graphql/helpers'
6-
import { ID } from '@moodlenet/common/dist/graphql/scalars.graphql'
7-
import { AssetRefInput } from '@moodlenet/common/dist/graphql/types.graphql.gen'
2+
import { isEdgeNodeOfType, narrowNodeType } from '@moodlenet/common/dist/graphql/helpers'
3+
import type { ID } from '@moodlenet/common/dist/graphql/scalars.graphql'
4+
import type { AssetRefInput } from '@moodlenet/common/dist/graphql/types.graphql.gen'
85
import { fileExceedsMaxUploadSize } from '@moodlenet/common/dist/staticAsset/lib'
96
import { useFormik } from 'formik'
107
import { createElement, useCallback, useEffect, useMemo } from 'react'
11-
import { mixed, object, SchemaOf, string } from 'yup'
12-
import {
13-
MIN_RESOURCES_FOR_USER_APPROVAL_REQUESTS,
14-
MNEnv,
15-
} from '../../../../../constants'
8+
import type { SchemaOf } from 'yup'
9+
import { mixed, object, string } from 'yup'
10+
import { MIN_RESOURCES_FOR_USER_APPROVAL_REQUESTS, MNEnv } from '../../../../../constants'
1611
import { useLocalInstance } from '../../../../../context/Global/LocalInstance'
1712
import { useSeoContentId } from '../../../../../context/Global/Seo'
1813
import { useSession } from '../../../../../context/Global/Session'
@@ -23,14 +18,15 @@ import {
2318
} from '../../../../../helpers/data'
2419
import { mainPath } from '../../../../../hooks/glob/nav'
2520
import { href } from '../../../../elements/link'
26-
import { ctrlHook, CtrlHook } from '../../../../lib/ctrl'
21+
import type { CtrlHook } from '../../../../lib/ctrl'
22+
import { ctrlHook } from '../../../../lib/ctrl'
2723
import { useCollectionCardCtrl } from '../../../molecules/cards/CollectionCard/Ctrl/CollectionCardCtrl'
2824
import { useResourceCardCtrl } from '../../../molecules/cards/ResourceCard/Ctrl/ResourceCardCtrl'
2925
import { useHeaderPageTemplateCtrl } from '../../../templates/HeaderPageTemplateCtrl/HeaderPageTemplateCtrl'
3026
import { fallbackProps } from '../../Extra/Fallback/Ctrl/FallbackCtrl'
3127
import { Fallback } from '../../Extra/Fallback/Fallback'
32-
import { ProfileProps } from '../Profile'
33-
import { ProfileFormValues } from '../types'
28+
import type { ProfileProps } from '../Profile'
29+
import type { ProfileFormValues } from '../types'
3430
import {
3531
useAddProfileRelationMutation,
3632
useDelProfileRelationMutation,
@@ -39,16 +35,14 @@ import {
3935
useSendEmailToProfileMutation,
4036
} from './ProfileCtrl.gen'
4137

42-
// TODO //@ETTO: LOOK ETTORE FOR FORM
43-
4438
const validationSchema: SchemaOf<ProfileFormValues> = object({
4539
avatarImage: mixed()
4640
.test((v, { createError }) =>
4741
v instanceof Blob && fileExceedsMaxUploadSize(v.size, MNEnv.maxUploadSize)
4842
? createError({
4943
message: t`The image is too big, reduce the size or use another image`,
5044
})
51-
: true
45+
: true,
5246
)
5347
.optional(),
5448
backgroundImage: mixed()
@@ -57,7 +51,7 @@ const validationSchema: SchemaOf<ProfileFormValues> = object({
5751
? createError({
5852
message: t`The image is too big, reduce the size or use another image`,
5953
})
60-
: true
54+
: true,
6155
)
6256
.optional(),
6357
displayName: string()
@@ -73,9 +67,7 @@ const newCollectionHref = href(mainPath.createNewCollection)
7367
const newResourceHref = href(mainPath.createNewResource)
7468

7569
export type ProfileCtrlProps = { id: ID }
76-
export const useProfileCtrl: CtrlHook<ProfileProps, ProfileCtrlProps> = ({
77-
id,
78-
}) => {
70+
export const useProfileCtrl: CtrlHook<ProfileProps, ProfileCtrlProps> = ({ id }) => {
7971
useSeoContentId(id)
8072
const {
8173
isAuthenticated,
@@ -116,7 +108,7 @@ export const useProfileCtrl: CtrlHook<ProfileProps, ProfileCtrlProps> = ({
116108
(profile?.collections.edges || [])
117109
.filter(isEdgeNodeOfType(['Collection']))
118110
.map(({ node }) => node),
119-
[profile?.collections.edges]
111+
[profile?.collections.edges],
120112
)
121113
const [edit, editProfile] = useEditProfileMutation()
122114
const [addRelation, addRelationRes] = useAddProfileRelationMutation()
@@ -128,16 +120,13 @@ export const useProfileCtrl: CtrlHook<ProfileProps, ProfileCtrlProps> = ({
128120
(profile?.resources.edges || [])
129121
.filter(isEdgeNodeOfType(['Resource']))
130122
.map(({ node }) => node),
131-
[profile?.resources.edges]
123+
[profile?.resources.edges],
132124
)
133125

134126
const kudos = useMemo(
135127
() =>
136-
[...resources, ...collections].reduce(
137-
(allLikes, { likesCount }) => allLikes + likesCount,
138-
0
139-
),
140-
[collections, resources]
128+
[...resources, ...collections].reduce((allLikes, { likesCount }) => allLikes + likesCount, 0),
129+
[collections, resources],
141130
)
142131
const myFollowEdgeId = profile?.myFollow.edges[0]?.edge.id
143132
const toggleFollowForm = useFormik({
@@ -199,14 +188,13 @@ export const useProfileCtrl: CtrlHook<ProfileProps, ProfileCtrlProps> = ({
199188
const form = useFormik<ProfileFormValues>({
200189
validationSchema,
201190
initialValues: { description: '', displayName: '' },
202-
onSubmit: async (vals) => {
191+
onSubmit: async vals => {
203192
if (!form.dirty || editProfile.loading) {
204193
return
205194
}
206195

207196
const imageAssetRef: AssetRefInput =
208-
!vals.backgroundImage ||
209-
vals.backgroundImage === form.initialValues.backgroundImage
197+
!vals.backgroundImage || vals.backgroundImage === form.initialValues.backgroundImage
210198
? { location: '', type: 'NoChange' }
211199
: typeof vals.backgroundImage === 'string'
212200
? {
@@ -290,10 +278,7 @@ export const useProfileCtrl: CtrlHook<ProfileProps, ProfileCtrlProps> = ({
290278
},
291279
},
292280
})
293-
if (
294-
_published &&
295-
editResp.data?.editNode.__typename === 'EditNodeMutationSuccess'
296-
) {
281+
if (_published && editResp.data?.editNode.__typename === 'EditNodeMutationSuccess') {
297282
await sendEmailMut({
298283
variables: {
299284
text: 'Congratulations! Your account has been approved!',
@@ -302,7 +287,7 @@ export const useProfileCtrl: CtrlHook<ProfileProps, ProfileCtrlProps> = ({
302287
})
303288
}
304289
},
305-
[edit, isAdmin, profile, sendEmailMut]
290+
[edit, isAdmin, profile, sendEmailMut],
306291
)
307292
const sendEmailForm = useFormik<{ text: string }>({
308293
initialValues: { text: '' },
@@ -326,17 +311,13 @@ export const useProfileCtrl: CtrlHook<ProfileProps, ProfileCtrlProps> = ({
326311
const userId = `${profile.id.split('/')![1]}@${localOrg.domain}`
327312

328313
const props: ProfileProps = {
329-
headerPageTemplateProps: ctrlHook(
330-
useHeaderPageTemplateCtrl,
331-
{},
332-
'header-page-template'
333-
),
314+
headerPageTemplateProps: ctrlHook(useHeaderPageTemplateCtrl, {}, 'header-page-template'),
334315
isOwner: isMe,
335316
resourceCardPropsList: resources.map(({ id }) =>
336-
ctrlHook(useResourceCardCtrl, { id, removeAction: false }, id)
317+
ctrlHook(useResourceCardCtrl, { id, removeAction: false }, id),
337318
),
338319
collectionCardPropsList: collections.map(({ id }) =>
339-
ctrlHook(useCollectionCardCtrl, { id }, id)
320+
ctrlHook(useCollectionCardCtrl, { id }, id),
340321
),
341322
overallCardProps: {
342323
followers: profile.followersCount,
@@ -359,8 +340,7 @@ export const useProfileCtrl: CtrlHook<ProfileProps, ProfileCtrlProps> = ({
359340
isApproved: profile._published,
360341
requestApprovalForm,
361342
isElegibleForApproval:
362-
profile.resourcesCount >=
363-
(MIN_RESOURCES_FOR_USER_APPROVAL_REQUESTS ?? 0),
343+
profile.resourcesCount >= (MIN_RESOURCES_FOR_USER_APPROVAL_REQUESTS ?? 0),
364344
isWaitingApproval,
365345
showAccountApprovedSuccessAlert: hasJustBeenApproved,
366346
unapproveUserForm,

legacy-packages/webapp/src/ui/styles/utils/_colors.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$base-light-green-color: #00bd7e;
2-
$base-light-red-color: rgb(255, 49, 49);
2+
$base-light-red-color: #ff3131;
33
$base-moodle-color: #f88012;
44
$base-electric-blue-color: #1a6aff;
55
$base-black-color: #212121;

notes/react-app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@ produce packge.json c0on tutti i package e li risolv
9393

9494
packages/react-app/src/webapp/components.mts export similar
9595

96-
//TODO //@ALE //@ETTO
96+
//TODO //@ALE
9797

9898
il package dovrebbe avere 3 cartelle, common, webapp, server

0 commit comments

Comments
 (0)