Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
84 changes: 52 additions & 32 deletions core/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,24 @@ datasource db {
}

model Indicator {
id String @id @unique
label String
description String?
source String
unit String?
dataset String?
absolute Boolean
unitSymbol String?
showChart Boolean @default(true)
precision Int @default(0)
hidden Boolean @default(false)
tags String[]
searchTags String[]
ranking Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
values Value[]
Bookmark Bookmark[]
relatedTo Indicator[] @relation("indicatorRelation")
relatedIn Indicator[] @relation("indicatorRelation")

@@index([label(sort: Asc)])
id String @id @unique
absolute Boolean
unitSymbol String?
showChart Boolean @default(true)
precision Int @default(0)
hidden Boolean @default(false)
tags String[]
searchTags String[]
ranking Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
values Value[]
Bookmark Bookmark[]
relatedTo Indicator[] @relation("indicatorRelation")
relatedIn Indicator[] @relation("indicatorRelation")
IndicatorTranslation IndicatorTranslation[]

@@index([id(sort: Asc)])
@@index([label, searchTags, hidden])
}

model Value {
Expand All @@ -59,22 +53,21 @@ enum AreaType {
}

model Country {
id String @id @unique
name String
geoCode String? @unique
id String @id @unique
geoCode String? @unique
iso2Code String?
hidden Boolean @default(false)
hidden Boolean @default(false)
mapping Json?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
independentState Boolean @default(true)
internationallyRecognized Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
independentState Boolean @default(true)
internationallyRecognized Boolean @default(true)
searchTags String[]
type AreaType?
values Value[]
Bookmark Bookmark[]
CountryTranslation CountryTranslation[]

@@index([name(sort: Asc)])
@@index([id(sort: Asc)])
}

Expand Down Expand Up @@ -105,3 +98,30 @@ model User {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

enum Language {
uk
en
}

model IndicatorTranslation {
language Language
indicator Indicator @relation(fields: [indicatorId], references: [id])
label String
description String?
source String
unit String?
dataset String?
indicatorId String

@@id([indicatorId, language])
}

model CountryTranslation {
language Language
country Country @relation(fields: [countryId], references: [id])
name String
countryId String

@@id([countryId, language])
}
2 changes: 1 addition & 1 deletion core/src/app/(admin)/admin/dashboard/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PropsWithChildren } from "react"
import AdminHeader from "@/layout/admin-header/AdminHeader"
import Footer from "@/layout/footer/Footer"
import { PropsWithChildren } from "react"

export default function RootLayout({ children }: PropsWithChildren) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ const generateMetadata = async ({
}
}

const i18nContext = {
name: country.name,
label: indicator.label,
}

return {
metadataBase: new URL(SERVER_ADDRESS),
title: translate("pages.indicator_country.metadata.title", {
country: country.name,
indicator: indicator.label,
}),
title: translate("pages.indicator_country.metadata.title", i18nContext),
description: translate(
"pages.indicator_country.metadata.description_long",
{
Expand All @@ -73,27 +75,21 @@ const generateMetadata = async ({
themeColor: "#ffffff",
openGraph: {
images: [ogImage],
title: translate("pages.indicator_country.metadata.title", {
country: country.name,
indicator: indicator.label,
}),
description: translate("pages.indicator_country.metadata.description", {
country: country.name,
indicator: indicator.label,
}),
title: translate("pages.indicator_country.metadata.title", i18nContext),
description: translate(
"pages.indicator_country.metadata.description",
i18nContext
),
type: "website",
url: `/indicator/${params.id}/${params.country}`,
},
twitter: {
images: [ogImage],
title: translate("pages.indicator_country.metadata.title", {
country: country.name,
indicator: indicator.label,
}),
description: translate("pages.indicator_country.metadata.description", {
country: country.name,
indicator: indicator.label,
}),
title: translate("pages.indicator_country.metadata.title", i18nContext),
description: translate(
"pages.indicator_country.metadata.description",
i18nContext
),
card: "summary_large_image",
site: "@Zhorrrro",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@ import CountryService from "@/services/country-service/CountryService"
export const GET = async () => {
const countries = await CountryService.getSelectAutocomplete()

return NextResponse.json([
{
value: "all",
label: "All countries",
},
...countries,
])
return NextResponse.json(countries)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@ import IndicatorService from "@/services/indicator-service/IndicatorService"
export const GET = async () => {
const indicators = await IndicatorService.getSelectAutocomplete()

return NextResponse.json([
{
value: "all",
label: "All indicators",
},
...indicators,
])
return NextResponse.json(indicators)
}
2 changes: 1 addition & 1 deletion core/src/app/api/public/download/[indicator]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const GET = validationMiddleware(async ({ params, searchParams }) => {
if (!indicator || !countryValues.length)
return new NextResponse(null, { status: 404 })

const fileName = indicator.label
const fileName = encodeURI(indicator.label)

if (searchParams.format === "xlsx") {
const header = ["Region", "Year", "Value"]
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/indicator-card/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Indicator } from "@prisma/client"
import { Indicator } from "@/types/indicator.types"

export interface IndicatorCardProps
extends Pick<Indicator, "label" | "id" | "description" | "source"> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ const IndicatorOptionsButton: FC<IndicatorOptionsProps> = ({
>
{translate(
isBookmarked
? "pages.indicator.bookmark"
: "pages.indicator.unbookmark"
? "pages.indicator.unbookmark"
: "pages.indicator.bookmark"
)}
</DropdownItem>
<DropdownItem className="indicator-options__dropdown-item" size="small">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Country } from "@prisma/client"
import { DropdownProps } from "@/ui/dropdown/Dropdown.types"
import { Country } from "@/types/country.types"

export interface CountriesDashboardTableRowDropdownProps
extends Pick<DropdownProps, "onClose" | "isOpen" | "anchor"> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Country } from "@prisma/client"
import { CountryFormValues } from "@/containers/forms/country-form/types"
import { Country } from "@/types/country.types"

export interface EditCountryFormProps {
country: Country
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Country } from "@prisma/client"
import { EditCountryFormValues } from "@/containers/forms/country-form/edit-country-form/types"
import { Country } from "@/types/country.types"

const getInitialValues = (country: Country): EditCountryFormValues => {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Indicator } from "@prisma/client"
import { IndicatorFormValues } from "@/containers/forms/indicator-form/types"
import { Indicator } from "@/types/indicator.types"

export interface EditIndicatorFormProps {
indicator: Indicator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Indicator } from "@prisma/client"
import { Indicator } from "@/types/indicator.types"

const getInitialValues = (indicator: Indicator) => {
return {
Expand Down
2 changes: 1 addition & 1 deletion core/src/containers/indicator-chart-section/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Indicator } from "@prisma/client"
import { ChartItem } from "@/store/chart-store/types"
import { Indicator } from "@/types/indicator.types"

export type ChartIndicatorData = Pick<Indicator, "unit" | "label">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Indicator } from "@prisma/client"
import { Indicator } from "@/types/indicator.types"
import { RowValue } from "@/types/value.types"

export interface IndicatorCountryTableProps {
Expand Down
3 changes: 2 additions & 1 deletion core/src/containers/indicator-details-section/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Indicator, Country } from "@prisma/client"
import { Country } from "@/types/country.types"
import { Indicator } from "@/types/indicator.types"

export interface IndicatorDetailsSectionProps {
indicator: Indicator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Indicator } from "@prisma/client"
import { CountryRowValue } from "@/types/country.types"
import { Indicator } from "@/types/indicator.types"

export interface IndicatorTableProps {
data: CountryRowValue[]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentProps } from "react"
import { Indicator } from "@prisma/client"
import { CountryRowValue } from "@/types/country.types"
import { Indicator } from "@/types/indicator.types"

export interface IndicatorTableRowProps extends ComponentProps<"tr"> {
indicator: Indicator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Indicator } from "@prisma/client"
import { DropdownProps } from "@/ui/dropdown/Dropdown.types"
import { Indicator } from "@/types/indicator.types"

export interface IndicatorsDashboardTableRowDropdownProps
extends Pick<DropdownProps, "onClose" | "isOpen" | "anchor"> {
Expand Down
2 changes: 1 addition & 1 deletion core/src/containers/modals/country-modal/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Country } from "@prisma/client"
import { Country } from "@/types/country.types"

export interface CountryModalProps {
country: Country
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FC } from "react"
import { Country } from "@prisma/client"
import EditCountryForm from "@/containers/forms/country-form/edit-country-form/EditCountryForm"
import { EditCountryModalProps } from "@/containers/modals/edit-country-modal/types"
import ModalContainer from "@/components/modal-container/ModalContainer"
import { useModal } from "@/providers/modal-provider/ModalProvider"
import { Country } from "@/types/country.types"
import translate from "@/modules/i18n"

const EditCountryModal: FC<EditCountryModalProps> = ({
Expand Down
2 changes: 1 addition & 1 deletion core/src/containers/modals/edit-country-modal/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Country } from "@prisma/client"
import { Country } from "@/types/country.types"

export interface EditCountryModalProps {
country: Country
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FC } from "react"
import { Indicator } from "@prisma/client"
import EditIndicatorForm from "@/containers/forms/indicator-form/edit-indicator-form/EditIndicatorForm"
import { EditIndicatorModalProps } from "@/containers/modals/edit-indicator-modal/types"
import ModalContainer from "@/components/modal-container/ModalContainer"
import { useModal } from "@/providers/modal-provider/ModalProvider"
import { Indicator } from "@/types/indicator.types"
import translate from "@/modules/i18n"

const EditIndicatorModal: FC<EditIndicatorModalProps> = ({
Expand Down
2 changes: 1 addition & 1 deletion core/src/containers/modals/edit-indicator-modal/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Indicator } from "@prisma/client"
import { Indicator } from "@/types/indicator.types"

export interface EditIndicatorModalProps {
indicator: Indicator
Expand Down
2 changes: 1 addition & 1 deletion core/src/containers/modals/indicator-modal/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Indicator } from "@prisma/client"
import { Indicator } from "@/types/indicator.types"

export interface IndicatorModalProps {
indicator: Indicator
Expand Down
6 changes: 6 additions & 0 deletions core/src/messages/messages.en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ export default {
by_indicator_id: "Indicator ID",
by_country_id: "Country ID",
},
country: {
all: "All countries",
},
indicator: {
all: "All indicators",
},
},
},
dashboard: {
Expand Down
6 changes: 6 additions & 0 deletions core/src/messages/messages.uk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ export default {
by_indicator_id: "ID індикатора",
by_country_id: "ID країни",
},
country: {
all: "Всі країни",
},
indicator: {
all: "Всі індикатори",
},
},
},
dashboard: {
Expand Down
Loading