Skip to content

Commit

Permalink
Merge pull request #51 from open-contracting/158-route-auth-check
Browse files Browse the repository at this point in the history
158 route auth check
  • Loading branch information
nahu authored Sep 5, 2023
2 parents 52099e0 + 332c54b commit 4ecdbe1
Show file tree
Hide file tree
Showing 53 changed files with 789 additions and 183 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ module.exports = {
plugins: ['react-refresh', '@typescript-eslint', 'react', 'prettier'],
rules: {
'react-refresh/only-export-components': 'warn',
'import/order': 'warn',
'react/react-in-jsx-scope': 'off',
'react/jsx-curly-brace-presence': 'off',
'react/jsx-filename-extension': [2, { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
'import/extensions': [
'error',
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ RUN yarn install
RUN yarn build

FROM nginx:1.25.1-alpine
ARG client_max_body_size
COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
Expand Down
10 changes: 8 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
services:
frontend:
build: ./credere-frontend/
build:
context: ./credere-frontend/
args:
VITE_MAX_FILE_SIZE_MB: ${VITE_MAX_FILE_SIZE_MB}
environment:
- VITE_APP_VERSION=${VITE_APP_VERSION}
- VITE_API_URL=${VITE_API_URL}
Expand Down Expand Up @@ -32,9 +35,10 @@ services:
- HASH_KEY=${HASH_KEY}
- TEST_MAIL_RECEIVER=${TEST_MAIL_RECEIVER}
- IMAGES_BASE_URL=${IMAGES_BASE_URL}
- IMAGES_LANG_SUBPATH=${IMAGES_LANG_SUBPATH}
- EMAIL_TEMPLATE_LANG=${EMAIL_TEMPLATE_LANG}
- FACEBOOK_LINK=${FACEBOOK_LINK}
- TWITTER_LINK=${TWITTER_LINK}
- SENTRY_DSN=${SENTRY_DSN}
- LINK_LINK=${LINK_LINK}
- OCP_EMAIL_GROUP=${OCP_EMAIL_GROUP}
- APPLICATION_EXPIRATION_DAYS=${APPLICATION_EXPIRATION_DAYS}
Expand All @@ -44,6 +48,8 @@ services:
- REMINDER_DAYS_BEFORE_EXPIRATION=${REMINDER_DAYS_BEFORE_EXPIRATION}
- PROGRESS_TO_REMIND_STARTED_APPLICATIONS=${PROGRESS_TO_REMIND_STARTED_APPLICATIONS}
- ENVIRONMENT=${ENVIRONMENT}
- TRANSIFEX_TOKEN=${TRANSIFEX_TOKEN}
- TRANSIFEX_SECRET=${TRANSIFEX_SECRET}

extra_hosts:
- 'host.docker.internal:host-gateway'
Expand Down
1 change: 1 addition & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
server {
listen 80;
server_name frontend;
client_max_body_size 10M;
location / {
# This would be the directory where your React app's static files are stored at
root /usr/share/nginx/html;
Expand Down
Binary file added public/images/es/set_password.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/api/private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ export const downloadDocumentFn = async (id: number) => {
return response.data;
};

export const downloadApplicationFn = async (id: number, lang: string) => {
const response = await authApi.get(`applications/${id}/download-application/${lang}`, {
responseType: 'blob',
});

return response.data;
};

export const emailToSME = async (emailToSMEPayload: EmailToSMEInput) => {
const { application_id, ...payload } = emailToSMEPayload;
const response = await authApi.post<IApplication>(`applications/email-sme/${application_id}`, payload);
Expand Down
15 changes: 14 additions & 1 deletion src/components/ApplicationAwardTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { Paper, Table, TableBody, TableContainer, TableHead, TableRow } from '@m
import { useT } from '@transifex/react';

import useGetPreviousAwards from '../hooks/useGetPreviousAwards';
import useLocalizedDateFormatter from '../hooks/useLocalizedDateFormatter';
import useUpdateAward from '../hooks/useUpdateAward';
import { IApplication, IUpdateAward } from '../schemas/application';
import { formatCurrency, formatDateFromString, formatPaymentMethod } from '../util';
import { formatCurrency, formatPaymentMethod } from '../util';
import ApplicationTableDataAwardRow from './ApplicationTableDataAwardRow';
import ApplicationTableDataPreviousAwardRow from './ApplicationTableDataPreviousAwardRow';
import { DataTableHeadCell, DataTableHeadLabel } from './DataTable';
Expand All @@ -18,6 +19,7 @@ export interface ApplicationAwardTableProps {

export function ApplicationAwardTable({ application, readonly = false, className }: ApplicationAwardTableProps) {
const t = useT();
const { formatDateFromString } = useLocalizedDateFormatter();
const { updateAwardMutation, isLoading } = useUpdateAward();
const { data: previousAwards, isLoading: isLoadingPreviousAwards } = useGetPreviousAwards(application.id);

Expand Down Expand Up @@ -58,6 +60,7 @@ export function ApplicationAwardTable({ application, readonly = false, className
name="title"
label={t('Award Title')}
award={award}
modifiedFields={application.modified_data_fields?.award_updates}
/>
<ApplicationTableDataAwardRow
isLoading={isLoading}
Expand All @@ -67,6 +70,7 @@ export function ApplicationAwardTable({ application, readonly = false, className
name="contracting_process_id"
label={t('Contracting Process ID')}
award={award}
modifiedFields={application.modified_data_fields?.award_updates}
/>
<ApplicationTableDataAwardRow
isLoading={isLoading}
Expand All @@ -76,6 +80,7 @@ export function ApplicationAwardTable({ application, readonly = false, className
name="description"
label={t('Award Description')}
award={award}
modifiedFields={application.modified_data_fields?.award_updates}
/>
<ApplicationTableDataAwardRow
type="date-field"
Expand All @@ -87,6 +92,7 @@ export function ApplicationAwardTable({ application, readonly = false, className
label={t('Award Date')}
award={award}
formatter={formatDateFromString}
modifiedFields={application.modified_data_fields?.award_updates}
/>
<ApplicationTableDataAwardRow
type="currency"
Expand All @@ -99,6 +105,7 @@ export function ApplicationAwardTable({ application, readonly = false, className
formLabel={t('Award Amount')}
award={award}
formatter={(value) => `${award.award_currency} ${formatCurrency(value, award.award_currency)}`}
modifiedFields={application.modified_data_fields?.award_updates}
/>
<ApplicationTableDataAwardRow
type="date-field"
Expand All @@ -110,6 +117,7 @@ export function ApplicationAwardTable({ application, readonly = false, className
label={t('Contract Start Date')}
award={award}
formatter={formatDateFromString}
modifiedFields={application.modified_data_fields?.award_updates}
/>
<ApplicationTableDataAwardRow
type="date-field"
Expand All @@ -121,6 +129,7 @@ export function ApplicationAwardTable({ application, readonly = false, className
label={t('Contract End Date')}
award={award}
formatter={formatDateFromString}
modifiedFields={application.modified_data_fields?.award_updates}
/>
<ApplicationTableDataAwardRow
preWhitespace
Expand All @@ -132,6 +141,7 @@ export function ApplicationAwardTable({ application, readonly = false, className
label={t('Payment Method')}
award={award}
formatter={formatPaymentMethod}
modifiedFields={application.modified_data_fields?.award_updates}
/>
<ApplicationTableDataAwardRow
isLoading={isLoading}
Expand All @@ -141,6 +151,7 @@ export function ApplicationAwardTable({ application, readonly = false, className
name="buyer_name"
label={t('Buyer Name')}
award={award}
modifiedFields={application.modified_data_fields?.award_updates}
/>
<ApplicationTableDataAwardRow
isLoading={isLoading}
Expand All @@ -150,6 +161,7 @@ export function ApplicationAwardTable({ application, readonly = false, className
name="procurement_method"
label={t('Procurement Method')}
award={award}
modifiedFields={application.modified_data_fields?.award_updates}
/>
<ApplicationTableDataAwardRow
isLoading={isLoading}
Expand All @@ -159,6 +171,7 @@ export function ApplicationAwardTable({ application, readonly = false, className
name="procurement_category"
label={t('Contract Type')}
award={award}
modifiedFields={application.modified_data_fields?.award_updates}
/>
<ApplicationTableDataPreviousAwardRow
label={t('Previous Public Sector Contracts')}
Expand Down
7 changes: 7 additions & 0 deletions src/components/ApplicationBorrowerTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export function ApplicationBorrowerTable({
name="legal_name"
label={t('Legal Name')}
borrower={borrower}
modifiedFields={application.modified_data_fields?.borrower_updates}
/>
<ApplicationTableDataBorrowerRow
preWhitespace
Expand All @@ -88,6 +89,7 @@ export function ApplicationBorrowerTable({
name="address"
label={t('Address')}
borrower={borrower}
modifiedFields={application.modified_data_fields?.borrower_updates}
/>
<ApplicationTableDataBorrowerRow
isLoading={isLoading || isLoadingVerifyDataField}
Expand All @@ -99,6 +101,7 @@ export function ApplicationBorrowerTable({
name="legal_identifier"
label={t('National Tax ID')}
borrower={borrower}
modifiedFields={application.modified_data_fields?.borrower_updates}
/>
<ApplicationTableDataBorrowerRow
isLoading={isLoading || isLoadingVerifyDataField}
Expand All @@ -110,6 +113,7 @@ export function ApplicationBorrowerTable({
name="type"
label={t('Registration Type')}
borrower={borrower}
modifiedFields={application.modified_data_fields?.borrower_updates}
/>
<ApplicationTableDataBorrowerRow
isLoading={isLoading || isLoadingVerifyDataField}
Expand All @@ -121,6 +125,7 @@ export function ApplicationBorrowerTable({
verifiedData={application.secop_data_verification}
borrower={borrower}
formatter={renderSize}
modifiedFields={application.modified_data_fields?.borrower_updates}
/>
<ApplicationTableDataBorrowerRow
isLoading={isLoading || isLoadingVerifyDataField}
Expand All @@ -132,6 +137,7 @@ export function ApplicationBorrowerTable({
verifiedData={application.secop_data_verification}
borrower={borrower}
formatter={renderSector}
modifiedFields={application.modified_data_fields?.borrower_updates}
/>
<ApplicationTableDataBorrowerRow
isLoading={isLoading || isLoadingVerifyDataField}
Expand All @@ -143,6 +149,7 @@ export function ApplicationBorrowerTable({
name="email"
label={t('Business Email')}
borrower={borrower}
modifiedFields={application.modified_data_fields?.borrower_updates}
/>
</TableBody>
</Table>
Expand Down
10 changes: 9 additions & 1 deletion src/components/ApplicationTableDataAwardRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function ApplicationTableDataAwardRow({
updateValue,
isLoading,
readonly,
modifiedFields,
}: ApplicationTableAwardDataRowProps) {
const value = award[name];
const missing = missingData[name];
Expand All @@ -28,7 +29,13 @@ export function ApplicationTableDataAwardRow({
<TableRow>
<DataTableCell>{label}</DataTableCell>
<DataTableCell>
<DataAvailability available={!missing} name={label} readonly={readonly} />
<DataAvailability
available={!missing}
name={name}
label={label}
readonly={readonly}
modifiedFields={modifiedFields}
/>
</DataTableCell>
{!missing && <DataTableCell className={preWhitespace ? 'whitespace-pre' : ''}>{formattedValue}</DataTableCell>}
{missing && updateValue && (
Expand All @@ -54,6 +61,7 @@ ApplicationTableDataAwardRow.defaultProps = {
preWhitespace: false,
type: undefined,
formLabel: undefined,
modifiedFields: undefined,
};

export default ApplicationTableDataAwardRow;
6 changes: 5 additions & 1 deletion src/components/ApplicationTableDataBorrowerRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function ApplicationTableDataBorrowerRow({
withoutVerify,
isLoading,
readonly,
modifiedFields,
}: ApplicationTableBorrowerDataRowProps) {
const t = useT();

Expand All @@ -46,8 +47,10 @@ export function ApplicationTableDataBorrowerRow({
<DataTableCell>
<DataAvailability
available={DATA_REQUESTED_FROM_MSME.includes(name) || !missing}
name={label}
name={name}
label={label}
readonly={readonly}
modifiedFields={modifiedFields}
/>
</DataTableCell>
{(!missing || withoutVerify) && (
Expand Down Expand Up @@ -87,6 +90,7 @@ ApplicationTableDataBorrowerRow.defaultProps = {
type: undefined,
formLabel: undefined,
withoutVerify: false,
modifiedFields: undefined,
};

export default ApplicationTableDataBorrowerRow;
7 changes: 4 additions & 3 deletions src/components/ApplicationTableDataDocumentRow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { TableRow } from '@mui/material';
import { useT } from '@transifex/react';
import DocumentIcon from 'src/assets/icons/document.svg';

import { DOCUMENT_TYPES_NAMES } from '../constants';
Expand All @@ -18,6 +18,7 @@ export function ApplicationTableDataDocumentRow({
isLoading = false,
readonly = false,
}: ApplicationTableDocumentDataRowProps) {
const t = useT();
const value = document.name;
const missing = false;

Expand All @@ -30,9 +31,9 @@ export function ApplicationTableDataDocumentRow({

return (
<TableRow>
<DataTableCell>{DOCUMENT_TYPES_NAMES[document.type]}</DataTableCell>
<DataTableCell>{t(DOCUMENT_TYPES_NAMES[document.type])}</DataTableCell>
<DataTableCell>
<DataAvailability available={!missing} name={document.type} readonly={readonly} />
<DataAvailability available={!missing} label={document.type} readonly={readonly} />
</DataTableCell>
{!downloadDocument && (
<DataTableCell className={preWhitespace ? 'whitespace-pre' : ''}>{formattedValue}</DataTableCell>
Expand Down
7 changes: 4 additions & 3 deletions src/components/ApplicationTableDataPreviousAwardRow.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Box, Paper, Table, TableBody, TableContainer, TableHead, TableRow } from '@mui/material';
import { useT } from '@transifex/react';
import { useState } from 'react';
import Minus from 'src/assets/icons/minus.svg';
import Plus from 'src/assets/icons/plus.svg';

import useLocalizedDateFormatter from '../hooks/useLocalizedDateFormatter';
import { IAward } from '../schemas/application';
import Loader from '../stories/loader/Loader';
import { formatCurrency, formatDateFromString } from '../util';
import { formatCurrency } from '../util';
import { ApplicationTableAwardDataRowProps } from './ApplicationTableDataRow';
import DataAvailability from './DataAvailability';
import { DataTableCell, DataTableHeadCell, DataTableHeadLabel } from './DataTable';
Expand Down Expand Up @@ -36,6 +36,7 @@ export function ApplicationTableDataPreviousAwardRow({
preWhitespace,
}: ApplicationTableDataPreviousAwardRowProps) {
const t = useT();
const { formatDateFromString } = useLocalizedDateFormatter();

const [open, setOpen] = useState(false);

Expand All @@ -49,7 +50,7 @@ export function ApplicationTableDataPreviousAwardRow({
<TableRow>
<DataTableCell>{label}</DataTableCell>
<DataTableCell>
<DataAvailability available={!missing} name={label} readonly />
<DataAvailability available={!missing} label={label} readonly />
</DataTableCell>
{!missing && (
<DataTableCell className={preWhitespace ? 'whitespace-pre' : ''}>
Expand Down
10 changes: 9 additions & 1 deletion src/components/ApplicationTableDataRow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { IAward, IBorrower, IBorrowerDocument, IUpdateAward, IUpdateBorrower } from '../schemas/application';
import {
IAward,
IBorrower,
IBorrowerDocument,
IModifiedDataFields,
IUpdateAward,
IUpdateBorrower,
} from '../schemas/application';

export interface ApplicationTableDataRowProps {
label: string;
Expand All @@ -10,6 +17,7 @@ export interface ApplicationTableDataRowProps {
formatter?: (value: any) => string;
isLoading: boolean;
readonly: boolean;
modifiedFields?: { [key: string]: IModifiedDataFields };
}

export interface ApplicationTableAwardDataRowProps extends ApplicationTableDataRowProps {
Expand Down
Loading

0 comments on commit 4ecdbe1

Please sign in to comment.