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) {
if (newFlow?.data?.nodes?.length === 0) return;
console.log(newFlow);
try {
// updates flow in db
const updatedFlow = await updateFlowInDatabase(newFlow);

View file

@ -34,7 +34,7 @@ export default function FlowSettingsModal({
useEffect(() => {
const tempNameList: string[] = [];
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));
}, [flows]);

View file

@ -84,7 +84,8 @@ export default function ShareModal({
filterByUser: true,
}).then((res) => {
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 });
});
setUnavaliableNames(unavaliableNames);

View file

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