🔧 fix(tabsContext.tsx): add setSuccessData to useContext to fix missing function error
✨ feat(tabsContext.tsx): add success alert when changes are saved successfully in TabsProvider component 🔧 fix(flowSettingsModal/index.tsx): remove setSuccessData from useContext to fix missing function error 🔧 fix(AdminPage/index.tsx): remove console.log statement ✨ feat(AdminPage/index.tsx): add success alert when user is edited successfully 🔧 fix(extraSidebarComponent/index.tsx): remove setSuccessData from useContext to fix missing function error
This commit is contained in:
parent
76db1b011c
commit
b4a01ad934
4 changed files with 3 additions and 7 deletions
|
|
@ -68,7 +68,7 @@ export const TabsContext = createContext<TabsContextType>(
|
||||||
);
|
);
|
||||||
|
|
||||||
export function TabsProvider({ children }: { children: ReactNode }) {
|
export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
const { setErrorData, setNoticeData } = useContext(alertContext);
|
const { setErrorData, setNoticeData, setSuccessData } = useContext(alertContext);
|
||||||
|
|
||||||
const [tabId, setTabId] = useState("");
|
const [tabId, setTabId] = useState("");
|
||||||
|
|
||||||
|
|
@ -579,6 +579,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
const updatedFlow = await updateFlowInDatabase(newFlow);
|
const updatedFlow = await updateFlowInDatabase(newFlow);
|
||||||
if (updatedFlow) {
|
if (updatedFlow) {
|
||||||
// updates flow in state
|
// updates flow in state
|
||||||
|
setSuccessData({ title: "Changes saved successfully" });
|
||||||
setFlows((prevState) => {
|
setFlows((prevState) => {
|
||||||
const newFlows = [...prevState];
|
const newFlows = [...prevState];
|
||||||
const index = newFlows.findIndex((flow) => flow.id === newFlow.id);
|
const index = newFlows.findIndex((flow) => flow.id === newFlow.id);
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ export default function FlowSettingsModal({
|
||||||
open,
|
open,
|
||||||
setOpen,
|
setOpen,
|
||||||
}: FlowSettingsPropsType): JSX.Element {
|
}: FlowSettingsPropsType): JSX.Element {
|
||||||
const { setSuccessData } = useContext(alertContext);
|
|
||||||
const { flows, tabId, updateFlow, saveFlow } = useContext(TabsContext);
|
const { flows, tabId, updateFlow, saveFlow } = useContext(TabsContext);
|
||||||
const flow = flows.find((f) => f.id === tabId);
|
const flow = flows.find((f) => f.id === tabId);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -28,7 +27,6 @@ export default function FlowSettingsModal({
|
||||||
savedFlow!.name = name;
|
savedFlow!.name = name;
|
||||||
savedFlow!.description = description;
|
savedFlow!.description = description;
|
||||||
saveFlow(savedFlow!);
|
saveFlow(savedFlow!);
|
||||||
setSuccessData({ title: "Changes saved successfully" });
|
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -133,8 +133,6 @@ export default function AdminPage() {
|
||||||
|
|
||||||
updateUser(userId, userEdit)
|
updateUser(userId, userEdit)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res);
|
|
||||||
|
|
||||||
resetFilter();
|
resetFilter();
|
||||||
setSuccessData({
|
setSuccessData({
|
||||||
title: "Success! User edited!",
|
title: "Success! User edited!",
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
const { data, templates } = useContext(typesContext);
|
const { data, templates } = useContext(typesContext);
|
||||||
const { flows, tabId, uploadFlow, tabsState, saveFlow, isBuilt } =
|
const { flows, tabId, uploadFlow, tabsState, saveFlow, isBuilt } =
|
||||||
useContext(TabsContext);
|
useContext(TabsContext);
|
||||||
const { setSuccessData, setErrorData } = useContext(alertContext);
|
const { setErrorData } = useContext(alertContext);
|
||||||
const [dataFilter, setFilterData] = useState(data);
|
const [dataFilter, setFilterData] = useState(data);
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const isPending = tabsState[tabId]?.isPending;
|
const isPending = tabsState[tabId]?.isPending;
|
||||||
|
|
@ -121,7 +121,6 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
}
|
}
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
saveFlow(flow!);
|
saveFlow(flow!);
|
||||||
setSuccessData({ title: "Changes saved successfully" });
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IconComponent
|
<IconComponent
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue