Skip to content

Commit 3001798

Browse files
Merge pull request #346 from AppQuality/UN-2378
feat(UN-2378): media type constraints for autoApprove campaigns in BugForm
2 parents e4019f6 + 2de62ac commit 3001798

13 files changed

Lines changed: 1364 additions & 43 deletions

File tree

src/App.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ import Page from "./Page";
1616

1717
import isStagingEnvironment from "./features/isStagingEnvironment";
1818

19+
const store = setupStore();
20+
if (process.env.NODE_ENV !== "production") {
21+
(window as any).__store = store;
22+
}
23+
1924
if (process.env.REACT_APP_GTM_ID) {
2025
TagManager.initialize({
2126
gtmId: process.env.REACT_APP_GTM_ID,
@@ -31,7 +36,7 @@ if (process.env.REACT_APP_GTM_ID) {
3136
function App() {
3237
const { t } = useTranslation();
3338
return (
34-
<Provider store={setupStore()}>
39+
<Provider store={store}>
3540
<ThemeProvider theme={aqBootstrapTheme}>
3641
<GlobalStyle />
3742
<Helmet>

src/locales/en/translation.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@
7676
"Approved bugs": "Approved bugs",
7777
"Area is a required field.": "Area is a required field.",
7878
"As first step to be done, complete your profile with authentic and real data. This is the only way to be selected for the Campaigns and get your reward.": "Enter your details in the Profile section: they are important to be selected for suitable campaign and to request the payments.",
79+
"At least one image is required": {
80+
"BUGFORM_UPLOAD_ERROR_IMAGEREQUIRED": "At least one image is required"
81+
},
82+
"At least one video is required": {
83+
"BUGFORM_UPLOAD_ERROR_VIDEOREQUIRED": "At least one video is required"
84+
},
7985
"Attribution date": "Attribution date",
8086
"Available booty": "Available booty",
8187
"Available tags \n<a> - Link to help article for fiscal type": {
@@ -555,6 +561,9 @@
555561
"BUGFORM_UPLOAD_TXT": "Upload at least {{num}} media",
556562
"BUGFORM_UPLOAD_TXT_plural": "Upload at least {{num}} media"
557563
},
564+
"Upload at least {{num}} files, including one video and one image (both are required)": {
565+
"BUGFORM_UPLOAD_TXT_VIDEO_IMAGE": "Upload at least {{num}} files, including one video and one image (both are required)"
566+
},
558567
"Uploaded Bugs": "Uploaded Bugs",
559568
"User mail validation": {
560569
"An Email has been sent to the provided address": "An Email has been sent to the provided address"

src/locales/es/translation.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@
7676
"Approved bugs": "Bugs aprobados",
7777
"Area is a required field.": "El área / La esfera es un campo obligatorio",
7878
"As first step to be done, complete your profile with authentic and real data. This is the only way to be selected for the Campaigns and get your reward.": "Añade todos tus datos en la sección Perfil: los necesitaremos para seleccionarte cuando haya una campaña adecuada y para que puedas solicitar los pagos.",
79+
"At least one image is required": {
80+
"BUGFORM_UPLOAD_ERROR_IMAGEREQUIRED": "Se requiere al menos una imagen"
81+
},
82+
"At least one video is required": {
83+
"BUGFORM_UPLOAD_ERROR_VIDEOREQUIRED": "Se requiere al menos un video"
84+
},
7985
"Attribution date": "Fecha de atribución",
8086
"Available booty": "Saldo Disponible",
8187
"Available tags \n<a> - Link to help article for fiscal type": {
@@ -555,6 +561,9 @@
555561
"BUGFORM_UPLOAD_TXT": "Sube al menos {{num}} archivo",
556562
"BUGFORM_UPLOAD_TXT_plural": "Sube al menos {{num}} archivos"
557563
},
564+
"Upload at least {{num}} files, including one video and one image (both are required)": {
565+
"BUGFORM_UPLOAD_TXT_VIDEO_IMAGE": "Sube al menos {{num}} archivos, incluyendo un video y una imagen (ambos son obligatorios)"
566+
},
558567
"Uploaded Bugs": "Bugs Cargados",
559568
"User mail validation": {
560569
"An Email has been sent to the provided address": "Se ha enviado un correo electrónico a la dirección proporcionada"

src/locales/fr/translation.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@
7676
"Approved bugs": "Bugs approuvés",
7777
"Area is a required field.": "Le domaine est un champ obligatoire.",
7878
"As first step to be done, complete your profile with authentic and real data. This is the only way to be selected for the Campaigns and get your reward.": "Indiquez vos coordonnées dans la section Profil : elles sont importantes pour être sélectionné pour des campagnes adaptées et pour demander les paiements.",
79+
"At least one image is required": {
80+
"BUGFORM_UPLOAD_ERROR_IMAGEREQUIRED": "Au moins une image est requise"
81+
},
82+
"At least one video is required": {
83+
"BUGFORM_UPLOAD_ERROR_VIDEOREQUIRED": "Au moins une vidéo est requise"
84+
},
7985
"Attribution date": "Date d'attribution",
8086
"Available booty": "Butin disponible",
8187
"Available tags \n<a> - Link to help article for fiscal type": {
@@ -338,7 +344,7 @@
338344
"Manufacturer: <bold>{{manufacturer}}</bold>": "Fabricant : <bold>{{manufacturer}}</bold>",
339345
"Mark as completed": "",
340346
"Media field must have at least {{num}} items": {
341-
"BUGFORM_UPLOAD_ERROR_MINIMUMFILES": "Vous devez télécharger au moins {{num}} médias pour cette campagne",
347+
"BUGFORM_UPLOAD_ERROR_MINIMUMFILES": "Vous devez télécharger au moins {{num}} média pour cette campagne",
342348
"BUGFORM_UPLOAD_ERROR_MINIMUMFILES_plural": "Vous devez télécharger au moins {{num}} médias pour cette campagne"
343349
},
344350
"Messages for you": "Messages pour vous",
@@ -552,9 +558,12 @@
552558
"USECASE_MEDIA_DROPZONE_MISSING_PARAMS": "Informations de campagne ou de tâche manquantes.",
553559
"Update your device list": "Mettez à jour votre liste d'appareils",
554560
"Upload a minimum number of {{num}} files": {
555-
"BUGFORM_UPLOAD_TXT": "Téléchargez au moins {{num}} médias",
561+
"BUGFORM_UPLOAD_TXT": "Téléchargez au moins {{num}} média",
556562
"BUGFORM_UPLOAD_TXT_plural": "Téléchargez au moins {{num}} médias"
557563
},
564+
"Upload at least {{num}} files, including one video and one image (both are required)": {
565+
"BUGFORM_UPLOAD_TXT_VIDEO_IMAGE": "Téléchargez au moins {{num}} fichiers, dont une vidéo et une image (les deux sont obligatoires)"
566+
},
558567
"Uploaded Bugs": "Bugs téléchargés",
559568
"User mail validation": {
560569
"An Email has been sent to the provided address": "Un email a été envoyé à l'adresse fournie"

src/locales/it/translation.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@
7676
"Approved bugs": "Bug approvati",
7777
"Area is a required field.": "L'area è un campo obbligatorio",
7878
"As first step to be done, complete your profile with authentic and real data. This is the only way to be selected for the Campaigns and get your reward.": "Inserisci tutti i tuoi dati nella sezione Profilo: servirà a noi per selezionarti quando c'è una campagna adatta e a te per richiedere il pagamento.",
79+
"At least one image is required": {
80+
"BUGFORM_UPLOAD_ERROR_IMAGEREQUIRED": "È richiesta almeno un'immagine"
81+
},
82+
"At least one video is required": {
83+
"BUGFORM_UPLOAD_ERROR_VIDEOREQUIRED": "È richiesto almeno un video"
84+
},
7985
"Attribution date": "Data di attribuzione",
8086
"Available booty": "Guadagni disponibili",
8187
"Available tags \n<a> - Link to help article for fiscal type": {
@@ -555,6 +561,9 @@
555561
"BUGFORM_UPLOAD_TXT": "Carica almeno {{num}} file",
556562
"BUGFORM_UPLOAD_TXT_plural": "Carica almeno {{num}} file"
557563
},
564+
"Upload at least {{num}} files, including one video and one image (both are required)": {
565+
"BUGFORM_UPLOAD_TXT_VIDEO_IMAGE": "Carica almeno {{num}} file, inclusi un video e un'immagine (entrambi obbligatori)"
566+
},
558567
"Uploaded Bugs": "Bug caricati",
559568
"User mail validation": {
560569
"An Email has been sent to the provided address": "Un'email è stata inviata all'indirizzo fornito"

src/pages/BugForm/BugFormContainer.tsx

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ export const BugFormContainer = () => {
9494
);
9595
}
9696

97+
const needsVideoAndImage =
98+
data?.autoApprove === 1 && (data?.minimumMedia || 0) > 1;
99+
97100
const validationSchema = {
98101
title: yup.string().required(t("This is a required field")),
99102
severity: yup.string().required(t("This is a required field")),
@@ -115,17 +118,45 @@ export const BugFormContainer = () => {
115118
.required(t("BUGFORM_BUGDTLS_TYPE_ERROR", "This is a required field")),
116119
expected: yup.string().required(t("This is a required field")),
117120
current: yup.string().required(t("This is a required field")),
118-
media: yup.array().min(
119-
data?.minimumMedia || 0,
120-
t(
121-
"Media field must have at least {{num}} items:::BUGFORM_UPLOAD_ERROR_MINIMUMFILES",
122-
{
123-
defaultValue: "Media field must have at least {{num}} items",
124-
num: data?.minimumMedia || 0,
125-
count: data?.minimumMedia,
121+
media: yup
122+
.array()
123+
.min(
124+
data?.minimumMedia || 0,
125+
t(
126+
"Media field must have at least {{num}} items:::BUGFORM_UPLOAD_ERROR_MINIMUMFILES",
127+
{
128+
defaultValue: "Media field must have at least {{num}} items",
129+
num: data?.minimumMedia || 0,
130+
count: data?.minimumMedia,
131+
}
132+
)
133+
)
134+
.test(
135+
"has-video",
136+
t(
137+
"At least one video is required:::BUGFORM_UPLOAD_ERROR_VIDEOREQUIRED",
138+
{ defaultValue: "At least one video is required" }
139+
),
140+
() => {
141+
if (!needsVideoAndImage) return true;
142+
return mediaList.some(
143+
(m) => m.status === "success" && m.fileType === "video"
144+
);
126145
}
127146
)
128-
),
147+
.test(
148+
"has-image",
149+
t(
150+
"At least one image is required:::BUGFORM_UPLOAD_ERROR_IMAGEREQUIRED",
151+
{ defaultValue: "At least one image is required" }
152+
),
153+
() => {
154+
if (!needsVideoAndImage) return true;
155+
return mediaList.some(
156+
(m) => m.status === "success" && m.fileType === "image"
157+
);
158+
}
159+
),
129160
additional: yup.object(),
130161
};
131162
if (data.titleRule) {

src/pages/BugForm/FileUploader/index.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,27 @@ export const FileUploader = () => {
2424
const { data } = useCampaignData();
2525
const { t } = useTranslation();
2626

27+
const needsVideoAndImage =
28+
data?.autoApprove === 1 && (data?.minimumMedia || 0) > 1;
29+
2730
return (
2831
<Card
2932
title={t("BUGFORM_UPLOAD_TITLE", { defaultValue: "Uploading media" })}
3033
>
3134
<Text className="aq-text-primaryVariant">
32-
<Trans
33-
i18nKey="Upload a minimum number of {{num}} files:::BUGFORM_UPLOAD_TXT"
34-
values={{
35+
{needsVideoAndImage ? (
36+
<Trans
37+
i18nKey="Upload at least {{num}} files, including one video and one image (both are required):::BUGFORM_UPLOAD_TXT_VIDEO_IMAGE"
38+
values={{ num: data?.minimumMedia || 0 }}
39+
defaults="Upload at least {{num}} files, including one video and one image (both are required)"
40+
/>
41+
) : (
42+
t("Upload a minimum number of {{num}} files:::BUGFORM_UPLOAD_TXT", {
43+
defaultValue: "Upload at least {{num}} media",
3544
num: data?.minimumMedia || 0,
36-
}}
37-
tOptions={{ count: data?.minimumMedia }}
38-
count={data?.minimumMedia}
39-
defaults={"Upload a minimum number of {{num}} files"}
40-
/>
45+
count: data?.minimumMedia,
46+
})
47+
)}
4148
</Text>
4249
<StyledFilesTypes className="aq-mb-3">
4350
<FileType className="file-type-margin" type="image" />

0 commit comments

Comments
 (0)