Skip to content

Commit 1b357b0

Browse files
GuevaraMariusSIBONIYO
authored andcommitted
feature: CRUD operation for routes
1 parent 4c004cc commit 1b357b0

File tree

16 files changed

+988
-102
lines changed

16 files changed

+988
-102
lines changed

public/locales/en/translation.js

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ export default {
99
webtitle: 'Phantom | Public transport made easier',
1010
title: 'WELCOME TO PHANTOM',
1111
description: {
12-
slogan: " Track your Bus' movements anywhere from your device.",
12+
slogan: " Track your route' movements anywhere from your device.",
1313
startBtn: 'Start tracking!'
1414
},
1515
about: {
1616
title:
17-
'Fostering fast movement with Phantom. We simulate your next bus enabling you to track your movement',
18-
1: ' Real time tracking your next bus accordingly and set when your schedule accordingly',
19-
2: "Easily identify and follow your bus on the map. Leave for the bus when it's actually close.",
20-
3: 'Real time tracking your next bus accordingly and set when your schedule accordingly',
21-
4: "Easily identify and follow your bus on the map. Leave for the bus when it's actually close."
17+
'Fostering fast movement with Phantom. We simulate your next route enabling you to track your movement',
18+
1: ' Real time tracking your next route accordingly and set when your schedule accordingly',
19+
2: "Easily identify and follow your route on the map. Leave for the route when it's actually close.",
20+
3: 'Real time tracking your next route accordingly and set when your schedule accordingly',
21+
4: "Easily identify and follow your route on the map. Leave for the route when it's actually close."
2222
},
2323
contact: {
2424
title: 'Contact Us:',
@@ -90,5 +90,32 @@ export default {
9090
operators: 'Operators',
9191
settings: 'Settings',
9292
profile: 'Profile'
93-
}
93+
},
94+
routes: {
95+
Route: 'ROUTES',
96+
RouteId: 'Route ID',
97+
create: 'Create route',
98+
Origin: 'Origin',
99+
Distance:'Disatance',
100+
BusStop:'Bus Stop',
101+
Destination:'Destination',
102+
AssignedBus:'Assigned Bus',
103+
Action:'Action',
104+
created: 'route created successfully',
105+
updated: 'route updated successfully',
106+
already: 'route already exists',
107+
number: 'Numbers cannot be route',
108+
short: 'That cannot be a route',
109+
confirm: 'Are you sure you want to delete this route ',
110+
deleted: 'route deleted successfully',
111+
cancel: 'Cancel',
112+
delete: 'Delete',
113+
confirm: 'Confirm',
114+
yes: 'Yes',
115+
no: 'No',
116+
edit: 'Edit route',
117+
edited: 'Route edited Successfully',
118+
editRoute:`Edit Route`,
119+
save: 'Save',
120+
}
94121
};

