Added check when is_component equals null

This commit is contained in:
Lucas Oliveira 2023-12-08 17:09:43 -03:00
commit 02f68b63a0
4 changed files with 7 additions and 6 deletions

View file

@ -639,8 +639,7 @@ export function FlowsProvider({ children }: { children: ReactNode }) {
} }
async function saveFlow(newFlow: FlowType, silent?: boolean) { async function saveFlow(newFlow: FlowType, silent?: boolean) {
if (newFlow?.data?.nodes?.length === 0) return; console.log(newFlow);
try { try {
// updates flow in db // updates flow in db
const updatedFlow = await updateFlowInDatabase(newFlow); const updatedFlow = await updateFlowInDatabase(newFlow);

View file

@ -34,7 +34,7 @@ export default function FlowSettingsModal({
useEffect(() => { useEffect(() => {
const tempNameList: string[] = []; const tempNameList: string[] = [];
flows.forEach((flow: FlowType) => { flows.forEach((flow: FlowType) => {
if (flow.is_component === false) tempNameList.push(flow.name); if ((flow.is_component ?? false) === false) tempNameList.push(flow.name);
}); });
setNameList(tempNameList.filter((name) => name !== flow!.name)); setNameList(tempNameList.filter((name) => name !== flow!.name));
}, [flows]); }, [flows]);

View file

@ -84,7 +84,8 @@ export default function ShareModal({
filterByUser: true, filterByUser: true,
}).then((res) => { }).then((res) => {
res?.results?.forEach((element: any) => { res?.results?.forEach((element: any) => {
if (element.is_component === is_component) console.log(element, is_component);
if ((element.is_component ?? false) === is_component)
unavaliableNames.push({ name: element.name, id: element.id }); unavaliableNames.push({ name: element.name, id: element.id });
}); });
setUnavaliableNames(unavaliableNames); setUnavaliableNames(unavaliableNames);

View file

@ -26,7 +26,7 @@ export default function ComponentsComponent({
useEffect(() => { useEffect(() => {
if (isLoading) return; if (isLoading) return;
const all = flows const all = flows
.filter((f) => f.is_component === is_component) .filter((f) => (f.is_component ?? false) === is_component)
.sort((a, b) => { .sort((a, b) => {
if (a?.updated_at && b?.updated_at) { if (a?.updated_at && b?.updated_at) {
return ( return (
@ -179,7 +179,8 @@ export default function ComponentsComponent({
pageSize={pageSize} pageSize={pageSize}
rowsCount={[10, 20, 50, 100]} rowsCount={[10, 20, 50, 100]}
totalRowsCount={ totalRowsCount={
flows.filter((f) => f.is_component === is_component).length flows.filter((f) => (f.is_component ?? false) === is_component)
.length
} }
paginate={(pageSize, pageIndex) => { paginate={(pageSize, pageIndex) => {
setPageIndex(pageIndex); setPageIndex(pageIndex);