enquiryReducer.js
2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import {
ENQUIRY_SUBMIT_FAIL,
ENQUIRY_SUBMIT_REQUEST,
ENQUIRY_SUBMIT_SUCCESS,
GET_ENQUIRIES_BY_ADMIN_FAIL,
GET_ENQUIRIES_BY_ADMIN_REQUEST,
GET_ENQUIRIES_BY_ADMIN_SUCCESS,
GET_ENQUIRIES_BY_ENDUSER_FAIL,
GET_ENQUIRIES_BY_ENDUSER_REQUEST,
GET_ENQUIRIES_BY_ENDUSER_SUCCESS,
GET_ENQUIRIES_BY_VENDOR_FAIL,
GET_ENQUIRIES_BY_VENDOR_REQUEST,
GET_ENQUIRIES_BY_VENDOR_SUCCESS
} from "../constants/enquiryConstants";
export const enquiryReducer = (state = { enquiry: null }, action) => {
switch (action.type) {
case ENQUIRY_SUBMIT_REQUEST:
return {
loading: true,
success: false
};
case ENQUIRY_SUBMIT_SUCCESS:
return {
loading: false,
success: true,
enquiry: action.payload
};
case ENQUIRY_SUBMIT_FAIL:
return {
loading: false,
success: false,
error: action.payload.error.message
};
default:
return state;
}
};
export const getEnquiriesReducer = (state = { enquiriesByVendor: null }, action) => {
switch (action.type) {
case GET_ENQUIRIES_BY_VENDOR_REQUEST:
return {
loading: true
};
case GET_ENQUIRIES_BY_VENDOR_SUCCESS:
return {
loading: false,
enquiriesByVendor: action.payload
};
case GET_ENQUIRIES_BY_VENDOR_FAIL:
return {
loading: false,
error: action.payload.error.message
};
default:
return state;
}
};
export const getEnquiriesByVendorReducer = (state = { enquiriesByAdmin: null }, action) => {
switch (action.type) {
case GET_ENQUIRIES_BY_ADMIN_REQUEST:
return {
loading: true
};
case GET_ENQUIRIES_BY_ADMIN_SUCCESS:
return {
loading: false,
enquiriesByAdmin: action.payload
};
case GET_ENQUIRIES_BY_ADMIN_FAIL:
return {
loading: false,
error: action.payload.error.message
};
default:
return state;
}
};
export const getEnquiriesByEndUserReducer = (state = { enquiriesByEndUser: null }, action) => {
switch (action.type) {
case GET_ENQUIRIES_BY_ENDUSER_REQUEST:
return {
loading: true
};
case GET_ENQUIRIES_BY_ENDUSER_SUCCESS:
return {
loading: false,
enquiriesByEndUser: action.payload
};
case GET_ENQUIRIES_BY_ENDUSER_FAIL:
return {
loading: false,
error: action.payload.error.message
};
default:
return state;
}
};