Skip to content

Commit

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

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

Closes #430

See merge request ergo/rosen-bridge/ui!357
  • Loading branch information
vorujack committed Nov 19, 2024
2 parents 1890323 + 0cf233b commit 67d9847
Show file tree
Hide file tree
Showing 40 changed files with 73 additions and 106 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-apples-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rosen-bridge/watcher-app': patch
---

Update the modules to utilize named exports, enhancing maintainability and aligning with our policy to ensure greater consistency
2 changes: 1 addition & 1 deletion apps/watcher/app/(home)/@actions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@rosen-bridge/icons';
import { FullCard, SvgIcon } from '@rosen-bridge/ui-kit';

import HomeActionButton from '@/_components/HomeActionButton';
import { HomeActionButton } from '@/_components/HomeActionButton';

const Actions = () => {
return (
Expand Down
4 changes: 1 addition & 3 deletions apps/watcher/app/(home)/@address/AddressSkeleton.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 address section of home page
*/
const AddressSkeleton = () => (
export const AddressSkeleton = () => (
<Skeleton animation="wave" height={60} width="100%" />
);

export default AddressSkeleton;
4 changes: 1 addition & 3 deletions apps/watcher/app/(home)/@address/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface CopyButtonProps {
*
* @param address
*/
const CopyButton = ({ address }: CopyButtonProps) => {
export const CopyButton = ({ address }: CopyButtonProps) => {
const [open, setOpen] = React.useState(false);

const handleClose = (
Expand All @@ -43,5 +43,3 @@ const CopyButton = ({ address }: CopyButtonProps) => {
</>
);
};

export default CopyButton;
4 changes: 1 addition & 3 deletions apps/watcher/app/(home)/@address/QrCodeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface QrCodeButtonProps {
* provided address when clicked
* @param address
*/
const QrCodeButton = ({ address }: QrCodeButtonProps) => {
export const QrCodeButton = ({ address }: QrCodeButtonProps) => {
const [open, setOpen] = React.useState(false);

const handleOpen = () => setOpen(true);
Expand All @@ -28,5 +28,3 @@ const QrCodeButton = ({ address }: QrCodeButtonProps) => {
</>
);
};

export default QrCodeButton;
6 changes: 3 additions & 3 deletions apps/watcher/app/(home)/@address/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import useSWR from 'swr';
import { Box, Card, FullCard, Grid, Typography } from '@rosen-bridge/ui-kit';
import { fetcher } from '@rosen-ui/swr-helpers';

import AddressSkeleton from './AddressSkeleton';
import CopyButton from './CopyButton';
import QrCodeButton from './QrCodeButton';
import { AddressSkeleton } from './AddressSkeleton';
import { CopyButton } from './CopyButton';
import { QrCodeButton } from './QrCodeButton';

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

Expand Down
4 changes: 1 addition & 3 deletions apps/watcher/app/(home)/@infoWidgets/InfoWidgetCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ interface InfoWidgetCardProps {
* @param unit
* @param value
*/
const InfoWidgetCard = ({
export const InfoWidgetCard = ({
color = 'secondary',
icon,
isLoading,
Expand Down Expand Up @@ -125,5 +125,3 @@ const InfoWidgetCard = ({
</InfoWidgetCardBase>
);
};

export default InfoWidgetCard;
10 changes: 5 additions & 5 deletions apps/watcher/app/(home)/@infoWidgets/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import {
ShieldExclamation,
Wallet,
} from '@rosen-bridge/icons';
import { Box, Grid, SvgIcon, Typography } from '@rosen-bridge/ui-kit';
import { Box, Grid, SvgIcon } from '@rosen-bridge/ui-kit';
import { healthStatusColorMap } from '@rosen-ui/constants';
import { fetcher } from '@rosen-ui/swr-helpers';
import { AugmentedPalette } from '@rosen-ui/types';
import { getDecimalString } from '@rosen-ui/utils';

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

import useRsnToken from '@/_hooks/useRsnToken';
import useERsnToken from '@/_hooks/useERsnToken';
import useToken from '@/_hooks/useToken';
import { useRsnToken } from '@/_hooks/useRsnToken';
import { useERsnToken } from '@/_hooks/useERsnToken';
import { useToken } from '@/_hooks/useToken';

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

Expand Down
4 changes: 1 addition & 3 deletions apps/watcher/app/(home)/@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/watcher/app/(home)/@revenue/RevenueChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,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 @@ -138,5 +138,3 @@ const RevenueChart = ({ period, data }: RevenueChartProps) => {
/>
);
};

export default RevenueChart;
4 changes: 1 addition & 3 deletions apps/watcher/app/(home)/@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/watcher/app/(home)/@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/watcher/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import {
import { ApiKeyContextProvider } from '@rosen-bridge/shared-contexts';

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

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

import mockedData from './_mock/mockedData';
import useInfo from './_hooks/useInfo';
import { mockedData } from './_mock/mockedData';
import { useInfo } from './_hooks/useInfo';
import { upperFirst } from 'lodash-es';

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

const App = ({ children }: AppProps) => {
export const App = ({ children }: AppProps) => {
const { data: info } = useInfo();

/**
Expand Down Expand Up @@ -126,5 +126,3 @@ const App = ({ children }: AppProps) => {
</NoSsr>
);
};

export default App;
2 changes: 1 addition & 1 deletion apps/watcher/app/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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/watcher/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;
4 changes: 1 addition & 3 deletions apps/watcher/app/_components/HomeActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ interface HomeActionButtonProps {
* @param action
* @param disabled
*/
const HomeActionButton = ({
export const HomeActionButton = ({
label,
icon,
action,
Expand All @@ -66,5 +66,3 @@ const HomeActionButton = ({
</HomeActionButtonBase>
);
};

export default HomeActionButton;
6 changes: 2 additions & 4 deletions apps/watcher/app/_hooks/useERsnToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import useSWR from 'swr';

import { fetcher } from '@rosen-ui/swr-helpers';

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

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

/**
* fetch ersn token info (if present)
*/
const useERsnToken = () => {
export const useERsnToken = () => {
const { data: info, isLoading: isInfoLoading } = useSWR<ApiInfoResponse>(
'/info',
fetcher,
Expand All @@ -24,5 +24,3 @@ const useERsnToken = () => {
isLoading: isInfoLoading || isERsnInfoLoading,
};
};

export default useERsnToken;
4 changes: 1 addition & 3 deletions apps/watcher/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);
6 changes: 2 additions & 4 deletions apps/watcher/app/_hooks/useRsnToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import useSWR from 'swr';

import { fetcher } from '@rosen-ui/swr-helpers';

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

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

/**
* fetch rsn token info (if present)
*/
const useRsnToken = () => {
export const useRsnToken = () => {
const { data: info, isLoading: isInfoLoading } = useSWR<ApiInfoResponse>(
'/info',
fetcher,
Expand All @@ -24,5 +24,3 @@ const useRsnToken = () => {
isLoading: isInfoLoading || isRsnInfoLoading,
};
};

export default useRsnToken;
4 changes: 1 addition & 3 deletions apps/watcher/app/_hooks/useToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ApiAddressAssetsResponse } from '@/_types/api';
/**
* fetch a token info (if present)
*/
const useToken = (tokenId: string | undefined) => {
export const useToken = (tokenId: string | undefined) => {
const { data, isLoading } = useSWR<ApiAddressAssetsResponse>(
tokenId
? [
Expand All @@ -25,5 +25,3 @@ const useToken = (tokenId: string | undefined) => {
isLoading,
};
};

export default useToken;
4 changes: 1 addition & 3 deletions apps/watcher/app/_mock/mockedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ const events: ApiEventResponse = {
items: generateEventRecords(100),
};

const mockedData: SWRConfigProps['fakeData'] = {
export const mockedData: SWRConfigProps['fakeData'] = {
withStringKeys: {
'/info': info,
'/health/status': healthStatus,
Expand Down Expand Up @@ -429,5 +429,3 @@ const mockedData: SWRConfigProps['fakeData'] = {
},
},
};

export default mockedData;
9 changes: 5 additions & 4 deletions apps/watcher/app/actions/@form/lock/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ import {
getTxURL,
} from '@rosen-ui/utils';

import ConfirmationModal from '../../ConfirmationModal';
import TokenAmountTextField, {
import { ConfirmationModal } from '../../ConfirmationModal';
import {
TokenAmountTextField,
TokenAmountCompatibleFormSchema,
} from '../../TokenAmountTextField';

import { Alert } from '@rosen-bridge/icons';

import { useApiKey } from '@rosen-bridge/shared-contexts';
import useRsnToken from '@/_hooks/useRsnToken';
import useToken from '@/_hooks/useToken';
import { useRsnToken } from '@/_hooks/useRsnToken';
import { useToken } from '@/_hooks/useToken';

import {
ApiPermitRequestBody,
Expand Down
7 changes: 4 additions & 3 deletions apps/watcher/app/actions/@form/unlock/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ import { getNonDecimalString } from '@rosen-ui/utils';

import { Alert } from '@rosen-bridge/icons';

import ConfirmationModal from '../../ConfirmationModal';
import TokenAmountTextField, {
import { ConfirmationModal } from '../../ConfirmationModal';
import {
TokenAmountTextField,
TokenAmountCompatibleFormSchema,
} from '../../TokenAmountTextField';

import { useApiKey } from '@rosen-bridge/shared-contexts';
import useRsnToken from '@/_hooks/useRsnToken';
import { useRsnToken } from '@/_hooks/useRsnToken';

import {
ApiInfoResponse,
Expand Down
7 changes: 4 additions & 3 deletions apps/watcher/app/actions/@form/withdraw/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ import { getNonDecimalString } from '@rosen-ui/utils';

import { Alert } from '@rosen-bridge/icons';

import ConfirmationModal from '../../ConfirmationModal';
import TokenAmountTextField, {
import { ConfirmationModal } from '../../ConfirmationModal';
import {
TokenAmountTextField,
TokenAmountCompatibleFormSchema,
} from '../../TokenAmountTextField';

import useToken from '@/_hooks/useToken';
import { useToken } from '@/_hooks/useToken';
import { useApiKey } from '@rosen-bridge/shared-contexts';

import {
Expand Down
6 changes: 3 additions & 3 deletions apps/watcher/app/actions/@text/lock/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { CircularProgress, Typography } from '@rosen-bridge/ui-kit';
import { fetcher } from '@rosen-ui/swr-helpers';
import { getDecimalString } from '@rosen-ui/utils';

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

import useToken from '@/_hooks/useToken';
import useRsnToken from '@/_hooks/useRsnToken';
import { useToken } from '@/_hooks/useToken';
import { useRsnToken } from '@/_hooks/useRsnToken';

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

Expand Down
Loading

0 comments on commit 67d9847

Please sign in to comment.