Skip to content

Commit

Permalink
change data to widget
Browse files Browse the repository at this point in the history
  • Loading branch information
ltminhthu committed Aug 5, 2024
1 parent ccb8b2a commit ebca821
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions apps/wallet/src/features/Explorer/Widgets/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import type { FC } from 'react';
import { useState } from 'react';
import { ScrollView, StyleSheet, View } from 'react-native';
import { WidgetType } from '@walless/core';
import { WidgetCategory } from '@walless/core';
import { Text } from '@walless/gui';
import type { WidgetDocument } from '@walless/store';

import CategoryButtons from './CategoryButtons';
import WidgetItem from './WidgetItem';

interface Props {
data: WidgetDocument[];
widgets: WidgetDocument[];
}

const Widgets: FC<Props> = ({ data }) => {
const [widgets, setWidgets] = useState<WidgetDocument[]>(
data.filter((item) => item.widgetType === WidgetType.NETWORK),
const Widgets: FC<Props> = ({ widgets }) => {
const [renderedWidgets, setRenderedWidgets] = useState<WidgetDocument[]>(
widgets.filter((widget) => widget.category === WidgetCategory.NETWORK),
);

return (
Expand All @@ -26,19 +26,19 @@ const Widgets: FC<Props> = ({ data }) => {
</Text>
</View>

<CategoryButtons widgets={data} setWidgets={setWidgets} />
<CategoryButtons widgets={widgets} setWidgets={setRenderedWidgets} />

<ScrollView
style={styles.layoutList}
contentContainerStyle={styles.listStyle}
showsVerticalScrollIndicator={false}
>
{widgets.length === 0 ? (
{renderedWidgets.length === 0 ? (
<Text style={styles.noWidgetsText}>
There&apos;s no widgets in this section
</Text>
) : (
widgets.map((widget) => (
renderedWidgets.map((widget) => (
<WidgetItem key={widget._id} widget={widget} />
))
)}
Expand Down

0 comments on commit ebca821

Please sign in to comment.