Skip to content

Commit

Permalink
refactor: ♻️ refactoring files and folders
Browse files Browse the repository at this point in the history
  • Loading branch information
nutfdt committed Dec 17, 2024
1 parent 589b489 commit 35a5c84
Show file tree
Hide file tree
Showing 31 changed files with 70 additions and 215 deletions.
23 changes: 0 additions & 23 deletions backend/src/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,29 +177,6 @@ async def log_tutorial_feedback(
logging.info("Tutorial feedback", extra=extras_logging)


@router.post("/identification-dummy")
async def log_identification_dummy(
request: Request, user_id: Union[str, None] = Cookie(None)
):
res = await request.json()

user_agent = parse(request.headers.get("user-agent"))
extras_logging = get_base_logs(user_agent, user_id)

# to know if the firearm is dummy or real
extras_logging["bg_dummy_bool"] = res["is_dummy"]
for key in [
"image_url",
"label",
"confidence",
"confidence_level",
"selected_options",
]:
extras_logging["bg_" + key] = res[key]

logging.info("Identification dummy", extra=extras_logging)


@router.post("/expert-contact")
async def expert_contact(
firstname: Annotated[str, Form()],
Expand Down
5 changes: 1 addition & 4 deletions frontend/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { defineConfig } from "cypress";
import codeCoverageTask from "@cypress/code-coverage/task.js";

const frontendHost = "localhost";
const frontendPort = "5173";

export default defineConfig({
e2e: {
specPattern: "cypress/e2e/**/*.{cy,spec}.{js,ts}",
baseUrl: `http://${frontendHost}:${frontendPort}`,
baseUrl: `http://localhost:5173`,
viewportWidth: 414,
viewportHeight: 896,
video: false,
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/e2e/home.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("HomePage", () => {
cy.visit("/");
cy.getByDataTestid("header-logo").contains("Ministère");
cy.get("#button-menu").should("exist").click();
cy.getByRole("navigation").contains("a", "A propos").click();
cy.getByRole("navigation").contains("a", "À propos").click();
cy.url().should("contain", "/a-propos");
cy.contains("p", "Basegun est un projet");

Expand Down
8 changes: 1 addition & 7 deletions frontend/src/api/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import axios from "axios";
import {
ASK_FOR_OPINION_ROUTE,
IDENTIFICATION_DUMMY_ROUTE,
IDENTIFICATION_FEEDBACK_ROUTE,
TUTORIAL_FEEDBACK_ROUTE,
UPLOAD_PHOTO_FOR_DETECTION_ROUTE,
Expand All @@ -19,7 +18,7 @@ export const uploadPhotoForDetection = async (file: File) => {
return data;
};

export const sendTutorialFeedback = async (feedback: any) => {
export const sendTutorialFeedbackIssue = async (feedback: any) => {
const { data } = await axios.post(TUTORIAL_FEEDBACK_ROUTE, feedback);
return data;
};
Expand All @@ -32,11 +31,6 @@ export const sendIdentificationFeedback = async (feedbackData: any) => {
return data;
};

export const sendIdentificationDummyFeedback = async (feedbackDummy: any) => {
const { data } = await axios.post(IDENTIFICATION_DUMMY_ROUTE, feedbackDummy);
return data;
};

export const sendExpertiseForm = async (data: any, accessToken: string) => {
return axios.post(ASK_FOR_OPINION_ROUTE, data, {
headers: {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/api/api-routes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export const UPLOAD_PHOTO_FOR_DETECTION_ROUTE = "/upload";
export const TUTORIAL_FEEDBACK_ROUTE = "/tutorial-feedback";
export const IDENTIFICATION_FEEDBACK_ROUTE = "/identification-feedback";
export const IDENTIFICATION_DUMMY_ROUTE = "/identification-dummy";
export const ASK_FOR_OPINION_ROUTE = "/expert-contact";
export const GET_IRCGN_NUMBERS_ROUTE = "/contact-details";
export const UPLOAD_PHOTO_FOR_ALARM_GUN_DETECTION = "/identification-alarm-gun";
2 changes: 2 additions & 0 deletions frontend/src/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
// biome-ignore lint: disable
export {}
declare global {
const EffectScope: (typeof import("vue"))["EffectScope"];
Expand Down Expand Up @@ -316,6 +317,7 @@ declare global {
} from "vue";
import("vue");
}

// for vue template auto import
import { UnwrapRef } from "vue";
declare module "vue" {
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ export {};
declare module 'vue' {
export interface GlobalComponents {
AskingExpert: typeof import('./components/AskingExpert.vue')['default']
AuthCallback: (typeof import("./components/authentication/AuthCallback.vue"))["default"]
AuthRedirect: (typeof import("./components/authentication/AuthRedirect.vue"))["default"]
ContactExpert: typeof import('./components/ContactExpert.vue')['default']
copy: (typeof import("./components/authentification/AuthRedirect copy.vue"))["default"]
DsfrAlert: typeof import('@gouvminint/vue-dsfr')['DsfrAlert']
DsfrButton: typeof import('@gouvminint/vue-dsfr')['DsfrButton']
DsfrCheckbox: typeof import('@gouvminint/vue-dsfr')['DsfrCheckbox']
Expand All @@ -21,20 +18,19 @@ declare module 'vue' {
DsfrModal: typeof import('@gouvminint/vue-dsfr')['DsfrModal']
DsfrPicture: typeof import('@gouvminint/vue-dsfr')['DsfrPicture']
DsfrRadioButton: typeof import('@gouvminint/vue-dsfr')['DsfrRadioButton']
DsfrRadioButtonSet: typeof import('@gouvminint/vue-dsfr')['DsfrRadioButtonSet']
DsfrSelect: typeof import('@gouvminint/vue-dsfr')['DsfrSelect']
DsfrStepper: typeof import('@gouvminint/vue-dsfr')['DsfrStepper']
DsfrTable: typeof import('@gouvminint/vue-dsfr')['DsfrTable']
DsfrTag: typeof import('@gouvminint/vue-dsfr')['DsfrTag']
HeaderMain: typeof import('./components/HeaderMain.vue')['default']
MissingCardAlert: typeof import('./components/MissingCardAlert.vue')['default']
OnboardingSwiper: typeof import('./components/OnboardingSwiper.vue')['default']
PopupContact: typeof import('./components/PopupContact.vue')['default']
PopupVideo: typeof import('./components/PopupVideo.vue')['default']
ResultPage: typeof import('./components/ResultPage.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
SnackbarAlert: typeof import('./components/SnackbarAlert.vue')['default']
StepsGuide: typeof import('./components/StepsGuide.vue')['default']
User: (typeof import("./components/authentication/User.vue"))["default"]
VIcon: typeof import('@gouvminint/vue-dsfr')['VIcon']
}
}
10 changes: 5 additions & 5 deletions frontend/src/components/AskingExpert.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<script lang="ts" setup>
import { ref, computed } from "vue";
import axios from "axios";
import { useRoute, useRouter } from "vue-router";
import { useSnackbarStore } from "@/stores/snackbar";
import { useStore } from "@/stores/result";
import SnackbarAlert from "@/components/SnackbarAlert.vue";
import { sendTutorialFeedbackIssue } from "@/api/api-client";
const { setMessage } = useSnackbarStore();
const store = useStore();
const router = useRouter();
Expand Down Expand Up @@ -36,8 +37,7 @@ async function sendTutorialFeedback() {
confidence: confidence.value,
confidence_level: confidenceLevel.value,
};
await axios
.post("/tutorial-feedback", feedback)
await sendTutorialFeedbackIssue(feedback)
.then(() => {
setMessage({
type: "success",
Expand All @@ -48,12 +48,12 @@ async function sendTutorialFeedback() {
console.log(error);
setMessage({
type: "error",
message: "Une erreur a eu lieu en enregistrant de votre message.",
message: "Une erreur a eu lieu en enregistrant votre message.",
});
})
.finally(() =>
setTimeout(() => {
router.push({ name: "ResultPage" });
router.push({ name: "IdentificationTypologyResult" });
}, 3000),
);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/ContactExpert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
icon="ri-alert-line"
label="Contacter un expert"
data-testid="expert-path"
@click="$router.push({ name: 'ExpertSituation' })"
@click="$router.push({ name: 'ExpertContact' })"
/>
</div>
</template>
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/HeaderMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { computed } from "vue";
import { useRoute } from "vue-router";
import type { DsfrHeader } from "@gouvminint/vue-dsfr";
import basegunLogo from "@/assets/basegun.png";
const route = useRoute();
Expand All @@ -21,7 +20,7 @@ const quickLinks: InstanceType<typeof DsfrHeader>["$props"]["quickLinks"] = [
to: "/",
},
{
label: "A propos",
label: "À propos",
to: "/a-propos",
},
{
Expand Down
88 changes: 0 additions & 88 deletions frontend/src/components/PopupContact.vue

This file was deleted.

22 changes: 12 additions & 10 deletions frontend/src/components/ResultPage.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts" setup>
import { ref, computed } from "vue";
import axios from "axios";
import SnackbarAlert from "@/components/SnackbarAlert.vue";
import {
TYPOLOGIES,
Expand All @@ -12,6 +11,8 @@ import { useSnackbarStore } from "@/stores/snackbar";
import { useStore } from "@/stores/result";
import { getMentionsFromCategories } from "@/utils/mentions";
import { sendIdentificationFeedback } from "@/api/api-client";
const { setMessage } = useSnackbarStore();
const store = useStore();
Expand Down Expand Up @@ -45,20 +46,21 @@ const disclaimer = computed(() =>
: null,
);
function sendFeedback(isCorrect: boolean) {
async function sendFeedback(isCorrect: boolean) {
if (isCorrect) {
isUp.value = true;
} else {
isDown.value = true;
}
axios
.post("/identification-feedback", {
image_url: store.imgUrl,
feedback: isCorrect,
confidence: confidence.value,
label: label.value,
confidence_level: confidenceLevel.value,
})
const feedback = {
image_url: store.imgUrl,
feedback: isCorrect,
confidence: confidence.value,
label: label.value,
confidence_level: confidenceLevel.value,
};
await sendIdentificationFeedback(feedback)
.then((data) => {
console.log(data);
setMessage({
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/StepsGuide.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script lang="ts" setup>
import { DsfrStepper } from "@gouvminint/vue-dsfr";
withDefaults(
defineProps<{
currentStep: number;
Expand Down
6 changes: 0 additions & 6 deletions frontend/src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ a {
width: 100%;
}

.footer-text {
padding: 10px;
text-align: center;
box-shadow: none;
}

.footer-actions {
display: flex;
justify-content: space-around;
Expand Down
Loading

0 comments on commit 35a5c84

Please sign in to comment.