feat(contacts/nui): alert on actions

This commit is contained in:
Christopher committed 2020-12-11 22:01:16 +01:00
1 parent a415301145
commit da32d2ca35
4 files changed
+45 -28

No files matched your search

@@ -1,25 +1,26 @@
import React from "react"; import React from 'react';
import { AppWrapper } from "../../../ui/components"; import { AppWrapper } from '../../../ui/components';
import { makeStyles, createStyles, Theme } from "@material-ui/core/styles"; import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
import { AppTitle } from "../../../ui/components/AppTitle"; import { AppTitle } from '../../../ui/components/AppTitle';
import { AppContent } from "../../../ui/components/AppContent"; import { AppContent } from '../../../ui/components/AppContent';
import { ContactList } from "./List/ContactList"; import { ContactList } from './List/ContactList';
import { useApp } from "../../../os/apps/hooks/useApps"; import { useApp } from '../../../os/apps/hooks/useApps';
import { AddContactModal } from "./ContactModal"; import { AddContactModal } from './ContactModal';
import { useModal } from "../hooks/useModal"; import { useModal } from '../hooks/useModal';
import { SearchContacts } from "./List/SearchContacts"; import { SearchContacts } from './List/SearchContacts';
import PersonAddIcon from "@material-ui/icons/PersonAdd"; import PersonAddIcon from '@material-ui/icons/PersonAdd';
import Fab from "@material-ui/core/Fab"; import Fab from '@material-ui/core/Fab';
import { useContactModal } from "../hooks/useContactModal"; import { useContactModal } from '../hooks/useContactModal';
import { InfoModal } from "./modal/InfoModal"; import { InfoModal } from './modal/InfoModal';
import { useContactDetail } from "../hooks/useContactDetail"; import { useContactDetail } from '../hooks/useContactDetail';
import { ContactAlert } from './alert/ContactAlert';
const useStyles = makeStyles((theme: Theme) => const useStyles = makeStyles((theme: Theme) =>
createStyles({ createStyles({
backgroundModal: { backgroundModal: {
background: "black", background: 'black',
opacity: "0.6", opacity: '0.6',
position: "absolute", position: 'absolute',
top: 0, top: 0,
left: 0, left: 0,
right: 0, right: 0,
@@ -27,7 +28,7 @@ const useStyles = makeStyles((theme: Theme) =>
zIndex: 5, zIndex: 5,
}, },
absolute: { absolute: {
position: "sticky", position: 'sticky',
bottom: theme.spacing(2), bottom: theme.spacing(2),
left: theme.spacing(3), left: theme.spacing(3),
}, },
@@ -37,7 +38,7 @@ const useStyles = makeStyles((theme: Theme) =>
export const ContactsApp = () => { export const ContactsApp = () => {
const classes = useStyles(); const classes = useStyles();
const { showModal, setShowModal } = useModal(); const { showModal, setShowModal } = useModal();
const contacts = useApp("CONTACTS"); const contacts = useApp('CONTACTS');
const { contactDetail } = useContactDetail(); const { contactDetail } = useContactDetail();
const openModal = () => { const openModal = () => {
@@ -45,7 +46,7 @@ export const ContactsApp = () => {
}; };
return ( return (
<AppWrapper id="contact-app"> <AppWrapper id='contact-app'>
<AppTitle app={contacts}></AppTitle> <AppTitle app={contacts}></AppTitle>
<SearchContacts /> <SearchContacts />
<AddContactModal /> <AddContactModal />
@@ -55,11 +56,12 @@ export const ContactsApp = () => {
<ContactList /> <ContactList />
<Fab <Fab
onClick={openModal} onClick={openModal}
style={{ backgroundColor: "#2196f3", color: "#fff" }} style={{ backgroundColor: '#2196f3', color: '#fff' }}
className={classes.absolute} className={classes.absolute}
> >
<PersonAddIcon /> <PersonAddIcon />
</Fab> </Fab>
<ContactAlert />
</AppContent> </AppContent>
</AppWrapper> </AppWrapper>
); );
@@ -0,0 +1,8 @@
import { useRecoilState } from 'recoil';
import { IContactAlert } from '../../../common/interfaces/contact';
import { contactsState } from './state';
export const useContactAlert = (): IContactAlert => {
const [alert, setAlert] = useRecoilState(contactsState.contactAlert);
return { alert, setAlert };
};
@@ -1,10 +1,13 @@
import { useNuiEvent } from "../../../os/nui-events/hooks/useNuiEvent"; import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
import { useSetRecoilState } from "recoil"; import { useSetRecoilState } from 'recoil';
import { contactsState } from "./state"; import { contactsState } from './state';
import { useContacts } from "./useContacts"; import { useContacts } from './useContacts';
import { useContactAlert } from './useAlert';
export const useContactsService = () => { export const useContactsService = () => {
const setContacts = useSetRecoilState(contactsState.contacts); const setContacts = useSetRecoilState(contactsState.contacts);
useNuiEvent("CONTACTS", "setContacts", setContacts); const setAlert = useSetRecoilState(contactsState.contactAlert);
return useContacts(); useNuiEvent('CONTACTS', 'setContacts', setContacts);
useNuiEvent('CONTACTS', 'setAlert', setAlert);
return { useContacts, useContactAlert };
}; };
+4
View File
@@ -0,0 +1,4 @@
export interface IContactAlert {
alert: string;
setAlert: (type: string) => void;
}