Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): add info card #16931

Merged
merged 53 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
2991578
feat: init
thorkellmani Nov 18, 2024
bffca01
feat: stfuf
thorkellmani Nov 18, 2024
c31e2e4
fix:error message
thorkellmani Nov 19, 2024
c691abc
fix: merge
thorkellmani Nov 27, 2024
35efc7d
fix: responseive
thorkellmani Nov 27, 2024
94a8575
fix: switch in inline
thorkellmani Nov 27, 2024
ea88272
fix: use wrapper
thorkellmani Nov 27, 2024
55ae166
fix: add layout switch
thorkellmani Nov 28, 2024
f2bba67
fix: disable tags
thorkellmani Nov 28, 2024
ca42520
Merge branch 'main' into feat/add-info-card
thorkellmani Dec 3, 2024
be27cbe
fix: make whole card clickable
thorkellmani Dec 3, 2024
c28ada2
chore: reduce columns
thorkellmani Dec 3, 2024
0f766cb
feat: updated status logic
thorkellmani Dec 4, 2024
b9bdb0e
feat: add time values
thorkellmani Dec 4, 2024
1507cab
feat: add time part
thorkellmani Dec 4, 2024
51e8a4a
Merge branch 'main' into feat/add-info-card
thorkellmani Dec 4, 2024
b3ce418
Merge branch 'main' into feat/add-info-card
thorkellmani Dec 4, 2024
ec8e7b8
chore: change props name
thorkellmani Dec 4, 2024
1eb0cb0
Merge remote-tracking branch 'refs/remotes/origin/feat/add-info-card'…
thorkellmani Dec 4, 2024
c11145c
chore: remove conidtional
thorkellmani Dec 4, 2024
859964a
chore: remove imports
thorkellmani Dec 4, 2024
9ec4527
fix: wrong message id
thorkellmani Dec 4, 2024
3301830
fix: add /en locale
thorkellmani Dec 11, 2024
50c504d
Merge branch 'main' into feat/updated-stats-logic
thorkellmani Dec 11, 2024
f80f403
Merge branch 'main' into feat/add-info-card
thorkellmani Dec 11, 2024
dfb70bd
Merge branch 'main' into feat/updated-stats-logic
thorkellmani Dec 12, 2024
e907c68
fix: merge
thorkellmani Dec 12, 2024
b8fd9c9
fix: undefined if empty array
thorkellmani Dec 12, 2024
569651a
Merge branch 'main' into feat/add-info-card
thorkellmani Dec 12, 2024
e2080c6
Merge branch 'main' into feat/updated-stats-logic
thorkellmani Dec 12, 2024
e2a0b6a
feat: multiple updates
thorkellmani Dec 12, 2024
d156f3c
chore: simplify card
thorkellmani Dec 12, 2024
5fd3723
chore: fix color
thorkellmani Dec 12, 2024
a074747
feat :merge main
thorkellmani Dec 13, 2024
fbd44a7
fix: simplify card
thorkellmani Dec 13, 2024
988622d
fix: increase border radius
thorkellmani Dec 13, 2024
ac6c4a5
fix: bunny comments
thorkellmani Dec 13, 2024
e88a631
fix: add key
thorkellmani Dec 13, 2024
dd46439
fix: something
thorkellmani Dec 13, 2024
373baa2
chore: fix codeowners
thorkellmani Dec 13, 2024
f1738a3
chore: CODEOWNERS indentation
thorkellmani Dec 13, 2024
eb12523
Merge branch 'main' into feat/add-info-card
thorkellmani Dec 16, 2024
d750a44
feat: update pagination
thorkellmani Dec 16, 2024
c0aa942
chore: fix
thorkellmani Dec 16, 2024
bff6859
chore: fix nr2
thorkellmani Dec 16, 2024
60d1df1
feat: PAGED
thorkellmani Dec 16, 2024
5d3ee1a
fix: merge
thorkellmani Dec 16, 2024
21d9f1d
chore: codeowners
thorkellmani Dec 16, 2024
d68ca8a
chore: remove improts
thorkellmani Dec 16, 2024
a7fef90
chore: revert
thorkellmani Dec 16, 2024
bc14e37
fix: review comments
thorkellmani Dec 17, 2024
2ce88fa
Merge branch 'main' into feat/add-info-card
kodiakhq[bot] Dec 17, 2024
a08e450
Merge branch 'main' into feat/add-info-card
kodiakhq[bot] Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ codemagic.yaml
/apps/services/regulations-admin-backend/ @island-is/hugsmidjan
/apps/services/user-profile/ @island-is/hugsmidjan @island-is/juni @island-is/aranja
/apps/web/components/Grant/ @island-is/hugsmidjan
/apps/web/components/PlazaCard/ @island-is/hugsmidjan
/apps/web/screens/Grants/ @island-is/hugsmidjan
/apps/web/screens/Regulations/ @island-is/hugsmidjan
/apps/web/components/Regulations/ @island-is/hugsmidjan
Expand Down
5 changes: 0 additions & 5 deletions apps/web/components/PlazaCard/PlazaCard.css.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/web/components/real.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/

