Skip to content

Commit

Permalink
Merge branch 'feature/contracts' of github.com:code4romania/teo into …
Browse files Browse the repository at this point in the history
…feature/contracts
  • Loading branch information
dragos1195 committed Oct 2, 2024
2 parents c6bdf5a + c26d647 commit fb9f052
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 23 deletions.
6 changes: 6 additions & 0 deletions frontend/src/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,12 @@
"description": "View the list of all your volunteer contracts in VIC. The volunteer contract has a predefined structure. You can create multiple contract templates (e.g. volunteer contract >16 years, volunteer contract <16 years)."
}
},
"document_contract": {
"delete_modal": {
"title": "Are you sure you want to delete this contract?",
"description": "Once deleted, the contract cannot be recovered."
}
},
"popover": {
"edit": "Edit template title",
"download": "Download document",
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/assets/locales/ro/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,12 @@
"description": "Vizualizează lista tuturor contractelor voluntarilor tăi din VIC. Contractul de voluntar are o structura prestabilită. Poți crea mai multe template-uri de contracte (ex. contract pentru voluntari >16 ani, contract pentru voluntari <16 ani)."
}
},
"document_contract": {
"delete_modal": {
"title": "Ești sigur că dorești ștergerea acestui contract?",
"description": "Odată șters, contractul nu mai poate fi recuperat."
}
},
"popover": {
"edit": "Editează titlu template",
"download": "Descarcă document",
Expand Down Expand Up @@ -1361,4 +1367,4 @@
"clear": "Șterge",
"apply_all": "Aplică pentru toate"
}
}
}
4 changes: 2 additions & 2 deletions frontend/src/components/DocumentContractsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ const DocumentContractsTable = ({ query, setQuery }: DocumentContractsTableBasic
/>
{selectedDeleteContract && (
<ConfirmationModal
title={t('contract.delete_modal.title')}
description={t('contract.delete_modal.description')}
title={t('document_contract.delete_modal.title')}
description={t('document_contract.delete_modal.description')}
confirmBtnLabel={t('general:delete')}
onClose={setSelectedDeleteContract.bind(null, null)}
onConfirm={confirmDelete}
Expand Down
12 changes: 11 additions & 1 deletion mobile/src/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,17 @@
"approved_start": "Your contract with",
"approved_end": "has been approved and signed.",
"rejected_start": "Your contract with",
"rejected_end": "was rejected. See reason."
"rejected_end": "was rejected by the organization. See reason.",
"rejected_volunteer_start": "You rejected the contract with",
"rejected_volunteer_end": ".",
"validated_start": "Your contract with",
"validated_end": "has been validated by the organization.",
"signed_start": "Your contract with",
"signed_end": "has been signed by the organization representative.",
"signed_volunteer_start": "You signed the contract with",
"signed_volunteer_end": ".",
"deleted_start": "Your contract with",
"deleted_end": "has been deleted."
},
"organization": {
"request": "Application to join the organization",
Expand Down
12 changes: 11 additions & 1 deletion mobile/src/assets/locales/ro/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,17 @@
"approved_start": "Contractul tău cu",
"approved_end": "a fost aprobat și semnat.",
"rejected_start": "Contractul tău cu",
"rejected_end": "a fost respins. Vezi motiv."
"rejected_end": "a fost respins de către organizație. Vezi motivul.",
"rejected_volunteer_start": "Ai respins contractul cu",
"rejected_volunteer_end": ".",
"validated_start": "Contractul tău cu",
"validated_end": "a fost validat de către organizație. Urmează să fie semnat de către reprezentantul acesteia.",
"signed_start": "Contractul tău cu",
"signed_end": "a fost semnat de către reprezentantul organizației.",
"signed_volunteer_start": "Ai semnat contractul cu",
"signed_volunteer_end": ".",
"deleted_start": "Contractul tău cu",
"deleted_end": "a fost șters."
},
"organization": {
"request": "Cererea de înscriere în organizația",
Expand Down
1 change: 1 addition & 0 deletions mobile/src/common/enums/tracked-event-name.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export enum TrackedEventName {
APPROVE_CONTRACT = 'APPROVE_CONTRACT',
REJECT_CONTRACT = 'REJECT_CONTRACT',

// Document Contract - new implementation
CREATE_DOCUMENT_CONTRACT = 'CREATE_DOCUMENT_CONTRACT',
VALIDATE_DOCUMENT_CONTRACT = 'VALIDATE_DOCUMENT_CONTRACT',
SIGN_DOCUMENT_CONTRACT_BY_NGO = 'SIGN_DOCUMENT_CONTRACT_BY_NGO',
Expand Down
9 changes: 5 additions & 4 deletions mobile/src/screens/DocumentsContract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PageLayout from '../layouts/PageLayout';
import { useTranslation } from 'react-i18next';
import { usePaddingTop } from '../hooks/usePaddingTop';
import { Text, useTheme } from '@ui-kitten/components';
import { IDocumentContract, RejectionReason } from '../services/documents/documents.api';
import { RejectionReason } from '../services/documents/documents.api';
import { DocumentContractStatus } from '../common/enums/document-contract-status.enum';
import Disclaimer from '../components/Disclaimer';
import { useUserProfile } from '../store/profile/profile.selector';
Expand Down Expand Up @@ -48,11 +48,12 @@ export const DocumentsContract = ({ navigation, route }: any) => {
const [isSignatureEmpty, setIsSignatureEmpty] = useState(false);

// queries
const { contract: routeContract } = route.params as { contract: IDocumentContract };
const { contractId } = route.params;
const { data: contract, isLoading: isLoadingContract } = useGetContractQuery(
routeContract.documentId,
contractId,
userProfile?.activeOrganization?.id,
);

const { mutate: signContract, isLoading: isLoadingSignContract } = useSignContractMutation();

const isUserOver16 = useMemo(
Expand Down Expand Up @@ -249,7 +250,7 @@ export const DocumentsContract = ({ navigation, route }: any) => {
return (
<PageLayout
onBackButtonPress={navigation.goBack}
title={t('contract.title', { value: routeContract.documentNumber })}
title={t('contract.title', { value: '' })}
headerStyle={{ paddingTop }}
>
<View style={styles.container}>
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/screens/DocumentsContracts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const DocumentsContracts = ({ navigation }: any) => {
}

const onContractPress = (contract: IDocumentContract) => {
navigation.navigate('documents/contract', { contract });
navigation.navigate('documents/contract', { contractId: contract.documentId });
};

return (
Expand Down
90 changes: 78 additions & 12 deletions mobile/src/screens/News.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,76 @@ const News = ({ navigation, route }: any) => {
);
}

if (item.eventName === TrackedEventName.CREATE_DOCUMENT_CONTRACT) {
return (
<NewsContent
startText={''}
organizationName={item.organizationName}
endText={`${t('item.documents.new')}`}
/>
);
}

if (item.eventName === TrackedEventName.VALIDATE_DOCUMENT_CONTRACT) {
return (
<NewsContent
startText={`${t('item.documents.validated_start')}`}
organizationName={item.organizationName}
endText={`${t('item.documents.validated_end')}`}
/>
);
}

if (item.eventName === TrackedEventName.SIGN_DOCUMENT_CONTRACT_BY_NGO) {
return (
<NewsContent
startText={`${t('item.documents.signed_start')}`}
organizationName={item.organizationName}
endText={`${t('item.documents.signed_end')}`}
/>
);
}

if (item.eventName === TrackedEventName.SIGN_DOCUMENT_CONTRACT_BY_VOLUNTEER) {
return (
<NewsContent
startText={`${t('item.documents.signed_start')}`}
organizationName={item.organizationName}
endText={`${t('item.documents.signed_end')}`}
/>
);
}

if (item.eventName === TrackedEventName.REJECT_DOCUMENT_CONTRACT_BY_NGO) {
return (
<NewsContent
startText={`${t('item.documents.rejected_start')}`}
organizationName={item.organizationName}
endText={`${t('item.documents.rejected_end')}`}
/>
);
}

if (item.eventName === TrackedEventName.REJECT_DOCUMENT_CONTRACT_BY_VOLUNTEER) {
return (
<NewsContent
startText={`${t('item.documents.rejected_volunteer_start')}`}
organizationName={item.organizationName}
endText={`${t('item.documents.rejected_volunteer_end')}`}
/>
);
}

if (item.eventName === TrackedEventName.DELETE_DOCUMENT_CONTRACT) {
return (
<NewsContent
startText={`${t('item.documents.deleted_start')}`}
organizationName={item.organizationName}
endText={`${t('item.documents.deleted_end')}`}
/>
);
}

return <></>;
};

Expand Down Expand Up @@ -198,13 +268,11 @@ const News = ({ navigation, route }: any) => {
}

if (type === NewsType.CONTRACTS) {
if (item.eventName === TrackedEventName.REJECT_CONTRACT) {
navigation.navigate('rejected-contract', {
contractId: item.contractId,
});
} else {
navigation.navigate('documents', { volunteerId: activeOrganization?.volunteerId });
// don't navigate to contract if it was deleted
if (item.eventName === TrackedEventName.DELETE_DOCUMENT_CONTRACT) {
return;
}
navigation.navigate('documents/contract', { contractId: item.contractId });
}

if (type === NewsType.ORGANIZATIONS) {
Expand All @@ -220,13 +288,11 @@ const News = ({ navigation, route }: any) => {
}

if (type === NewsType.CONTRACTS) {
if (item.eventName === TrackedEventName.REJECT_CONTRACT) {
navigation.navigate('rejected-contract', {
contractId: item.contractId,
});
} else {
navigation.navigate('documents', {});
// don't navigate to contract if it was deleted
if (item.eventName === TrackedEventName.DELETE_DOCUMENT_CONTRACT) {
return;
}
navigation.navigate('documents/contract', { contractId: item.contractId });
}

if (type === NewsType.ORGANIZATIONS) {
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/services/documents/documents.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const getContract = (
contractId: string,
organizationId: string,
): Promise<IDocumentContract> => {
const params = { contractId, organizationId };
const params = { organizationId };
return API.get(`/mobile/documents/contracts/${contractId}`, {
params,
}).then((res) => res.data);
Expand Down

0 comments on commit fb9f052

Please sign in to comment.