[ABANDONED] React/Redux front end for the Flexor social network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.9 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. import { Action } from 'redux'
  2. import { NotificationType, FormValue } from '../types'
  3. export interface InitFormAction extends Action {
  4. type: 'FORMS_INIT'
  5. }
  6. export interface InitFieldAction extends Action {
  7. type: 'FORMS_INIT_FIELD'
  8. payload: {
  9. name: string
  10. value: FormValue
  11. apiName?: string
  12. }
  13. }
  14. export interface SetFieldValueAction extends Action {
  15. type: 'FORMS_SET_FIELD_VALUE'
  16. payload: {
  17. name: string
  18. value: FormValue
  19. }
  20. }
  21. export interface SetFormNotificationAction extends Action {
  22. type: 'FORMS_SET_FORM_NOTIFICATION'
  23. payload: {
  24. type: NotificationType
  25. message: string
  26. }
  27. }
  28. export interface SetFieldNotificationAction extends Action {
  29. type: 'FORMS_SET_FIELD_NOTIFICATION'
  30. payload: {
  31. name: string
  32. type: NotificationType
  33. message: string
  34. }
  35. }
  36. export type FormsActions = InitFormAction | InitFieldAction | SetFieldValueAction | SetFormNotificationAction | SetFieldNotificationAction
  37. export const initForm = (): InitFormAction => ({
  38. type: 'FORMS_INIT',
  39. })
  40. export const initField = (name: string, value: FormValue, apiName?: string): InitFieldAction => ({
  41. type: 'FORMS_INIT_FIELD',
  42. payload: {
  43. name,
  44. value,
  45. apiName,
  46. },
  47. })
  48. export const setFieldValue = (name: string, value: FormValue): SetFieldValueAction => ({
  49. type: 'FORMS_SET_FIELD_VALUE',
  50. payload: {
  51. name,
  52. value,
  53. },
  54. })
  55. export const setFormNotification = (type: NotificationType, message: string): SetFormNotificationAction => ({
  56. type: 'FORMS_SET_FORM_NOTIFICATION',
  57. payload: {
  58. type,
  59. message,
  60. }
  61. })
  62. export const setFieldNotification = (name: string, type: NotificationType, message: string): SetFieldNotificationAction => ({
  63. type: 'FORMS_SET_FIELD_NOTIFICATION',
  64. payload: {
  65. name,
  66. type,
  67. message,
  68. }
  69. })