Added conversion logic for ROs. Blanket translations for files.

This commit is contained in:
Patrick Fic
2020-01-14 11:58:37 -08:00
parent bee4f630c4
commit e4693685fe
29 changed files with 2783 additions and 185 deletions

View File

@@ -15,7 +15,7 @@ import {
Avatar,
Layout
} from "antd";
import { UPDATE_JOB } from "../../graphql/jobs.queries";
import { UPDATE_JOB, CONVERT_JOB_TO_RO } from "../../graphql/jobs.queries";
import { useMutation } from "@apollo/react-hooks";
import FormItemPhone from "../form-items-formatted/phone-form-item.component";
import { useTranslation } from "react-i18next";
@@ -36,6 +36,7 @@ const formItemLayout = {
function JobTombstone({ job, ...otherProps }) {
const [jobContext, setJobContext] = useState(job);
const [mutationUpdateJob] = useMutation(UPDATE_JOB);
const [mutationConvertJob] = useMutation(CONVERT_JOB_TO_RO);
const { t } = useTranslation();
if (!job) {
@@ -95,11 +96,31 @@ function JobTombstone({ job, ...otherProps }) {
}
tags={<Tag color='blue'>{jobContext?.job_status?.name}</Tag>}
extra={[
<Form.Item key='1'>
<Button type='primary' htmlType='submit'>
{t("general.labels.save")}
</Button>
</Form.Item>
<Button
key='convert'
type='dashed'
disabled={!jobContext.converted}
onClick={() => {
mutationConvertJob({
variables: { jobId: jobContext.id }
}).then(r => {
console.log("r", r);
setJobContext({
...jobContext,
converted: true,
ro_number: r.data.update_jobs.returning[0].ro_number
});
notification["success"]({
message: t("jobs.successes.converted")
});
});
}}>
{t("jobs.labels.convert")}
</Button>,
<Button type='primary' key='submit' htmlType='submit'>
{t("general.labels.save")}
</Button>
]}>
<Descriptions size='small' column={5}>
<Descriptions.Item label={t("jobs.fields.vehicle")}>

View File

@@ -9,55 +9,56 @@ const errorLink = onError(
console.log("networkError", networkError);
console.log("operation", operation);
console.log("forward", forward);
//if (graphQLErrors) {
// User access token has expired
if (networkError.message.includes("JWTExpired")) {
console.log("Got to the error check.");
if (access_token && access_token !== "undefined") {
// Let's refresh token through async request
return new Observable(observer => {
auth.currentUser
.getIdToken(true)
.then(function(idToken) {
if (!idToken) {
window.localStorage.removeItem("token");
return console.log("Refresh token has expired");
}
console.log("Got a new token", idToken);
window.localStorage.setItem("token", idToken);
// reset the headers
operation.setContext(({ headers = {} }) => ({
headers: {
// Re-add old headers
...headers,
// Switch out old access token for new one
authorization: idToken ? `Bearer ${idToken}` : ""
}
}));
// const subscriber = {
// next: observer.next.bind(observer),
// error: observer.error.bind(observer),
// complete: observer.complete.bind(observer)
// };
console.log("About to resend the request.");
// Retry last failed request
forward(operation); //.subscribe(subscriber);
})
.catch(error => {
// No refresh or client token available, we force user to login
console.log("Hit an error.");
observer.error(error);
});
});
}
if (graphQLErrors) {
//User access token has expired
console.log("graphQLErrors", graphQLErrors);
}
//}
if (networkError) {
console.log(`[Network error]: ${networkError}`);
//props.history.push("/network-error");
if (networkError.message.includes("JWTExpired")) {
console.log("Got to the error check.");
if (access_token && access_token !== "undefined") {
// Let's refresh token through async request
return new Observable(observer => {
auth.currentUser
.getIdToken(true)
.then(function(idToken) {
if (!idToken) {
window.localStorage.removeItem("token");
return console.log("Refresh token has expired");
}
console.log("Got a new token", idToken);
window.localStorage.setItem("token", idToken);
// reset the headers
operation.setContext(({ headers = {} }) => ({
headers: {
// Re-add old headers
...headers,
// Switch out old access token for new one
authorization: idToken ? `Bearer ${idToken}` : ""
}
}));
// const subscriber = {
// next: observer.next.bind(observer),
// error: observer.error.bind(observer),
// complete: observer.complete.bind(observer)
// };
console.log("About to resend the request.");
// Retry last failed request
forward(operation); //.subscribe(subscriber);
})
.catch(error => {
// No refresh or client token available, we force user to login
console.log("Hit an error.");
observer.error(error);
});
});
}
}
}
}
);

View File

@@ -272,3 +272,15 @@ export const UPDATE_JOB = gql`
}
}
`;
export const CONVERT_JOB_TO_RO = gql`
mutation CONVERT_JOB_TO_RO($jobId: uuid!) {
update_jobs(where: { id: { _eq: $jobId } }, _set: { converted: true }) {
returning {
id
ro_number
converted
}
}
}
`;

View File

@@ -1,110 +1,108 @@
{
"translation": {
"general": {
"languages": {
"english": "English",
"french": "French",
"spanish": "Spanish"
},
"labels": {
"in": "In",
"out": "Out",
"na": "N/A",
"unknown": "Unknown",
"save": "Save",
"loading": "Loading..."
}
},
"menus": {
"currentuser": {
"profile": "Profile",
"languageselector": "Language"
},
"profilesidebar": {
"profile": "My Profile",
"shops": "My Shops"
}
},
"titles": {
"app": "Bodyshop by ImEX Systems",
"jobs": "All Jobs | $t(titles.app)",
"jobsdetail": "Job {{ro_number}} | $t(titles.app)",
"profile": "My Profile | $t(titles.app)"
},
"profile": {
"errors": {
"state": "Error reading page state. Please refresh."
}
},
"vehicles": {
"fields": {
"plate_no": "License Plate"
}
},
"notes": {
"labels": {
"newnoteplaceholder": "Add a note..."
},
"fields": {
"critical": "Critical",
"private": "Private",
"text": "Contents"
}
},
"jobs": {
"labels": {
"cards": {
"customer": "Customer Information",
"vehicle": "Vehicle",
"insurance": "Insurance Details",
"dates": "Dates",
"documents": "Documents",
"parts": "Parts",
"notes": "Notes",
"damage": "Area of Damage",
"totals": "Totals",
"filehandler": "File Handler",
"appraiser": "Appraiser",
"estimator": "Estimator"
},
"vehicle_info": "Vehicle"
},
"fields": {
"ro_number": "RO #",
"est_number": "Estimate Number",
"clm_total": "Claim Total",
"deductible": "Deductible",
"owner": "Owner",
"status": "Job Status",
"vehicle": "Vehicle",
"phone1": "Phone 1",
"clm_no": "Claim #",
"owner_owing": "Cust. Owes"
},
"successes": {
"save": "Record Saved",
"savetitle": "Record saved succesfully."
},
"errors": {
"noaccess": "This job does not exist or you do not have access to it.",
"validationtitle": "Validation Error",
"validation": "Please ensure all fields are entered correctly.",
"saving": "Error encountered while saving record.",
"nojobselected": "No job is selected.",
"noowner": "No owner associated.",
"novehicle": "No vehicle associated."
},
"actions": {
"addDocuments": "Add Job Documents",
"printCenter": "Print Center",
"postInvoices": "Post Invoices",
"addNote": "Add Note"
}
}
}
"translation": {
"general": {
"labels": {
"in": "In",
"loading": "Loading...",
"na": "N/A",
"out": "Out",
"save": "Save",
"unknown": "Unknown"
},
"languages": {
"english": "English",
"french": "French",
"spanish": "Spanish"
}
},
"jobs": {
"actions": {
"addDocuments": "Add Job Documents",
"addNote": "Add Note",
"postInvoices": "Post Invoices",
"printCenter": "Print Center"
},
"errors": {
"noaccess": "This job does not exist or you do not have access to it.",
"nojobselected": "No job is selected.",
"noowner": "No owner associated.",
"novehicle": "No vehicle associated.",
"saving": "Error encountered while saving record.",
"validation": "Please ensure all fields are entered correctly.",
"validationtitle": "Validation Error"
},
"fields": {
"claim_total": "Claim Total",
"clm_no": "Claim #",
"clm_total": "Claim Total",
"deductible": "Deductible",
"est_number": "Estimate Number",
"owner": "Owner",
"owner_owing": "Cust. Owes",
"phone1": "Phone 1",
"ro_number": "RO #",
"status": "Job Status",
"vehicle": "Vehicle"
},
"labels": {
"cards": {
"appraiser": "Appraiser",
"customer": "Customer Information",
"damage": "Area of Damage",
"dates": "Dates",
"documents": "Documents",
"estimator": "Estimator",
"filehandler": "File Handler",
"insurance": "Insurance Details",
"notes": "Notes",
"parts": "Parts",
"totals": "Totals",
"vehicle": "Vehicle"
},
"convert": "Convert",
"vehicle_info": "Vehicle"
},
"successes": {
"converted": "Job converted successfully.",
"save": "Record Saved",
"savetitle": "Record saved successfully."
}
},
"menus": {
"currentuser": {
"languageselector": "Language",
"profile": "Profile"
},
"profilesidebar": {
"profile": "My Profile",
"shops": "My Shops"
}
},
"notes": {
"fields": {
"critical": "Critical",
"private": "Private",
"text": "Contents"
},
"labels": {
"newnoteplaceholder": "Add a note..."
}
},
"profile": {
"errors": {
"state": "Error reading page state. Please refresh."
}
},
"titles": {
"app": "Bodyshop by ImEX Systems",
"jobs": "All Jobs | $t(titles.app)",
"jobsdetail": "Job {{ro_number}} | $t(titles.app)",
"profile": "My Profile | $t(titles.app)"
},
"vehicles": {
"fields": {
"plate_no": "License Plate"
}
}
}
}

View File

@@ -1,9 +1,108 @@
{
"translation": {
"general": {
"title": "Hola a {{framework}}",
"greetings": "Hola!",
"intro": "To get started, edit <1><0></0></1> and save to reload."
}
}
"translation": {
"general": {
"labels": {
"in": "en",
"loading": "Cargando...",
"na": "N / A",
"out": "Afuera",
"save": "Salvar",
"unknown": "Desconocido"
},
"languages": {
"english": "Inglés",
"french": "francés",
"spanish": "español"
}
},
"jobs": {
"actions": {
"addDocuments": "Agregar documentos de trabajo",
"addNote": "Añadir la nota",
"postInvoices": "Contabilizar facturas",
"printCenter": "Centro de impresión"
},
"errors": {
"noaccess": "Este trabajo no existe o no tiene acceso a él.",
"nojobselected": "No hay trabajo seleccionado.",
"noowner": "Ningún propietario asociado.",
"novehicle": "No hay vehículo asociado.",
"saving": "Se encontró un error al guardar el registro.",
"validation": "Asegúrese de que todos los campos se ingresen correctamente.",
"validationtitle": "Error de validacion"
},
"fields": {
"claim_total": "Reclamar total",
"clm_no": "Reclamación #",
"clm_total": "Reclamar total",
"deductible": "Deducible",
"est_number": "Numero Estimado",
"owner": "Propietario",
"owner_owing": "Cust. Debe",
"phone1": "Teléfono 1",
"ro_number": "RO #",
"status": "Estado del trabajo",
"vehicle": "Vehículo"
},
"labels": {
"cards": {
"appraiser": "Tasador",
"customer": "Información al cliente",
"damage": "Área de Daño",
"dates": "fechas",
"documents": "documentos",
"estimator": "Estimador",
"filehandler": "File Handler",
"insurance": "detalles del seguro",
"notes": "Notas",
"parts": "Partes",
"totals": "Totales",
"vehicle": "Vehículo"
},
"convert": "Convertir",
"vehicle_info": "Vehículo"
},
"successes": {
"converted": "Trabajo convertido con éxito.",
"save": "Registro guardado",
"savetitle": "Registro guardado con éxito."
}
},
"menus": {
"currentuser": {
"languageselector": "idioma",
"profile": "Perfil"
},
"profilesidebar": {
"profile": "Mi perfil",
"shops": "Mis tiendas"
}
},
"notes": {
"fields": {
"critical": "Crítico",
"private": "Privado",
"text": "Contenido"
},
"labels": {
"newnoteplaceholder": "Agrega una nota..."
}
},
"profile": {
"errors": {
"state": "Error al leer el estado de la página. Porfavor refresca."
}
},
"titles": {
"app": "Carrocería de ImEX Systems",
"jobs": "Todos los trabajos | $t(titles.app)",
"jobsdetail": "Trabajo {{ro_number}} | $t(titles.app)",
"profile": "Mi perfil | $ t (títulos.app)"
},
"vehicles": {
"fields": {
"plate_no": "Placa"
}
}
}
}

View File

@@ -1,22 +1,108 @@
{
"translation": {
"general": {
"languages": {
"english": "Anglais",
"french": "Francais",
"spanish": "Espanol"
},
"title": "Welcome to {{framework}}",
"greetings": "Hello2!",
"intro": "To get started, edit <1><0></0></1> and save to reload."
},
"whiteboard": {
"viewJobImages": "Viewez le Job Images",
"printCenter": "Printez Centre",
"postInvoices": "Postez le Invoices",
"notes": "Le Job Notes",
"partStatus": "Status de Parts",
"receiveParts": "Receive Parts"
}
}
"translation": {
"general": {
"labels": {
"in": "dans",
"loading": "Chargement...",
"na": "N / A",
"out": "En dehors",
"save": "sauvegarder",
"unknown": "Inconnu"
},
"languages": {
"english": "Anglais",
"french": "Francais",
"spanish": "Espanol"
}
},
"jobs": {
"actions": {
"addDocuments": "Ajouter des documents de travail",
"addNote": "Ajouter une note",
"postInvoices": "Poster des factures",
"printCenter": "Centre d'impression"
},
"errors": {
"noaccess": "Ce travail n'existe pas ou vous n'y avez pas accès.",
"nojobselected": "Aucun travail n'est sélectionné.",
"noowner": "Aucun propriétaire associé.",
"novehicle": "Aucun véhicule associé.",
"saving": "Erreur rencontrée lors de la sauvegarde de l'enregistrement.",
"validation": "Veuillez vous assurer que tous les champs sont correctement entrés.",
"validationtitle": "Erreur de validation"
},
"fields": {
"claim_total": "Total réclamation",
"clm_no": "Prétendre #",
"clm_total": "Total réclamation",
"deductible": "Déductible",
"est_number": "Numéro d'estimation",
"owner": "Propriétaire",
"owner_owing": "Cust. Owes",
"phone1": "Téléphone 1",
"ro_number": "RO #",
"status": "Statut de l'emploi",
"vehicle": "Véhicule"
},
"labels": {
"cards": {
"appraiser": "Expert",
"customer": "Informations client",
"damage": "Zone de dommages",
"dates": "Rendez-vous",
"documents": "Les documents",
"estimator": "Estimateur",
"filehandler": "Gestionnaire de fichiers",
"insurance": "Détails de l'assurance",
"notes": "Remarques",
"parts": "les pièces",
"totals": "Totaux",
"vehicle": "Véhicule"
},
"convert": "Convertir",
"vehicle_info": "Véhicule"
},
"successes": {
"converted": "Travail converti avec succès.",
"save": "Enregistrement enregistré",
"savetitle": "Enregistrement enregistré avec succès."
}
},
"menus": {
"currentuser": {
"languageselector": "La langue",
"profile": "Profil"
},
"profilesidebar": {
"profile": "Mon profil",
"shops": "Mes boutiques"
}
},
"notes": {
"fields": {
"critical": "Critique",
"private": "privé",
"text": "Contenu"
},
"labels": {
"newnoteplaceholder": "Ajouter une note..."
}
},
"profile": {
"errors": {
"state": "Erreur lors de la lecture de l'état de la page. Rafraichissez, s'il vous plait."
}
},
"titles": {
"app": "Carrosserie par ImEX Systems",
"jobs": "Tous les emplois | $t(titles.app)",
"jobsdetail": "Travail {{ro_number}} | $t(titles.app)",
"profile": "Mon profil | $ t (titres.app)"
},
"vehicles": {
"fields": {
"plate_no": "Plaque d'immatriculation"
}
}
}
}