|
|
@@ -4,6 +4,7 @@ import SwitchCom from "../../Helpers/SwitchCom";
|
|
|
|
import LoadingSpinner from "../../Spinners/LoadingSpinner";
|
|
|
|
import LoadingSpinner from "../../Spinners/LoadingSpinner";
|
|
|
|
import usersService from "../../../services/UsersService";
|
|
|
|
import usersService from "../../../services/UsersService";
|
|
|
|
import localImgLoad from "../../../lib/localImgLoad";
|
|
|
|
import localImgLoad from "../../../lib/localImgLoad";
|
|
|
|
|
|
|
|
import { toast } from "react-toastify";
|
|
|
|
|
|
|
|
|
|
|
|
import defaultImage from '../../../assets/images/banner-job-due.jpg'
|
|
|
|
import defaultImage from '../../../assets/images/banner-job-due.jpg'
|
|
|
|
|
|
|
|
|
|
|
@@ -13,13 +14,15 @@ export default function NotificationSettingTab() {
|
|
|
|
|
|
|
|
|
|
|
|
const [accSettings, setAccSettings] = useState({loading: true, data: []}) // STATE TO HOLD ACCOUNT SETTINGS
|
|
|
|
const [accSettings, setAccSettings] = useState({loading: true, data: []}) // STATE TO HOLD ACCOUNT SETTINGS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let [notificationChange, setNotificationChange] = useState({loading: false, uid: ''})
|
|
|
|
|
|
|
|
|
|
|
|
// const [updateNotification, setUpdateNotification] = useState(false);
|
|
|
|
// const [updateNotification, setUpdateNotification] = useState(false);
|
|
|
|
// const [uploadProduct, setUploadProduct] = useState(true);
|
|
|
|
// const [uploadProduct, setUploadProduct] = useState(true);
|
|
|
|
// const [saleProduct, setSaleProduct] = useState(true);
|
|
|
|
// const [saleProduct, setSaleProduct] = useState(true);
|
|
|
|
// const [getProduct, setGetProduct] = useState(false);
|
|
|
|
// const [getProduct, setGetProduct] = useState(false);
|
|
|
|
// const [authLevel, setAuthLevel] = useState(true);
|
|
|
|
// const [authLevel, setAuthLevel] = useState(true);
|
|
|
|
|
|
|
|
|
|
|
|
const handleNotificationChange = (item) => {
|
|
|
|
const NotificationInterfaceChange = (item) => {
|
|
|
|
setAccSettings(prev => {
|
|
|
|
setAccSettings(prev => {
|
|
|
|
let newAccSettings = prev.data.map(data => {
|
|
|
|
let newAccSettings = prev.data.map(data => {
|
|
|
|
if(data.uid == item.uid){
|
|
|
|
if(data.uid == item.uid){
|
|
|
@@ -33,6 +36,26 @@ export default function NotificationSettingTab() {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let handleNotificationChange = (item) => { // FUNCTION TO SET ACCOUNT SETTING
|
|
|
|
|
|
|
|
setNotificationChange({loading: true, uid: item.uid})
|
|
|
|
|
|
|
|
let reqData = { // API PAYLOADS
|
|
|
|
|
|
|
|
pref_id: item.pref_id,
|
|
|
|
|
|
|
|
status: '100'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
api.setAccSettings(reqData).then(res => {
|
|
|
|
|
|
|
|
if(res.status != 200 || res.data.internal_return < 0){
|
|
|
|
|
|
|
|
toast.error("unable to complete");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
toast.success("successful");
|
|
|
|
|
|
|
|
NotificationInterfaceChange(item) // CHANGES NOTIFICATION UI INTERFACE
|
|
|
|
|
|
|
|
}).catch(errer => {
|
|
|
|
|
|
|
|
toast.error("unable to complete");
|
|
|
|
|
|
|
|
}).finally(()=>{
|
|
|
|
|
|
|
|
setNotificationChange({loading: false, uid: {}})
|
|
|
|
|
|
|
|
// setTimeout(()=>{setNotificationChange({loading: false, uid: {}})},2000)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{
|
|
|
|
useEffect(()=>{
|
|
|
|
api.getAccSettings().then(res => {
|
|
|
|
api.getAccSettings().then(res => {
|
|
|
|
setAccSettings({loading: false, data: res.data?.result_list || []})
|
|
|
|
setAccSettings({loading: false, data: res.data?.result_list || []})
|
|
|
@@ -67,12 +90,16 @@ export default function NotificationSettingTab() {
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="mt-5 sm:mt-0">
|
|
|
|
<div className="mt-5 sm:mt-0">
|
|
|
|
|
|
|
|
{notificationChange.loading && notificationChange.uid == item.uid ?
|
|
|
|
|
|
|
|
<LoadingSpinner size='8' color='sky-blue' />
|
|
|
|
|
|
|
|
:
|
|
|
|
<SwitchCom
|
|
|
|
<SwitchCom
|
|
|
|
value={item.pref_value}
|
|
|
|
value={item.pref_value}
|
|
|
|
handler={() => handleNotificationChange(item)}
|
|
|
|
handler={ notificationChange.loading ? ()=>{} : () => handleNotificationChange(item)}
|
|
|
|
// value={updateNotification}
|
|
|
|
// value={updateNotification}
|
|
|
|
// handler={() => setUpdateNotification(!updateNotification)}
|
|
|
|
// handler={() => setUpdateNotification(!updateNotification)}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</li>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|