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