public/locales/fr/translation.js

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -78,53 +78,11 @@ export default {
7878
yes: 'Oui',
7979
no: 'Non'
8080
},
81-
forgot: {
82-
title: 'Mot de passe oublié?',
83-
placeHolder: 'Entrer votre Email',
84-
paragraph:
85-
'En cliquant sur le bouton Envoyez-moi un lien de réinitialisation, nous vous donnerons des instructions pour réinitialiser le mot de passe dans votre boîte aux lettres.',
86-
btn: 'Envoyez-moi le lien de réinitialisation',
87-
back: 'Retour connexion',
88-
success: 'Vérifiez votre email',
89-
fail: 'Aucun utilisateur trouvé avec cette adresse e-mail',
90-
error: "Une erreur s'est produite, vérifiez votre réseau et réessayez"
91-
},
92-
reset: {
93-
title: 'Réinitialiser le mot de passe',
94-
newPassword: 'Entrez un nouveau mot de passe',
95-
comfirmPassword: 'Confirmer le nouveau mot de passe',
96-
paragraph:
97-
"Une fois le mot de passe réinitialisé, vous pouvez vous connecter à l'aide de votre nouveau mot de passe.",
98-
btn: 'Réinitialiser le mot de passe',
99-
success: 'Votre mot de passe a été réinitialisé avec succès',
100-
fail: 'Non autorisé, votre lien est expiré demande à nouveau',
101-
error: "Une erreur s'est produite, vérifiez votre réseau et réessayez"
102-
},
10381
validation: {
10482
invalidEmail: "L'email n'est pas valide",
10583
invalidPassword: "Le mot de passe n'est pas valide",
10684
invalidComfirm: 'Vos mots de passe ne correspondent pas'
10785
},
108-
signin: {
109-
title: 'Se Connecter',
110-
email: 'Adresse e-mail',
111-
password: 'Mot de passe',
112-
sendBtn: 'Envoyer',
113-
forgotPassword: 'Mot de passe oublié?',
114-
yourEmail: 'votre email...',
115-
yourPassword: 'votre mot de passe..',
116-
errorEmail: 'Votre e-mail doit être valide; exemple: "[email protected]"',
117-
errorPassword: 'Le mot de passe ne peuvent pas être vides',
118-
errorPass:
119-
'Le mot de passe doit comporter au moins 5 caractères, dont 4 lettres et chiffres'
120-
},
121-
logout: {
122-
confirm: `ÊTES-VOUS SÛR DE VOULOIR VOUS DÉCONNECTER`,
123-
profile: 'Profile',
124-
logout: 'Se deconnecte',
125-
yes: 'Oui',
126-
no: 'Non'
127-
},
12886
sideBar: {
12987
overView: 'Aperçu',
13088
roles: 'Conducteurs',
@@ -134,5 +92,30 @@ export default {
13492
operators: 'Operateurs',
13593
settings: 'Réglages',
13694
profile: 'Profil'
137-
}
95+
},
96+
routes: {
97+
Route: 'ITINÉRAIRES',
98+
RouteId: 'Numéro de Route',
99+
Destination:'Destination',
100+
Distance:'Disatance',
101+
BusStop:'Arrêt Bus',
102+
AssignedBus:'Assignation',
103+
Action:'Action',
104+
create: 'Crééer une itinéraire',
105+
Origin: 'Origine',
106+
created: 'Itinéraire est Crééé avec succès',
107+
updated: `La mise à jour de l'itinéraire est réussie`,
108+
already: 'itinéraire existe déjà',
109+
confirm: 'Êtes-vous sûr de vouloir supprimer cet itinéraire',
110+
deleted: 'Itinéraire est supriméé avec succès',
111+
cancel: 'Annuler',
112+
delete: 'Effacer',
113+
confirm: 'Confirmer',
114+
yes: 'Oui',
115+
no: 'Non',
116+
edit: 'Éditer',
117+
edited: 'Itinéraire éditée',
118+
editRoute:`Éditer l'itinéraire avec succès`,
119+
save: 'Sauvegarder',
120+
}
138121
};

public/locales/kin/translation.js