export * from './Card/Card'
export * from './PlazaCard/PlazaCard'
export * from './Header/Header'
export * from './SearchInput/SearchInput'
export * from './LanguageToggler/LanguageToggler'
Expand Down
1 change: 0 additions & 1 deletion apps/web/screens/Grants/Grant/GrantSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
Stack,
Text,
} from '@island.is/island-ui/core'
import { useLocale } from '@island.is/localization'
import { Locale } from '@island.is/shared/types'
import { isDefined } from '@island.is/shared/utils'
import { InstitutionPanel } from '@island.is/web/components'
Expand Down
69 changes: 54 additions & 15 deletions apps/web/screens/Grants/SearchResults/SearchResults.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useMemo, useState } from 'react'
import { ReactNode, useCallback, useEffect, useMemo, useState } from 'react'
import { useIntl } from 'react-intl'
import { useWindowSize } from 'react-use'
import debounce from 'lodash/debounce'
Expand All @@ -16,6 +16,7 @@ import {
BreadCrumbItem,
Breadcrumbs,
FilterInput,
Pagination,
Text,
} from '@island.is/island-ui/core'
import { theme } from '@island.is/island-ui/theme'
Expand Down Expand Up @@ -55,9 +56,11 @@ export interface SearchState {
organization?: Array<string>
}

const PAGE_SIZE = 8

