From e0d3bc4ba4c625aba05687c78512a6eb9bffa92e Mon Sep 17 00:00:00 2001 From: roshni73 Date: Tue, 9 Apr 2024 15:36:08 +0545 Subject: [PATCH] Add Carts and statice data for view all source --- src/App/routes.tsx | 9 +++ src/views/AlertMap/index.tsx | 2 +- src/views/ViewAllSource/SourceCard/i18n.json | 7 +++ src/views/ViewAllSource/SourceCard/index.tsx | 60 +++++++++++++++++++ .../SourceCard/styles.module.css | 37 ++++++++++++ src/views/ViewAllSource/i18n.json | 6 ++ src/views/ViewAllSource/index.tsx | 54 +++++++++++++++++ 7 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 src/views/ViewAllSource/SourceCard/i18n.json create mode 100644 src/views/ViewAllSource/SourceCard/index.tsx create mode 100644 src/views/ViewAllSource/SourceCard/styles.module.css create mode 100644 src/views/ViewAllSource/i18n.json create mode 100644 src/views/ViewAllSource/index.tsx diff --git a/src/App/routes.tsx b/src/App/routes.tsx index 62c5e92a..fb560d99 100644 --- a/src/App/routes.tsx +++ b/src/App/routes.tsx @@ -50,10 +50,19 @@ const preferences = myWrapRoute({ parent: root, }); +const viewAllSource = myWrapRoute({ + title: 'ViewAllSource', + path: 'view-all-source', + component: () => import('#views/ViewAllSource'), + componentProps: {}, + parent: root, +}); + export const wrappedRoutes = { root, home, preferences, + viewAllSource, }; export const unwrappedRoutes = unwrapRoute(Object.values(wrappedRoutes)); diff --git a/src/views/AlertMap/index.tsx b/src/views/AlertMap/index.tsx index 1d256356..7c782a7e 100644 --- a/src/views/AlertMap/index.tsx +++ b/src/views/AlertMap/index.tsx @@ -41,7 +41,7 @@ function OngoingAlertMap(props: Props) { actions={( {strings.mapViewAllSources} diff --git a/src/views/ViewAllSource/SourceCard/i18n.json b/src/views/ViewAllSource/SourceCard/i18n.json new file mode 100644 index 00000000..f31e1d97 --- /dev/null +++ b/src/views/ViewAllSource/SourceCard/i18n.json @@ -0,0 +1,7 @@ +{ + "namespace": "source card", + "strings": { + "languageTitle":"language", + "sourceCardLastUpdated":"Date" + } +} \ No newline at end of file diff --git a/src/views/ViewAllSource/SourceCard/index.tsx b/src/views/ViewAllSource/SourceCard/index.tsx new file mode 100644 index 00000000..be1142bb --- /dev/null +++ b/src/views/ViewAllSource/SourceCard/index.tsx @@ -0,0 +1,60 @@ +import { + Button, + Container, + TextOutput, +} from '@ifrc-go/ui'; +import { useTranslation } from '@ifrc-go/ui/hooks'; + +import i18n from './i18n.json'; +import styles from './styles.module.css'; + +interface Props { + className?: string; +} + +interface FeedData { + logo: string; + name: string; + language: string; +} +interface Props { + className?: string; + feedData: FeedData; +} + +function SourceCard(props: Props) { + const { className, feedData } = props; + const strings = useTranslation(i18n); + return ( + +
+ Logo +
+
{feedData.name}
+ + +
+
+ + )} + headingLevel={4} + withInternalPadding + withHeaderBorder + withoutWrapInHeading + /> + ); +} +export default SourceCard; diff --git a/src/views/ViewAllSource/SourceCard/styles.module.css b/src/views/ViewAllSource/SourceCard/styles.module.css new file mode 100644 index 00000000..c5bd5b0f --- /dev/null +++ b/src/views/ViewAllSource/SourceCard/styles.module.css @@ -0,0 +1,37 @@ +.view-all-source{ + border-radius: var(--go-ui-border-radius-lg); + box-shadow: var(--go-ui-box-shadow-md); + + .severity-indicator { + font-size: var(--go-ui-font-size-xl); + } + + .last-updated { + color: var(--go-ui-color-text-light); + } + + .figures { + display: flex; + flex-grow: 1; + gap: var(--go-ui-spacing-lg); + + .separator { + flex-shrink: 0; + background-color: var(--go-ui-color-separator); + width: var(--go-ui-width-separator-sm); + } + + .figure { + flex-basis: 0; + flex-grow: 1; + padding: 0; + } + } + } + .flexContainer { + display: flex; + align-items: center; + justify-content: space-between; + } + + \ No newline at end of file diff --git a/src/views/ViewAllSource/i18n.json b/src/views/ViewAllSource/i18n.json new file mode 100644 index 00000000..ffd8156a --- /dev/null +++ b/src/views/ViewAllSource/i18n.json @@ -0,0 +1,6 @@ +{ + "namespace": "viewAllSource", + "strings": { + "viewAllSourceHeading": "View All Sources" + } +} \ No newline at end of file diff --git a/src/views/ViewAllSource/index.tsx b/src/views/ViewAllSource/index.tsx new file mode 100644 index 00000000..9b2df247 --- /dev/null +++ b/src/views/ViewAllSource/index.tsx @@ -0,0 +1,54 @@ +import { + gql, + useQuery, +} from '@apollo/client'; +import { Container } from '@ifrc-go/ui'; + +import SourceCard from './SourceCard'; + +const SOURCE_FEEDS = gql` + query SourceFeeds($pagination: OffsetPaginationInput) { + public { + feeds(pagination: $pagination) { + limit + offset + items { + languages { + logo + name + language + } + } + } + } + }`; + +type Source = { + id: number; + logo: string; + name: string + sourceName: string; + lastUpdated: string; + language: string; +}; + +// eslint-disable-next-line import/prefer-default-export +export function Component() { + const { data } = useQuery(SOURCE_FEEDS, { + variables: { + pagination: { + limit: 10, + offset: 0, + }, + }, + }); + return ( + + {data.feeds.map((datum: Source) => ( + + ))} + + ); +} + +Component.displayName = 'ViewAllSource';