Lines changed: 26 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -79,55 +79,11 @@ export default {
7979
yes: 'Yego',
8080
no: 'Hoya'
8181
},
82-
forgot: {
83-
title: 'Wibagiwe Ijambobanga?',
84-
placeHolder: 'Injiza Email Yawe',
85-
paragraph:
86-
'Numara gukanda kuri Saba guhindura, inzira yo guhindura ijambobanga turayikoherereza kuri email yawe',
87-
btn: 'Ohereza Ubusabe',
88-
back: 'Subira kwinjira',
89-
success: 'Byagenze neza Reba muri email yawe',
90-
fail: 'Ntamuntu wagaragaye ukoresha iyo email',
91-
error: 'Habayemo ikibazo reba niba ufite murandasi wongere ugerageze'
92-
},
93-
reset: {
94-
title: 'Hindura Ijambobanga',
95-
newPassword: 'Injiza ijambobanga rishya',
96-
comfirmPassword: 'Subiramo ijambobanga rishya',
97-
paragraph:
98-
' Numara gukora ijambobanga rishya niryo uzajya ukoresha winjira.',
99-
btn: 'Hindura Ijambobanga',
100-
success: 'Your password reset successfully',
101-
fail: 'Ntago wemerewe. inzira yawe ishobora kuba ishaje, ongera usabe',
102-
error: 'Habayemo ikibazo reba niba ufite murandasi wongere ugerageze'
103-
},
10482
validation: {
10583
invalidEmail: 'Email ntago yemewe',
10684
invalidPassword: 'Ijambobanga ntiryemewe',
10785
invalidComfirm: 'Amajambobanga ntago asa'
10886
},
109-
signin: {
110-
title: 'Injira',
111-
email: 'Imeyili yawe',
112-
password: 'Ijambobanga',
113-
sendBtn: 'Ohereza',
114-
forgotPassword: 'Mwibagiwe Ijambobanga?',
115-
yourEmail: 'Emeyili yanyu...',
116-
yourPassword: 'Ijambobanga ryanyu...',
117-
errorEmail:
118-
'Imeri yawe igomba kuba ifite agaciro; urugero: "[email protected]"',
119-
errorPassword: 'Ijambobanga ntirishobora kuba ubusa',
120-
errorPass:
121-
'Ijambobanga rigomba kuba byibuze inyuguti 5 zirimo inyuguti 4 nimibare'
122-
},
123-
logout: {
124-
confirm: `
125-
ESE KOKO USHAKA GUSOHOKA ?`,
126-
profile: 'Umwirondoro',
127-
logout: 'Gusohoka',
128-
yes: 'Yego',
129-
no: 'Hoya'
130-
},
13187
sideBar: {
13288
overView: 'Incamake',
13389
roles: 'Inshingano',
@@ -137,5 +93,30 @@ export default {
13793
operators: 'Abakoresha',
13894
settings: 'Igenamiterere',
13995
profile: 'Umwirondoro'
140-
}
96+
},
97+
routes: {
98+
Route: 'IMIHANDA',
99+
RouteId: `Umuhanda`,
100+
create: 'Kora Umuhanda',
101+
Origin: 'Itangiriro',
102+
Destination:'Iherezo',
103+
Distance:'Uburebure',
104+
BusStop:'Icyapa',
105+
AssignedBus:'Uyishinzwe',
106+
Action:'Igikorwa',
107+
created: 'Umuhanda wakozwe neza',
108+
updated: 'Umuhanda wavuguruwe neza',
109+
already: 'Umuhanda usanzwe ubaho',
110+
confirm: 'Urashaka gusiba umuhanda?',
111+
deleted: 'Gusiba umuhanda byemeye',
112+
cancel: 'Kubireka',
113+
delete: 'Siba',
114+
confirm: 'Emeza',
115+
yes: 'Yego',
116+
no: 'Hoya',
117+
edit: 'Guhindura',
118+
edited: 'Umuhanda wahinduwe neza',
119+
editRoute:`Hindura Umuhanda`,
120+
save: 'BIKA',
121+
}
141122
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const token = localStorage.getItem('authToken');
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import React, { useState } from 'react';
2+
import { toast } from 'react-toastify';
3+
import { useDispatch } from 'react-redux';
4+
import { createRouteAction } from '../../../redux/actionCreators/routesAction';
5+
import './Routes.scss';
6+
import {Trans} from 'react-i18next';
7+
8+
export const AddRoute = () => {
9+
const dispatch = useDispatch();
10+
const [open, setOpen] = React.useState(false);
11+
const [newRoute, setNewRoute] = useState({
12+
origin: '',
13+
destination: '',
14+
distance:'',
15+
});
16+
17+
const handleChange = ({ target }) => {
18+
const { name, value } = target;
19+
setNewRoute((newRoute) => ({ ...newRoute, [name]: value }));
20+
};
21+
22+
const modalContainerStyle = {
23+
display: open ? 'flex' : 'none'
24+
};
25+
26+
const handleOpen = () => {
27+
setOpen(true);
28+
};
29+
30+
const handleClose = () => {
31+
setOpen(false);
32+
};
33+
34+
const validation = () => {
35+
if (!isNaN(newRoute)) {
36+
toast.warning(<Trans i18nKey=''></Trans>);
37+
} else if (isNaN(newRoute) && newRoute.length <= 3) {
38+
toast.warning(<Trans i18nKey=''></Trans>);
39+
} else {
40+
return true;
41+
}
42+
};
43+
44+
const createRoute = () => {
45+
if (validation()) {
46+
dispatch(createRouteAction(newRoute));
47+
toast.success(<Trans i18nKey='routes.created'></Trans>);
48+
handleClose();
49+
}
50+
};
51+
52+
return (
53+
<>
54+
<button data-testid='show-btn' type='button' onClick={handleOpen}>
55+
+
56+
</button>
57+
<div style={modalContainerStyle} className='modal-container'>
58+
<div className='modal'>
59+
<h2>
60+
{<Trans i18nKey='routes.create'></Trans>}
61+
</h2>
62+
<form
63+
data-testid='form'
64+
onSubmit={(e) => {
65+
e.preventDefault();
66+
createRoute();
67+
}}
68+
>
69+
<input
70+
type='text'
71+
data-testid='route'
72+
placeholder='Origin'
73+
onChange={handleChange}
74+
value={newRoute.origin}
75+
autoFocus
76+
name='origin'
77+
required
78+
/>
79+
<input
80+
type='text'
81+
data-testid='route'
82+
placeholder='destination'
83+
onChange={handleChange}
84+
name='destination'
85+
value={newRoute.destination}
86+
autoFocus
87+
required
88+
/>
89+
<input
90+
type='text'
91+
data-testid='route'
92+
placeholder='Distance'
93+
onChange={handleChange}
94+
name='distance'
95+
value={newRoute.distance}
96+
autoFocus
97+
required
98+
/>
99+
100+
<button type='submit'>{<Trans i18nKey='routes.create'></Trans>}</button>
101+
<button
102+
style={{ backgroundColor: '#fb5b5b' }}
103+
type='button'
104+
onClick={handleClose}
105+
>
106+
{<Trans i18nKey='routes.cancel'></Trans>}
107+
</button>
108+
</form>
109+
</div>
110+
</div>
111+
</>
112+
);
113+
};
114+
115+
export default AddRoute;

0 commit comments

Comments
 (0)