overleaf/services/web/frontend/js/features/settings/utils/action-creators.ts
Timothée Alby cf2dfc6bf1 Merge pull request #7593 from overleaf/ta-settings-migration
[SettingsPage] Integration Branch

GitOrigin-RevId: 5a3c26b2a02d716c4ae3981e3f08b811ae307725
2022-04-25 08:05:12 +00:00

52 lines
1.3 KiB
TypeScript

import {
Actions,
ActionSetData,
ActionSetLoading,
ActionMakePrimary,
ActionDeleteEmail,
ActionSetEmailAffiliationBeingEdited,
ActionUpdateAffiliation,
} from '../context/user-email-context'
import { UserEmailData } from '../../../../../types/user-email'
import { Nullable } from '../../../../../types/utils'
import { Affiliation } from '../../../../../types/affiliation'
export const setData = (data: UserEmailData[]): ActionSetData => ({
type: Actions.SET_DATA,
payload: data,
})
export const setLoading = (flag: boolean): ActionSetLoading => ({
type: Actions.SET_LOADING_STATE,
payload: flag,
})
export const makePrimary = (
email: UserEmailData['email']
): ActionMakePrimary => ({
type: Actions.MAKE_PRIMARY,
payload: email,
})
export const deleteEmail = (
email: UserEmailData['email']
): ActionDeleteEmail => ({
type: Actions.DELETE_EMAIL,
payload: email,
})
export const setEmailAffiliationBeingEdited = (
email: Nullable<UserEmailData['email']>
): ActionSetEmailAffiliationBeingEdited => ({
type: Actions.SET_EMAIL_AFFILIATION_BEING_EDITED,
payload: email,
})
export const updateAffiliation = (
email: UserEmailData['email'],
role: Affiliation['role'],
department: Affiliation['department']
): ActionUpdateAffiliation => ({
type: Actions.UPDATE_AFFILIATION,
payload: { email, role, department },
})