3736 |
stevensc |
1 |
import React from 'react';
|
|
|
2 |
import { useForm } from 'react-hook-form';
|
|
|
3 |
|
|
|
4 |
import { usePrivacySettings } from '@account-settings/hooks';
|
|
|
5 |
import { SettingsWidget } from '@account-settings/components';
|
|
|
6 |
|
|
|
7 |
import SwitchInput from '@components/UI/SwitchInput';
|
|
|
8 |
|
|
|
9 |
const Privacy = () => {
|
|
|
10 |
const { options, isLoading, isUpdating, handleChecked, updateSettings } = usePrivacySettings();
|
|
|
11 |
const { handleSubmit } = useForm();
|
|
|
12 |
|
|
|
13 |
const handleOnSubmit = handleSubmit(() => {
|
|
|
14 |
updateSettings();
|
|
|
15 |
});
|
|
|
16 |
|
|
|
17 |
return (
|
|
|
18 |
<SettingsWidget title='Privacidad' loading={isLoading}>
|
|
|
19 |
<form onSubmit={handleOnSubmit}>
|
|
|
20 |
{options.map((option, index) => (
|
|
|
21 |
<div className='notbat' key={index}>
|
|
|
22 |
<span>{option.label}</span>
|
|
|
23 |
<SwitchInput
|
|
|
24 |
isChecked={option.value}
|
|
|
25 |
setValue={(value) => handleChecked(value, option.input_name)}
|
|
|
26 |
/>
|
|
|
27 |
</div>
|
|
|
28 |
))}
|
|
|
29 |
|
|
|
30 |
<button type='submit' className='btn btn-primary mt-3' disabled={isUpdating}>
|
|
|
31 |
Guardar
|
|
|
32 |
</button>
|
|
|
33 |
</form>
|
|
|
34 |
</SettingsWidget>
|
|
|
35 |
);
|
|
|
36 |
};
|
|
|
37 |
|
|
|
38 |
export default Privacy;
|