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

[FS-280]: Cycle 39 Maintenance #136

Merged
merged 9 commits into from
Jan 8, 2024
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
11 changes: 1 addition & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module.exports = init({
modules: {
auto: true,
esm: true,
disableExpensiveRules: !process.env.CI && !process.env.HUSKY,
typescript: {
parserProject: ['./tsconfig.eslint.json'],
resolverProject: ['./tsconfig.json'],
},
},
extends: ['plugin:@cspell/recommended'],
rules: {
// NOTE: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md#known-issueslimitations
'react/no-unused-prop-types': 'off',
Expand All @@ -25,14 +25,5 @@ module.exports = init({
'node/prefer-global/buffer': 'off',
},
},
{
files: ['./**/*.stories.tsx', './**/*.cy.tsx'],
rules: {
'@typescript-eslint/no-confusing-void-expression': 'off',
'react/jsx-no-useless-fragment': 'off',
'react-hooks/rules-of-hooks': 'off',
'storybook/no-title-property-in-meta': 'off',
},
},
],
});
2 changes: 1 addition & 1 deletion app/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'dayjs/locale/fa';
import '@camp/zod-addons';
import '@camp/zod-addons/monkey-patch';

import { ApolloProvider } from '@camp/api-client';
import { AuthProvider } from '@camp/auth';
Expand Down
2 changes: 1 addition & 1 deletion configs/husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm exec lint-staged
HUSKEY=1 pnpm exec lint-staged
2 changes: 1 addition & 1 deletion configs/husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm run verify
HUSKEY=1 pnpm run verify
54 changes: 43 additions & 11 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,58 @@
import { getBooleanEnv, getEnv, toInteger } from '@fullstacksjs/toolbox';
import { Config } from '@fullstacksjs/config';
import { defineConfig } from 'cypress';
import viteProcessor from 'cypress-vite';

import { config } from './vite.config';

const port = toInteger(getEnv('PORT', ''), 3000);
const host = getEnv('HOST', 'localhost');
const envs = new Config({
retries: Config.number({ default: 1 }),
cypress: Config.object({
port: Config.number({ default: 3000 }),
host: Config.string({ default: 'localhost' }),
retries: Config.number({ default: 1 }),
video: Config.boolean({ default: true }),
}),
auth0: Config.object({
audience: Config.string().required(),
domain: Config.string().required(),
clientId: Config.string().required(),
}),
api: Config.object({
endpoint: Config.string().required(),
secret: Config.string().required(),
}),
}).parse({
cypress: {
port: process.env.PORT,
host: process.env.HOST,
retries: process.env.CYPRESS_RETRIES,
video: process.env.CYPRESS_RECORD_VIDEO,
},
auth0: {
audience: process.env.APP_AUTH0_AUDIENCE,
domain: process.env.APP_AUTH0_DOMAIN,
clientId: process.env.APP_AUTH0_CLIENT_ID,
},
api: {
endpoint: process.env.APP_API_ENDPOINT,
secret: process.env.APP_HASURA_ADMIN_SECRET,
},
});

