cra-template-firebase-crm
v1.0.0
Published
The most advanced CRM Boilerplate for React + Firebase. Contains snippets for automatic state management in a declarative style
Downloads
3
Maintainers
Readme
⚛️ cra-template-firebase-crm
Contains the most advanced Firebase CRM starter kit which you ever seen!
Usage
yarn create react-app --template cra-template-firebase-crm .
or
npx create-react-app . --template=firebase-crm
What's inside
Code sample
import { useState } from 'react';
import {
FetchView,
RecordView,
ActionTrigger,
useReloadTrigger,
IActionTrigger,
} from 'react-declarative';
import ioc from '../../lib/ioc';
interface ITodoOnePageProps {
id: string;
}
const actions: IActionTrigger[] = [
{
label: 'Mark as complete',
action: 'complete-action',
}
];
export const TodoOnePage = ({
id,
}: ITodoOnePageProps) => {
const { reloadTrigger, doReload } = useReloadTrigger();
const [search, setSearch] = useState('');
const state = async () => await ioc.todoDbService.findById(id);
const handleAction = async (action: string) => {
if (action === 'complete-action') {
await ioc.todoDbService.update(id, {
completed: true,
});
doReload();
}
};
return (
<>
<ActionTrigger
actions={actions}
onAction={handleAction}
/>
<FetchView state={state} deps={[reloadTrigger]}>
{(data) => (
<RecordView
onSearchChanged={(search) => setSearch(search)}
search={search}
data={data}
/>
)}
</FetchView>
</>
);
};
export default TodoOnePage;