const GrantsSearchResultsPage: CustomScreen<GrantsHomeProps> = ({
locale,
initialGrants,
initialGrantList,
tags,
}) => {
const { formatMessage } = useIntl()
Expand All @@ -67,7 +70,12 @@ const GrantsSearchResultsPage: CustomScreen<GrantsHomeProps> = ({
const parentUrl = linkResolver('styrkjatorg', [], locale).href
const currentUrl = linkResolver('styrkjatorgsearch', [], locale).href

const [grants, setGrants] = useState<Array<Grant>>(initialGrants ?? [])
const [grants, setGrants] = useState<Array<Grant>>(
initialGrantList?.items ?? [],
)
const [totalHits, setTotalHits] = useState<number | undefined>(
initialGrantList?.total ?? 0,
)
const [searchState, setSearchState] = useState<SearchState>()
const [initialRender, setInitialRender] = useState<boolean>(true)

Expand All @@ -89,7 +97,7 @@ const GrantsSearchResultsPage: CustomScreen<GrantsHomeProps> = ({
const organizations = searchParams.getAll('organization')

setSearchState({
page: page ? Number.parseInt(page) : undefined,
page: page ? Number.parseInt(page) : 1,
query: searchParams.get('query') ?? undefined,
status: statuses.length ? statuses : undefined,
category: categories.length ? categories : undefined,
Expand All @@ -98,6 +106,13 @@ const GrantsSearchResultsPage: CustomScreen<GrantsHomeProps> = ({
})
}, [])

const totalPages = useMemo(() => {
if (!totalHits) {
return
}
return totalHits > PAGE_SIZE ? Math.ceil(totalHits / PAGE_SIZE) : 1
}, [totalHits])

const updateUrl = useCallback(() => {
if (!searchState) {
return
Expand Down Expand Up @@ -134,7 +149,7 @@ const GrantsSearchResultsPage: CustomScreen<GrantsHomeProps> = ({
organizations: searchState?.organization,
page: searchState?.page,
search: searchState?.query,
size: 8,
size: PAGE_SIZE,
statuses: searchState?.status,
types: searchState?.type,
},
Expand All @@ -143,6 +158,7 @@ const GrantsSearchResultsPage: CustomScreen<GrantsHomeProps> = ({
.then((res) => {
if (res.data) {
setGrants(res.data.getGrants.items)
setTotalHits(res.data.getGrants.total)
} else if (res.error) {
setGrants([])
console.error('Error fetching grants', res.error)
Expand Down Expand Up @@ -199,7 +215,7 @@ const GrantsSearchResultsPage: CustomScreen<GrantsHomeProps> = ({

const onResetFilter = () => {
setSearchState({
page: undefined,
page: 1,
query: undefined,
status: undefined,
category: undefined,
Expand All @@ -210,18 +226,18 @@ const GrantsSearchResultsPage: CustomScreen<GrantsHomeProps> = ({
}

const hitsMessage = useMemo(() => {
if (!grants) {
if (!totalHits) {
return
}
if (grants.length === 1) {
if (totalHits === 1) {
return formatMessage(m.search.resultFound, {
arg: <strong>{grants.length}</strong>,
arg: <strong>{totalHits}</strong>,
})
}
return formatMessage(m.search.resultsFound, {
arg: <strong>{grants.length}</strong>,
arg: <strong>{totalHits}</strong>,
})
}, [formatMessage, grants])
}, [formatMessage, totalHits])

return (
<GrantWrapper
Expand Down Expand Up @@ -290,6 +306,28 @@ const GrantsSearchResultsPage: CustomScreen<GrantsHomeProps> = ({
locale={locale}
/>
</Box>
{totalPages && totalPages > 1 ? (
<Box marginTop={2} marginBottom={0}>
<Pagination
variant="purple"
page={searchState?.page ?? 1}
itemsPerPage={PAGE_SIZE}
totalItems={totalHits}
totalPages={totalPages}
renderLink={(page, className, children) => (
<Box
cursor="pointer"
className={className}
onClick={() => {
updateSearchStateValue('page', page)
}}
>
{children}
</Box>
)}
/>
</Box>
) : undefined}
</SidebarLayout>
)}
{isMobile && (
Expand Down Expand Up @@ -335,19 +373,19 @@ const GrantsSearchResultsPage: CustomScreen<GrantsHomeProps> = ({

interface GrantsHomeProps {
locale: Locale
initialGrants?: Array<Grant>
initialGrantList?: GrantList
tags?: Array<GenericTag>
}

const GrantsSearchResults: CustomScreen<GrantsHomeProps> = ({
initialGrants,
initialGrantList,
tags,
customPageData,
locale,
}) => {
return (
<GrantsSearchResultsPage
initialGrants={initialGrants}
initialGrantList={initialGrantList}
tags={tags}
locale={locale}
customPageData={customPageData}
Expand Down Expand Up @@ -404,8 +442,9 @@ GrantsSearchResults.getProps = async ({ apolloClient, locale, query }) => {
},
}),
])

return {
initialGrants: getGrants.items,
initialGrantList: getGrants,
tags: getGenericTagsInTagGroups ?? undefined,
locale: locale as Locale,
themeConfig: {
Expand Down
Loading
Loading