export default defineConfig({
e2e: {
retries: toInteger(getEnv('CYPRESS_RETRIES', '1')),
baseUrl: `https://${host}:${port}`,
retries: envs.get('cypress.retries'),
baseUrl: `https://${envs.get('cypress.host')}:${envs.get('cypress.port')}`,
projectId: '8jt3ix',
video: getBooleanEnv('CYPRESS_RECORD_VIDEO', true),
video: envs.get('cypress.video'),
defaultCommandTimeout: 10000,
experimentalMemoryManagement: true,
env: {
APP_AUTH0_AUDIENCE: getEnv('APP_AUTH0_AUDIENCE'),
APP_AUTH0_DOMAIN: getEnv('APP_AUTH0_DOMAIN'),
APP_AUTH0_CLIENT_ID: getEnv('APP_AUTH0_CLIENT_ID'),
APP_API_ENDPOINT: getEnv('APP_API_ENDPOINT'),
APP_HASURA_ADMIN_SECRET: getEnv('APP_HASURA_ADMIN_SECRET'),
APP_AUTH0_AUDIENCE: envs.get('auth0.audience'),
APP_AUTH0_DOMAIN: envs.get('auth0.domain'),
APP_AUTH0_CLIENT_ID: envs.get('auth0.clientId'),
APP_API_ENDPOINT: envs.get(`api.endpoint`),
APP_HASURA_ADMIN_SECRET: envs.get('api.secret'),
},
setupNodeEvents(on) {
on('file:preprocessor', viteProcessor());
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/draftHouseholder.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pruneUndefinedOrEmpty } from '@fullstacksjs/toolbox';
import { isNull, pruneValueWhen } from '@fullstacksjs/toolbox';

import { householderFormIds as ids } from '../../app/Dashboard/Households/HouseholdDetail/_components/HouseholderForm/HouseholderForm.ids';
import { householdDetailIds as tabIds } from '../../app/Dashboard/Households/HouseholdDetail/HouseholdDetail.ids';
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('Householder', () => {
});

it('[OK]: Admin wants to add householder information', () => {
const mock = pruneUndefinedOrEmpty(householderFixture());
const mock = pruneValueWhen(householderFixture(), isNull);
addHouseholder(mock);
});

Expand All @@ -77,7 +77,7 @@ describe('Householder', () => {
});

it('[OK]: Admin wants to undo changes after editing form', () => {
const mock = pruneUndefinedOrEmpty(householderFixture());
const mock = pruneValueWhen(householderFixture(), isNull);

addHouseholder(mock);
cy.findByTestId(ids.editBtn, { timeout: 1e4 }).click();
Expand All @@ -87,7 +87,7 @@ describe('Householder', () => {
});

it('[OK]: Admin wants to revisit householder information', () => {
const mock = pruneUndefinedOrEmpty(householderFixture());
const mock = pruneValueWhen(householderFixture(), isNull);
addHouseholder(mock);
cy.reload();
compareHouseholderForm(mock);
Expand Down
Empty file.
22 changes: 12 additions & 10 deletions docs/Glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ The project glossary is a collection of terms captured from models and shapes th

## Terms

| Term | Definition |
| ---------------- | ---------------------------------------------------------------------------------------------------------- |
| Term | Definition |
| ------------------- | ------------------------------------------------------------------------------------------------------------- |
| Household | a term used for a group of Members under support. a Household must have a Householder. |
| Dependent | a Member who falls under the support of a Householder. |
| Householder | a Member who provides emotional and financial support to a Household. |
| Need | Cash or non-cash support that a Household or Group of Families needs. |
| Caseworker | a person involved in directly considering the individual case's problems, needs, and adjustments. |
| Project | the predefined program of aiding a Household or group of Families with money, properties, or material goods. |
| Loan | a loan is money given to a Household in exchange for future repayment of the loan value amount with interest. |
| Member | a Householder or a Dependent |
| Project Gallery | a gallery of the pictures of a Project |
| Dependent | a Member who falls under the support of a Householder. |
| Householder | a Member who provides emotional and financial support to a Household. |
| Need | Cash or non-cash support that a Household or Group of Families needs. |
| Caseworker | a person involved in directly considering the individual case's problems, needs, and adjustments. |
| Project | the predefined program of aiding a Household or group of Families with money, properties, or material goods. |
| Loan | a loan is money given to a Household in exchange for future repayment of the loan value amount with interest. |
| Member | a Householder or a Dependent which belongs to a Household |
| Project Gallery | a gallery of the pictures and documents of a Project |
| Draft Household | A saved Household which is not completed yet. |
| Completed Household | A Household in which all information is provided and submitted. |
| Visit | An assessment by a caseworker at a beneficiary's household to evaluate their living conditions and needs. |
| Accommodation Type | A classification indicating whether a household owns or rents their dwelling |
4 changes: 2 additions & 2 deletions libs/data-layer/operations/fragments/scalar.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Nullish } from '@fullstacksjs/toolbox';
import type { Nullable } from '@fullstacksjs/toolbox';

export const toDate = (d: Nullish | string) => (d ? new Date(d) : undefined);
export const toDate = (d: Nullable<string>) => (d ? new Date(d) : undefined);
export const toApiDate = (d: Date): string => d.toISOString().split('T')[0]!;
4 changes: 2 additions & 2 deletions libs/data-layer/operations/queries/useHouseholdListQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { QueryHookOptions } from '@camp/api-client';
import { useQuery } from '@camp/api-client';
import type { HouseholdKeys, HouseholdListItem } from '@camp/domain';
import { ApiOrderBy } from '@camp/domain';
import type { Nullish } from '@fullstacksjs/toolbox';
import type { Nullable } from '@fullstacksjs/toolbox';
import { isEmpty, isNotNull } from '@fullstacksjs/toolbox';
import type { PaginationState, SortingState } from '@tanstack/react-table';

Expand Down Expand Up @@ -40,7 +40,7 @@ export const HouseholdListDocument = gql`

export interface HouseholdListDto {
household: (HouseholdKeys & HouseholdListItem)[];
totalCount: Nullish | number;
totalCount: Nullable<number>;
}

const toClient = (data: ApiHouseholdListQuery | null): HouseholdListDto => {
Expand Down
6 changes: 3 additions & 3 deletions libs/data-layer/operations/queries/useHouseholdQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
ApiHouseholdQueryVariables,
} from '@camp/data-layer';
import type { HouseholdDetail, HouseholdKeys } from '@camp/domain';
import type { Nullish } from '@fullstacksjs/toolbox';
import type { Nullable } from '@fullstacksjs/toolbox';

import {
getHouseholdDetail,
Expand All @@ -27,14 +27,14 @@ export const HouseholdDocument = gql`
`;

export interface HouseholdDto {
household: Nullish | (HouseholdDetail & HouseholdKeys);
household: Nullable<HouseholdDetail & HouseholdKeys>;
}

interface Variables {
id: string;
}

const toClient = (data: ApiHouseholdQuery | Nullish): HouseholdDto => {
const toClient = (data: Nullable<ApiHouseholdQuery>): HouseholdDto => {
return {
household: data?.household_by_pk
? {
Expand Down
4 changes: 2 additions & 2 deletions libs/data-layer/operations/queries/useHouseholderQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
ApiHouseholderQueryVariables,
} from '@camp/data-layer';
import type { HouseholderIdentity, HouseholderKeys } from '@camp/domain';
import type { Nullish } from '@fullstacksjs/toolbox';
import type { Nullable } from '@fullstacksjs/toolbox';

import {
getHouseholderIdentity,
Expand Down Expand Up @@ -34,7 +34,7 @@ interface Variables {
id: string;
}

const toClient = (data: ApiHouseholderQuery | Nullish): HouseholderDto => {
const toClient = (data: Nullable<ApiHouseholderQuery>): HouseholderDto => {
return {
householder: data?.householder_by_pk
? {
Expand Down
4 changes: 2 additions & 2 deletions libs/data-layer/operations/queries/useMemberListQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { gql } from '@apollo/client';
import type { QueryHookOptions } from '@camp/api-client';
import { useQuery } from '@camp/api-client';
import type { Member } from '@camp/domain';
import type { Nullish } from '@fullstacksjs/toolbox';
import type { Nullable } from '@fullstacksjs/toolbox';

import type {
ApiMemberListQuery,
Expand Down Expand Up @@ -41,7 +41,7 @@ export interface MemberList {
members: Member[];
}

const toClient = (data: ApiMemberListQuery | Nullish) => {
const toClient = (data: Nullable<ApiMemberListQuery>) => {
const members = data?.member;
if (members == null) return null;
return {
Expand Down
4 changes: 2 additions & 2 deletions libs/data-layer/operations/queries/useProjectListQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
ApiProjectListQueryVariables,
} from '@camp/data-layer';
import type { ProjectKeys, ProjectListItem } from '@camp/domain';
import type { Nullish } from '@fullstacksjs/toolbox';
import type { Nullable } from '@fullstacksjs/toolbox';

import {
getProjectKeys,
Expand Down Expand Up @@ -37,7 +37,7 @@ export interface ProjectList {
projects: (ProjectKeys & ProjectListItem)[];
}

const toClient = (data: ApiProjectListQuery | Nullish): ProjectList => {
const toClient = (data: Nullable<ApiProjectListQuery>): ProjectList => {
const projects = data?.project_aggregate.nodes;

return {
Expand Down
4 changes: 2 additions & 2 deletions libs/data-layer/operations/queries/useProjectQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
ProjectDetail,
ProjectKeys,
} from '@camp/domain';
import type { Nullish } from '@fullstacksjs/toolbox';
import type { Nullable } from '@fullstacksjs/toolbox';

import {
getHouseholdDetail,
Expand Down Expand Up @@ -52,7 +52,7 @@ export interface Variables {
id: string;
}

const toClient = (data: ApiProjectQuery | Nullish): ProjectDto => {
const toClient = (data: Nullable<ApiProjectQuery>): ProjectDto => {
const project = data?.project_by_pk;

return {
Expand Down
1 change: 0 additions & 1 deletion libs/debug/Debug.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Tuple } from '@fullstacksjs/toolbox';

/* eslint-disable @typescript-eslint/no-empty-function */
export type LogLevel = 'error' | 'info' | 'silent' | 'trace' | 'warn';

export interface Logger {
Expand Down
4 changes: 2 additions & 2 deletions libs/design/FileUpload/FileList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isNullOrEmpty } from '@fullstacksjs/toolbox';
import { isNullOrEmptyArray } from '@fullstacksjs/toolbox';
import { Box } from '@mantine/core';

import { File } from './File';
Expand All @@ -10,7 +10,7 @@ interface Props {
}

export const FileList = ({ files, onRemove }: Props) => {
if (isNullOrEmpty(files)) return null;
if (isNullOrEmptyArray(files)) return null;

return (
<Box>
Expand Down
4 changes: 2 additions & 2 deletions libs/design/FileUpload/FileSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UploadIcon } from '@camp/icons';
import { messages } from '@camp/messages';
import { Button, Group, Text } from '@mantine/core';
import { forwardRef } from 'react';
import { Upload } from 'react-feather';

interface Props extends Omit<React.HTMLProps<HTMLInputElement>, 'onClick'> {
onClick?: React.MouseEventHandler<HTMLButtonElement>;
Expand All @@ -23,7 +23,7 @@ export const FileSelect = forwardRef<HTMLInputElement, Props>(
color: props.disabled ? theme.colors.fg[4] : theme.colors.fg[5],
})}
>
<Upload />
<UploadIcon />
<Text size="sm">{t.note}</Text>
</Group>
</Group>
Expand Down
4 changes: 2 additions & 2 deletions libs/design/Select/ControlledSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Nullish } from '@fullstacksjs/toolbox';
import type { Nullable } from '@fullstacksjs/toolbox';
import type { Control, FieldValues, Path, PathValue } from 'react-hook-form';
import { Controller } from 'react-hook-form';

Expand All @@ -8,7 +8,7 @@ import { Select } from './Select';
interface Props<T extends FieldValues> extends SelectProps {
name: Path<T>;
control: Control<T>;
presentation?: (value: Nullish | PathValue<T, Path<T>>) => JSX.Element;
presentation?: (value: Nullable<PathValue<T, Path<T>>>) => JSX.Element;
}

export const ControlledSelect = <T extends FieldValues>({
Expand Down
2 changes: 0 additions & 2 deletions libs/design/theme/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export const theme: MantineThemeOverride = {
backgroundColor: palette.secondary.default,
borderRadius: '4px',
},

/* eslint-enable @typescript-eslint/naming-convention */
}),
dir: 'rtl',
fontFamily: 'IRANSansFaNum, IRANSans',
Expand Down
2 changes: 1 addition & 1 deletion libs/domain/Household.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { messages } from '@camp/messages';
import { toZodLiteralList } from '@camp/zod-addons';
import { createColumnHelper } from '@tanstack/react-table';
import { z } from 'zod';

import { toZodLiteralList } from '../zod-addons';
import type { HouseholdStatusEnum } from './ApiSchema';
import { HouseholdSeverityEnum } from './ApiSchema';

Expand Down
2 changes: 1 addition & 1 deletion libs/domain/Schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { messages } from '@camp/messages';
import { toZodLiteralList } from '@camp/zod-addons';
import { z } from 'zod';

import { toZodLiteralList } from '../zod-addons';
import { cities } from './City';
import { genders } from './Gender';
import { nationalities } from './Nationality';
Expand Down
1 change: 1 addition & 0 deletions libs/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export {
Users as PeopleIcon,
Plus as PlusIcon,
Trash2 as TrashIcon,
Upload as UploadIcon,
User as UserIcon,
} from 'react-feather';
Loading