Skip to content

Commit

Permalink
Merge branch '424-refactor-default-exports-to-named-exports-in-javasc…
Browse files Browse the repository at this point in the history
…ript-modules-in-guard-app' into 'dev'

Resolve "Refactor default exports to named exports in JavaScript modules in guard app"

Closes #424

See merge request ergo/rosen-bridge/ui!355
  • Loading branch information
vorujack committed Nov 18, 2024
2 parents c1366a1 + df652fa commit da29ec3
Show file tree
Hide file tree
Showing 32 changed files with 60 additions and 73 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-steaks-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rosen-bridge/watcher-app': patch
---

Update App.tsx import to match the recent changes in swr-mock
5 changes: 5 additions & 0 deletions .changeset/neat-rice-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rosen-ui/swr-mock': patch
---

Refactor to use named exports to improve code maintainability
5 changes: 5 additions & 0 deletions .changeset/slow-moons-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rosen-bridge/guard-app': patch
---

Restructure modules to use named exports, enhancing clarity and consistency
4 changes: 1 addition & 3 deletions apps/guard/app/(dashboard)/@actions/SendForSigningForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface Form {
/**
* render a form for signing a tx
*/
const SendForSigningForm = () => {
export const SendForSigningForm = () => {
const { apiKey } = useApiKey();

const {
Expand Down Expand Up @@ -198,5 +198,3 @@ const SendForSigningForm = () => {
</FullCard>
);
};

export default SendForSigningForm;
4 changes: 1 addition & 3 deletions apps/guard/app/(dashboard)/@actions/TabPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface TabPanelProps {
* @param in
* @param children
*/
const TabPanel = ({ in: isIn, children }: TabPanelProps) => {
export const TabPanel = ({ in: isIn, children }: TabPanelProps) => {
return (
<Slide
direction="up"
Expand All @@ -28,5 +28,3 @@ const TabPanel = ({ in: isIn, children }: TabPanelProps) => {
</Slide>
);
};

export default TabPanel;
4 changes: 2 additions & 2 deletions apps/guard/app/(dashboard)/@actions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {
useResponsiveValue,
} from '@rosen-bridge/ui-kit';

import SendForSigningForm from './SendForSigningForm';
import TabPanel from './TabPanel';
import { SendForSigningForm } from './SendForSigningForm';
import { TabPanel } from './TabPanel';

/**
* render root of page
Expand Down
4 changes: 1 addition & 3 deletions apps/guard/app/(dashboard)/@infoWidgets/HealthWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const HealthWidgetBase = styled(Card)<HealthWidgetBaseProps>(
/**
* render a widget showing health status or a pending indicator
*/
const HealthWidget = () => {
export const HealthWidget = () => {
const { data: info, isLoading } = useSWR<ApiInfoResponse>('/info', fetcher);

return (
Expand Down Expand Up @@ -89,5 +89,3 @@ const HealthWidget = () => {
</HealthWidgetBase>
);
};

export default HealthWidget;
6 changes: 2 additions & 4 deletions apps/guard/app/(dashboard)/@infoWidgets/WalletWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React from 'react';
import { CopyToClipboard } from 'react-copy-to-clipboard';

import { Copy, QrcodeScan } from '@rosen-bridge/icons';
Expand Down Expand Up @@ -92,7 +92,7 @@ interface WalletWidgetProps {
* @param color
* @param isLoading
*/
const WalletWidget = ({
export const WalletWidget = ({
title,
tokenInfoWithAddresses,
color,
Expand Down Expand Up @@ -194,5 +194,3 @@ const WalletWidget = ({
</WalletWidgetBase>
);
};

export default WalletWidget;
4 changes: 2 additions & 2 deletions apps/guard/app/(dashboard)/@infoWidgets/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import useSWR from 'swr';
import { Stack } from '@rosen-bridge/ui-kit';
import { fetcher } from '@rosen-ui/swr-helpers';

import HealthWidget from './HealthWidget';
import WalletWidget from './WalletWidget';
import { HealthWidget } from './HealthWidget';
import { WalletWidget } from './WalletWidget';

import { ApiInfoResponse } from '@/_types/api';

Expand Down
4 changes: 1 addition & 3 deletions apps/guard/app/(dashboard)/@revenue/PeriodSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface PeriodSelectProps {
* @param period
* @param setPeriod
*/
const PeriodSelect = ({ period, setPeriod }: PeriodSelectProps) => {
export const PeriodSelect = ({ period, setPeriod }: PeriodSelectProps) => {
const [anchorElement, setAnchorElement] = useState<HTMLButtonElement | null>(
null,
);
Expand Down Expand Up @@ -84,5 +84,3 @@ const PeriodSelect = ({ period, setPeriod }: PeriodSelectProps) => {
</Box>
);
};

export default PeriodSelect;
4 changes: 1 addition & 3 deletions apps/guard/app/(dashboard)/@revenue/RevenueChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ interface RevenueChartProps {
* @param period
* @param data
*/
const RevenueChart = ({ period, data }: RevenueChartProps) => {
export const RevenueChart = ({ period, data }: RevenueChartProps) => {
const theme = useTheme();

const reversedData = useMemo(
Expand Down Expand Up @@ -137,5 +137,3 @@ const RevenueChart = ({ period, data }: RevenueChartProps) => {
/>
);
};

export default RevenueChart;
4 changes: 1 addition & 3 deletions apps/guard/app/(dashboard)/@revenue/RevenueChartSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { Skeleton } from '@rosen-bridge/ui-kit';
/**
* render a skeleton element for `RevenueChart`
*/
const RevenueChartSkeleton = () => (
export const RevenueChartSkeleton = () => (
<Skeleton animation="wave" height={240} width="100%" />
);

export default RevenueChartSkeleton;
9 changes: 6 additions & 3 deletions apps/guard/app/(dashboard)/@revenue/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ import { FullCard } from '@rosen-bridge/ui-kit';
import { fetcher } from '@rosen-ui/swr-helpers';
import { ChartPeriod } from '@rosen-ui/types';

import PeriodSelect from './PeriodSelect';
import RevenueChartSkeleton from './RevenueChartSkeleton';
import { PeriodSelect } from './PeriodSelect';
import { RevenueChartSkeleton } from './RevenueChartSkeleton';

import { ApiRevenueChartResponse } from '@/_types/api';

/**
* This is required because revenue chart cannot be pre-rendered in next and
* throws an error
*/
const RevenueChart = dynamic(() => import('./RevenueChart'), { ssr: false });
const RevenueChart = dynamic(
() => import('./RevenueChart').then((mod) => mod.RevenueChart),
{ ssr: false },
);

const Revenue = () => {
const [period, setPeriod] = useState<ChartPeriod>('week');
Expand Down
10 changes: 4 additions & 6 deletions apps/guard/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import {
CssBaseline,
ThemeProvider,
} from '@rosen-bridge/ui-kit';
import SWRConfig from '@rosen-ui/swr-mock';
import { SWRConfig } from '@rosen-ui/swr-mock';

import { SideBar } from './SideBar';
import Toolbar from './Toolbar';
import { Toolbar } from './Toolbar';

import { theme } from '@/_theme/theme';

import { ApiKeyContextProvider } from '@rosen-bridge/shared-contexts';

import mockedData from './_mock/mockedData';
import { mockedData } from './_mock/mockedData';

const Root = styled('div')(({ theme }) => ({
width: '100vw',
Expand Down Expand Up @@ -65,7 +65,7 @@ interface AppProps {
children?: React.ReactNode;
}

const App = ({ children }: AppProps) => {
export const App = ({ children }: AppProps) => {
return (
<NoSsr>
<ThemeProvider theme={theme}>
Expand Down Expand Up @@ -95,5 +95,3 @@ const App = ({ children }: AppProps) => {
</NoSsr>
);
};

export default App;
2 changes: 1 addition & 1 deletion apps/guard/app/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@rosen-bridge/icons';
import { AppBar, AppLogo } from '@rosen-bridge/ui-kit';

import useInfo from './_hooks/useInfo';
import { useInfo } from './_hooks/useInfo';

import packageJson from '../package.json';

Expand Down
4 changes: 1 addition & 3 deletions apps/guard/app/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const pageTitleMap: Record<string, string> = {
/**
* render toolbar containing page title and some actions
*/
const Toolbar = () => {
export const Toolbar = () => {
const page = useSelectedLayoutSegment();

return (
Expand All @@ -35,5 +35,3 @@ const Toolbar = () => {
/>
);
};

export default Toolbar;
2 changes: 1 addition & 1 deletion apps/guard/app/_hooks/useAddresses.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from 'react';
import { Network } from '@rosen-ui/types';

import useInfo from './useInfo';
import { useInfo } from './useInfo';

type Addresses = {
[key in 'cold' | 'hot']: {
Expand Down
4 changes: 1 addition & 3 deletions apps/guard/app/_hooks/useInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ import { ApiInfoResponse } from '@/_types/api';
/**
* wrap useSWR for fetching info api
*/
const useInfo = () => useSWR<ApiInfoResponse>('/info', fetcher);

export default useInfo;
export const useInfo = () => useSWR<ApiInfoResponse>('/info', fetcher);
5 changes: 1 addition & 4 deletions apps/guard/app/_mock/mockedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
ApiSignResponse,
ApiEventResponse as ApiOngoingEventResponse,
ApiHistoryResponse as ApiHistoryEventResponse,
EventBase,
HistoryEvent,
OngoingEvent,
} from '@/_types/api';
Expand Down Expand Up @@ -392,7 +391,7 @@ const history: ApiHistoryEventResponse = {
items: generateHistoryEventRecords(100),
};

const mockedData: SWRConfigProps['fakeData'] = {
export const mockedData: SWRConfigProps['fakeData'] = {
withStringKeys: {
'/info': info,
'/revenue/chart': revenueChart,
Expand Down Expand Up @@ -439,5 +438,3 @@ const mockedData: SWRConfigProps['fakeData'] = {
},
},
};

export default mockedData;
4 changes: 1 addition & 3 deletions apps/guard/app/assets/TableSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface TableSkeletonProps {
numberOfItems: number;
}

const TableSkeleton: FC<TableSkeletonProps> = (props) => {
export const TableSkeleton: FC<TableSkeletonProps> = (props) => {
const renderMobileRow = useCallback(
() => (
<TableRow>
Expand Down Expand Up @@ -65,5 +65,3 @@ const TableSkeleton: FC<TableSkeletonProps> = (props) => {
/>
);
};

export default TableSkeleton;
2 changes: 1 addition & 1 deletion apps/guard/app/assets/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@rosen-bridge/ui-kit';

import { MobileRow, TabletRow, mobileHeader, tabletHeader } from './TableRow';
import TableSkeleton from './TableSkeleton';
import { TableSkeleton } from './TableSkeleton';

import { ApiAddressAssetsResponse, GuardTokenInfo } from '@/_types/api';

Expand Down
4 changes: 1 addition & 3 deletions apps/guard/app/events/TableSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface TableSkeletonProps {
numberOfItems: number;
}

const TableSkeleton: FC<TableSkeletonProps> = (props) => {
export const TableSkeleton: FC<TableSkeletonProps> = (props) => {
const renderMobileRow = useCallback(
() => (
<TableRow>
Expand Down Expand Up @@ -65,5 +65,3 @@ const TableSkeleton: FC<TableSkeletonProps> = (props) => {
/>
);
};

export default TableSkeleton;
2 changes: 1 addition & 1 deletion apps/guard/app/events/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@rosen-bridge/ui-kit';

import { MobileRow, TabletRow, mobileHeader, tabletHeader } from './TableRow';
import TableSkeleton from './TableSkeleton';
import { TableSkeleton } from './TableSkeleton';

import { ApiEventResponse, OngoingEvent } from '@/_types/api';

Expand Down
4 changes: 1 addition & 3 deletions apps/guard/app/history/TableSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface TableSkeletonProps {
numberOfItems: number;
}

const TableSkeleton: FC<TableSkeletonProps> = (props) => {
export const TableSkeleton: FC<TableSkeletonProps> = (props) => {
const renderMobileRow = useCallback(
() => (
<TableRow>
Expand Down Expand Up @@ -65,5 +65,3 @@ const TableSkeleton: FC<TableSkeletonProps> = (props) => {
/>
);
};

export default TableSkeleton;
2 changes: 1 addition & 1 deletion apps/guard/app/history/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@rosen-bridge/ui-kit';

import { MobileRow, TabletRow, mobileHeader, tabletHeader } from './TableRow';
import TableSkeleton from './TableSkeleton';
import { TableSkeleton } from './TableSkeleton';

import { ApiHistoryResponse, HistoryEvent } from '@/_types/api';

Expand Down
2 changes: 1 addition & 1 deletion apps/guard/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Metadata } from 'next';

import App from './App';
import { App } from './App';

export const metadata: Metadata = {
title: 'Rosen Guard',
Expand Down
4 changes: 1 addition & 3 deletions apps/guard/app/revenues/TableSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface TableSkeletonProps {
numberOfItems: number;
}

const TableSkeleton: FC<TableSkeletonProps> = (props) => {
export const TableSkeleton: FC<TableSkeletonProps> = (props) => {
const renderMobileRow = useCallback(
() => (
<TableRow>
Expand Down Expand Up @@ -65,5 +65,3 @@ const TableSkeleton: FC<TableSkeletonProps> = (props) => {
/>
);
};

export default TableSkeleton;
2 changes: 1 addition & 1 deletion apps/guard/app/revenues/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@rosen-bridge/ui-kit';

import { MobileRow, TabletRow, mobileHeader, tabletHeader } from './TableRow';
import TableSkeleton from './TableSkeleton';
import { TableSkeleton } from './TableSkeleton';

import { ApiRevenueResponse, Revenue } from '@/_types/api';

Expand Down
2 changes: 1 addition & 1 deletion apps/watcher/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import React, { useEffect } from 'react';
import SWRConfig from '@rosen-ui/swr-mock';
import { SWRConfig } from '@rosen-ui/swr-mock';

/**
* FIXME: import NoSsr from ui-kit
Expand Down
Loading

0 comments on commit da29ec3

Please sign in to comment.