Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Farhan/Add useSettings hook to @deriv/api #9805

Merged
merged 7 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/api/src/hooks/useSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useMemo } from 'react';
import useFetch from '../useFetch';

/** A custom hook to get user settings (email, date of birth, address etc) */
const useSettings = () => {
farhan-nurzi-deriv marked this conversation as resolved.
Show resolved Hide resolved
const { data, ...rest } = useFetch('get_settings');

const modified_data = useMemo(() => ({ ...data?.get_settings }), [data?.get_settings]);

return {
/** User information and settings */
data: modified_data,
...rest,
};
};

export default useSettings;