Compare commits
1 Commits
42c5a3b2d2
...
feat/admin
| Author | SHA1 | Date | |
|---|---|---|---|
| 311f523647 |
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="PhpCSFixerValidationInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
1
.idea/php.xml
generated
1
.idea/php.xml
generated
@@ -15,7 +15,6 @@
|
|||||||
<component name="PhpCSFixer">
|
<component name="PhpCSFixer">
|
||||||
<phpcsfixer_settings>
|
<phpcsfixer_settings>
|
||||||
<PhpCSFixerConfiguration tool_path="$PROJECT_DIR$/vendor/bin/php-cs-fixer" />
|
<PhpCSFixerConfiguration tool_path="$PROJECT_DIR$/vendor/bin/php-cs-fixer" />
|
||||||
<phpcs_fixer_by_interpreter asDefaultInterpreter="true" interpreter_id="990ff521-e6e9-4080-9cc9-228367d597f9" tool_path="\\wsl.localhost\Ubuntu-24.04\home\matte\Ferme\vendor\bin\php-cs-fixer" timeout="30000" />
|
|
||||||
</phpcsfixer_settings>
|
</phpcsfixer_settings>
|
||||||
</component>
|
</component>
|
||||||
<component name="PhpCodeSniffer">
|
<component name="PhpCodeSniffer">
|
||||||
|
|||||||
87
.idea/workspace.xml
generated
87
.idea/workspace.xml
generated
@@ -4,11 +4,16 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="7c107abe-5995-4428-8429-b146aaca8386" name="Changes" comment="fix : panel scrollable plus interface revue">
|
<list default="true" id="7c107abe-5995-4428-8429-b146aaca8386" name="Changes" comment="feat : test auto-tag-develop.yml (auto incrément version)">
|
||||||
|
<change afterPath="$PROJECT_DIR$/frontend/composables/useAppVersion.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/config/packages/security.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/config/packages/security.yaml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/config/reference.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/reference.php" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/config/reference.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/reference.php" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/frontend/pages/admin/carrier/carrier-list.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/pages/admin/carrier/carrier-list.vue" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/frontend/app.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/app.vue" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/frontend/pages/admin/supplier/supplier-list.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/pages/admin/supplier/supplier-list.vue" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/frontend/layouts/default.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/layouts/default.vue" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/frontend/pages/login.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/pages/login.vue" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Dto/AppVersion.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/ApiResource/AppVersion.php" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/State/AppVersionProvider.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/State/AppVersionProvider.php" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -220,43 +225,43 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"RunOnceActivity.MCP Project settings loaded": "true",
|
"RunOnceActivity.MCP Project settings loaded": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||||
"git-widget-placeholder": "feat/312-creation-d-une-page-d-administration-listing-des-fournisseurs",
|
"git-widget-placeholder": "develop",
|
||||||
"last_opened_file_path": "/home/sroy/Documents/test/Ferme",
|
"last_opened_file_path": "/home/sroy/Documents/test/Ferme",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"settings.editor.selected.configurable": "configurable.tailwindcss",
|
"settings.editor.selected.configurable": "configurable.tailwindcss",
|
||||||
"ts.external.directory.path": "/opt/phpstorm/plugins/javascript-plugin/jsLanguageServicesImpl/external",
|
"ts.external.directory.path": "/opt/phpstorm/plugins/javascript-plugin/jsLanguageServicesImpl/external",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
},
|
},
|
||||||
"keyToStringList": {
|
"keyToStringList": {
|
||||||
"DatabaseDriversLRU": [
|
"DatabaseDriversLRU": [
|
||||||
"postgresql"
|
"postgresql"
|
||||||
],
|
],
|
||||||
"com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [
|
"com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [
|
||||||
"TEXT"
|
"TEXT"
|
||||||
],
|
],
|
||||||
"vue.recent.templates": [
|
"vue.recent.templates": [
|
||||||
"Vue Composition API Component"
|
"Vue Composition API Component"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="MoveFile.RECENT_KEYS">
|
<key name="MoveFile.RECENT_KEYS">
|
||||||
<recent name="\\wsl.localhost\Ubuntu-24.04\home\matte\Ferme\frontend\pages\admin\supplier" />
|
|
||||||
<recent name="\\wsl.localhost\Ubuntu-24.04\home\m-tristan\workspace\Ferme" />
|
<recent name="\\wsl.localhost\Ubuntu-24.04\home\m-tristan\workspace\Ferme" />
|
||||||
<recent name="\\wsl.localhost\Ubuntu-24.04\home\tristan\workspace\ferme\templates" />
|
<recent name="\\wsl.localhost\Ubuntu-24.04\home\tristan\workspace\ferme\templates" />
|
||||||
<recent name="C:\Users\autin\AppData\Roaming\JetBrains\PhpStorm2025.3\scratches" />
|
<recent name="C:\Users\autin\AppData\Roaming\JetBrains\PhpStorm2025.3\scratches" />
|
||||||
<recent name="C:\Users\autin\AppData\Roaming\JetBrains\PhpStorm2025.3\scratches\Ferme_MCD\MCD_DOC" />
|
<recent name="C:\Users\autin\AppData\Roaming\JetBrains\PhpStorm2025.3\scratches\Ferme_MCD\MCD_DOC" />
|
||||||
|
<recent name="\\wsl.localhost\Ubuntu-24.04\home\tristan\workspace\ferme\frontend\pages\reception" />
|
||||||
</key>
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="SharedIndexes">
|
<component name="SharedIndexes">
|
||||||
@@ -297,6 +302,14 @@
|
|||||||
<workItem from="1770195959162" duration="18915000" />
|
<workItem from="1770195959162" duration="18915000" />
|
||||||
<workItem from="1770274844804" duration="3940000" />
|
<workItem from="1770274844804" duration="3940000" />
|
||||||
</task>
|
</task>
|
||||||
|
<task id="LOCAL-00009" summary="feat : ajout d'une gestion d'erreur au global côté front avec la lib toaster et I18n pour centraliser les messages d'erreur">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1768555180530</created>
|
||||||
|
<option name="number" value="00009" />
|
||||||
|
<option name="presentableId" value="LOCAL-00009" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1768555180530</updated>
|
||||||
|
</task>
|
||||||
<task id="LOCAL-00010" summary="feat : ajout de l'authentification avec lexik">
|
<task id="LOCAL-00010" summary="feat : ajout de l'authentification avec lexik">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
<created>1768832208350</created>
|
<created>1768832208350</created>
|
||||||
@@ -681,15 +694,7 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1770371073055</updated>
|
<updated>1770371073055</updated>
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00058" summary="fix : nom page fournisseur">
|
<option name="localTasksCounter" value="58" />
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1770632525875</created>
|
|
||||||
<option name="number" value="00058" />
|
|
||||||
<option name="presentableId" value="LOCAL-00058" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1770632525875</updated>
|
|
||||||
</task>
|
|
||||||
<option name="localTasksCounter" value="59" />
|
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
@@ -739,6 +744,7 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
|
<MESSAGE value="fix : gitea workflow" />
|
||||||
<MESSAGE value="fix : script de déploiement" />
|
<MESSAGE value="fix : script de déploiement" />
|
||||||
<MESSAGE value="feat : ajout plus d'information sur la liste des réceptions côté front sur la page d'accueil" />
|
<MESSAGE value="feat : ajout plus d'information sur la liste des réceptions côté front sur la page d'accueil" />
|
||||||
<MESSAGE value="fix : redirige sur le login sur une 401 et reset du auth state + doc + timeout du toaster" />
|
<MESSAGE value="fix : redirige sur le login sur une 401 et reset du auth state + doc + timeout du toaster" />
|
||||||
@@ -763,8 +769,7 @@
|
|||||||
<MESSAGE value="feat : update numéro de version" />
|
<MESSAGE value="feat : update numéro de version" />
|
||||||
<MESSAGE value="fix : auto-tag-develop.yml" />
|
<MESSAGE value="fix : auto-tag-develop.yml" />
|
||||||
<MESSAGE value="feat : test auto-tag-develop.yml (auto incrément version)" />
|
<MESSAGE value="feat : test auto-tag-develop.yml (auto incrément version)" />
|
||||||
<MESSAGE value="fix : nom page fournisseur" />
|
<option name="LAST_COMMIT_MESSAGE" value="feat : test auto-tag-develop.yml (auto incrément version)" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="fix : nom page fournisseur" />
|
|
||||||
</component>
|
</component>
|
||||||
<component name="XSLT-Support.FileAssociations.UIState">
|
<component name="XSLT-Support.FileAssociations.UIState">
|
||||||
<expand />
|
<expand />
|
||||||
@@ -778,4 +783,4 @@
|
|||||||
<option value=".github/prompts" />
|
<option value=".github/prompts" />
|
||||||
</promptFileLocations>
|
</promptFileLocations>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -29,10 +29,6 @@ Ajouter dans le fichier .env du frontend
|
|||||||
* Finalisation de la partie réception de marchandise
|
* Finalisation de la partie réception de marchandise
|
||||||
* [#267] Lister les réceptions en attente
|
* [#267] Lister les réceptions en attente
|
||||||
* [#268] Lister les réceptions terminées
|
* [#268] Lister les réceptions terminées
|
||||||
* [#316] Admin liste des transporteurs
|
|
||||||
* [#312] Creation administration listing fournisseurs
|
|
||||||
* [#315] Creation page admin utilisateur
|
|
||||||
* [#317] Admin modification creation transporteur
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
parameters:
|
parameters:
|
||||||
app.version: '0.0.36'
|
app.version: '0.0.32'
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
<template>
|
|
||||||
<form @submit.prevent="validate">
|
|
||||||
<div
|
|
||||||
class="flex items-center justify-between gap-10">
|
|
||||||
<h1 class="text-3xl font-bold uppercase">
|
|
||||||
{{ userId ? "Modifications de l'utilisateur" : "Ajout d'un utilisateur" }}
|
|
||||||
</h1>
|
|
||||||
<button
|
|
||||||
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
|
||||||
type="submit"
|
|
||||||
>
|
|
||||||
{{ userId ? 'Sauvegarder' : 'Ajouter' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid gap-y-16 gap-x-40 mb-16">
|
|
||||||
<UiTextInput
|
|
||||||
id="user-name"
|
|
||||||
v-model="form.username"
|
|
||||||
label="Nom de l'utilisateur"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<UiSelect
|
|
||||||
id="user-role"
|
|
||||||
v-model="form.role"
|
|
||||||
label="Rôle de l'utilisateur"
|
|
||||||
:options="ROLE"
|
|
||||||
/>
|
|
||||||
<UiTextInput
|
|
||||||
id="user-password"
|
|
||||||
v-model="form.password"
|
|
||||||
label="Mot de passe"
|
|
||||||
type="password"
|
|
||||||
|
|
||||||
/>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
|
|
||||||
import {computed, reactive, ref, watch} from 'vue'
|
|
||||||
import {ROLE} from '~/utils/constants'
|
|
||||||
import {createUser, updateUser, getUser} from '~/services/auth'
|
|
||||||
import type {UserData, UserFormData} from '~/services/dto/user-data'
|
|
||||||
|
|
||||||
const route = useRoute()
|
|
||||||
const router = useRouter()
|
|
||||||
const userId = computed(() => resolveUserId(route.params.id))
|
|
||||||
const isLoading = ref(false)
|
|
||||||
const isHydrating = ref(false)
|
|
||||||
|
|
||||||
const resolveUserId = (param: unknown) => {
|
|
||||||
const idStr = Array.isArray(param) ? param[0] : param
|
|
||||||
if (!idStr) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
const id = Number(idStr)
|
|
||||||
return Number.isFinite(id) ? id : null
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const form = reactive<UserFormData>({
|
|
||||||
username: '',
|
|
||||||
password: '',
|
|
||||||
role: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
const hydrateFromUser = (user: UserData | null) => {
|
|
||||||
if (!user) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
isHydrating.value = true
|
|
||||||
form.username = user.username ?? ''
|
|
||||||
const roles = user.roles ?? []
|
|
||||||
const hasAdmin = roles.includes("ROLE_ADMIN")
|
|
||||||
form.role = hasAdmin ? "ROLE_ADMIN" : "ROLE_USER"
|
|
||||||
form.password = ''
|
|
||||||
isHydrating.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => userId.value,
|
|
||||||
async (id) => {
|
|
||||||
if (id === null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
isLoading.value = true
|
|
||||||
try {
|
|
||||||
const user = await getUser(id)
|
|
||||||
hydrateFromUser(user)
|
|
||||||
} finally {
|
|
||||||
isLoading.value = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{immediate: true}
|
|
||||||
)
|
|
||||||
|
|
||||||
async function validate() {
|
|
||||||
|
|
||||||
const normalizedUsername = form.username.trim()
|
|
||||||
const normalizedRole = form.role.trim()
|
|
||||||
const normalizedPassword = form.password.trim()
|
|
||||||
|
|
||||||
const basePayload = {
|
|
||||||
username: normalizedUsername,
|
|
||||||
roles: normalizedRole ? [normalizedRole] : undefined,
|
|
||||||
password: normalizedPassword || undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userId.value) {
|
|
||||||
await updateUser(userId.value, basePayload)
|
|
||||||
await router.push(`/admin/user/list/`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const created = await createUser(basePayload)
|
|
||||||
if (created) {
|
|
||||||
await router.push(`/admin/user/list/`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -46,11 +46,7 @@
|
|||||||
"list": "Impossible de récupérer la liste des races de bovins."
|
"list": "Impossible de récupérer la liste des races de bovins."
|
||||||
},
|
},
|
||||||
"carrier": {
|
"carrier": {
|
||||||
"list": "Impossible de récupérer la liste des transporteurs.",
|
"list": "Impossible de récupérer la liste des transporteurs."
|
||||||
"fetch": "Impossible de récupérer les données du transporteur",
|
|
||||||
"update": "Impossible de mettre à jour le transporteur",
|
|
||||||
"create": "Impossible de créer le transporteur"
|
|
||||||
|
|
||||||
},
|
},
|
||||||
"driver": {
|
"driver": {
|
||||||
"list": "Impossible de récupérer la liste des chauffeurs."
|
"list": "Impossible de récupérer la liste des chauffeurs."
|
||||||
@@ -61,9 +57,7 @@
|
|||||||
"auth": {
|
"auth": {
|
||||||
"login": "Identifiants invalides.",
|
"login": "Identifiants invalides.",
|
||||||
"users": "Impossible de récupérer les utilisateurs.",
|
"users": "Impossible de récupérer les utilisateurs.",
|
||||||
"logout": "Impossible de se déconnecter.",
|
"logout": "Impossible de se déconnecter."
|
||||||
"update": "Impossible de mettre à jour l'utilisateur.",
|
|
||||||
"create": "Impossible de créer l'utilisateur."
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"success": {
|
"success": {
|
||||||
@@ -71,14 +65,8 @@
|
|||||||
"update": "Réception mise à jour avec succès."
|
"update": "Réception mise à jour avec succès."
|
||||||
},
|
},
|
||||||
"auth": {
|
"auth": {
|
||||||
"update": "Utilisateur mis à jour avec succès.",
|
|
||||||
"create": "Utilisateur créé avec succès.",
|
|
||||||
"login": "Connexion réussie.",
|
"login": "Connexion réussie.",
|
||||||
"logout": "Déconnexion réussie."
|
"logout": "Déconnexion réussie."
|
||||||
},
|
|
||||||
"carrier": {
|
|
||||||
"update": "Transporteur mis à jour",
|
|
||||||
"create": "Transporteur créé"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,19 +21,16 @@
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="grid grid-cols-[16rem,1fr] h-[calc(100vh-85px)] min-h-0">
|
<div class="grid grid-cols-[16rem,1fr] h-[calc(100vh-85px)] min-h-0">
|
||||||
<aside class="bg-primary-500 text-white min-h-0 flex flex-col justify-between">
|
<aside class="bg-primary-500 text-white min-h-0 grid grid-rows-[auto,1fr,auto]">
|
||||||
<div class="flex flex-col gap-4 p-4 font-bold text-xl">
|
<div class="p-4 font-semibold">Tableau de bord</div>
|
||||||
|
|
||||||
|
<div class="overflow-y-auto min-h-0 p-4 space-y-3">
|
||||||
<!-- Liste des liens à ajouter ci-dessous -->
|
<!-- Liste des liens à ajouter ci-dessous -->
|
||||||
<NuxtLink to="/admin/dashboard">
|
<!--Button pour afficher le component admin-users -->
|
||||||
Tableau de bord
|
<NuxtLink
|
||||||
</NuxtLink>
|
to="/admin/user-list"
|
||||||
<NuxtLink to="/admin/supplier/supplier-list">
|
class="block px-4 py-2 rounded hover:bg-primary-600 transition"
|
||||||
Fournisseur
|
>
|
||||||
</NuxtLink>
|
|
||||||
<NuxtLink to="/admin/carrier/carrier-list">
|
|
||||||
Transporteur
|
|
||||||
</NuxtLink>
|
|
||||||
<NuxtLink to="/admin/user/list">
|
|
||||||
Utilisateurs
|
Utilisateurs
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</div>
|
</div>
|
||||||
@@ -47,6 +44,7 @@
|
|||||||
Déconnexion
|
Déconnexion
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<main class="min-h-0 overflow-auto px-12 py-12 ">
|
<main class="min-h-0 overflow-auto px-12 py-12 ">
|
||||||
@@ -60,9 +58,8 @@
|
|||||||
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {useAuthStore} from '~/stores/auth'
|
import auth from "~/layouts/auth.vue";
|
||||||
|
|
||||||
const auth = useAuthStore()
|
|
||||||
const { version } = useAppVersion()
|
const { version } = useAppVersion()
|
||||||
const handleLogout = async () => {
|
const handleLogout = async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -20,10 +20,7 @@
|
|||||||
Accueil
|
Accueil
|
||||||
</a>
|
</a>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink
|
<NuxtLink to="/admin/dashboard" custom v-slot="{ href, navigate, isActive }">
|
||||||
to="/admin/dashboard" custom v-slot="{ href, navigate, isActive }"
|
|
||||||
v-if="auth.isAdmin"
|
|
||||||
>
|
|
||||||
<a
|
<a
|
||||||
:href="href"
|
:href="href"
|
||||||
@click="navigate"
|
@click="navigate"
|
||||||
@@ -110,27 +107,27 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {useAuthStore} from '~/stores/auth'
|
import { useAuthStore } from '~/stores/auth'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
const isMenuOpen = ref(false)
|
const isMenuOpen = ref(false)
|
||||||
const {version} = useAppVersion()
|
const { version } = useAppVersion()
|
||||||
|
|
||||||
const closeMenu = () => {
|
const closeMenu = () => {
|
||||||
isMenuOpen.value = false
|
isMenuOpen.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleMenu = () => {
|
const toggleMenu = () => {
|
||||||
isMenuOpen.value = !isMenuOpen.value
|
isMenuOpen.value = !isMenuOpen.value
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleLogout = async () => {
|
const handleLogout = async () => {
|
||||||
try {
|
try {
|
||||||
await auth.logout()
|
await auth.logout()
|
||||||
} finally {
|
} finally {
|
||||||
closeMenu()
|
closeMenu()
|
||||||
await navigateTo('/login')
|
await navigateTo('/login')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
|
|
||||||
<template>
|
|
||||||
<form @submit.prevent="validate">
|
|
||||||
<div class="flex items-center justify-between ">
|
|
||||||
<h1 class="text-3xl font-bold uppercase">
|
|
||||||
{{ route.params.id ? 'Modifier transporteur' : 'Ajout transporteur' }}
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px] justify-self-end"
|
|
||||||
>Enregistrer
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-2 items-start gap-y-8 gap-x-40 mb-16">
|
|
||||||
|
|
||||||
<UiTextInput
|
|
||||||
label = "nom du fournisseur"
|
|
||||||
id="carrier-name"
|
|
||||||
v-model="form.name"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<UiTextInput
|
|
||||||
label = "code fournisseur"
|
|
||||||
id="code-id"
|
|
||||||
v-model="form.code"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import {createCarrier, getCarrier, updateCarrier} from "~/services/carrier";
|
|
||||||
import type {CarrierData, CarrierFormData} from "~/services/dto/carrier-data";
|
|
||||||
const router = useRouter()
|
|
||||||
const route = useRoute()
|
|
||||||
const idCarrier = Number(route.params.id)
|
|
||||||
const isLoading = ref(false)
|
|
||||||
const isHydrating = ref(false)
|
|
||||||
|
|
||||||
const form = reactive<CarrierFormData>({
|
|
||||||
code:'',
|
|
||||||
name:''
|
|
||||||
})
|
|
||||||
|
|
||||||
definePageMeta({
|
|
||||||
layout: 'admin'
|
|
||||||
})
|
|
||||||
|
|
||||||
const hydrateFromUser = (carrier: CarrierData | null) => {
|
|
||||||
if (!carrier) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
isHydrating.value = true
|
|
||||||
form.name = carrier.name ?? ''
|
|
||||||
form.code = carrier.code ?? ''
|
|
||||||
isHydrating.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => idCarrier,
|
|
||||||
async (id) => {
|
|
||||||
if (id === null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
isLoading.value = true
|
|
||||||
try {
|
|
||||||
const user = await getCarrier(id)
|
|
||||||
hydrateFromUser(user)
|
|
||||||
} finally {
|
|
||||||
isLoading.value = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{immediate: true}
|
|
||||||
)
|
|
||||||
async function validate() {
|
|
||||||
|
|
||||||
const normalizedCarrierCode = form.code.trim()
|
|
||||||
const normalizedCarrierName = form.name.trim()
|
|
||||||
|
|
||||||
const basePayload = {
|
|
||||||
name: normalizedCarrierName,
|
|
||||||
code: normalizedCarrierCode
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(idCarrier){
|
|
||||||
await updateCarrier(idCarrier, basePayload)
|
|
||||||
navigate()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
await createCarrier(basePayload)
|
|
||||||
navigate()
|
|
||||||
}
|
|
||||||
|
|
||||||
function navigate(){
|
|
||||||
router.push("/admin/carrier/carrier-list")
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
<template>
|
|
||||||
|
|
||||||
<div class="flex items-center justify-between ">
|
|
||||||
<h1 class="text-3xl font-bold uppercase">listes des transporteurs</h1>
|
|
||||||
<NuxtLink
|
|
||||||
to="/admin/carrier"
|
|
||||||
class="flex items-center justify-center text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
|
||||||
>Ajouter
|
|
||||||
</NuxtLink>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-6 border border-slate-200 mb-16 ">
|
|
||||||
<div class="grid grid-cols-2 gap-4 bg-slate-100 px-4 py-3 text-sm font-semibold uppercase tracking-wide">
|
|
||||||
<div>Label</div>
|
|
||||||
<div>Code</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-for="carrier in carrierList"
|
|
||||||
:key="carrier.id"
|
|
||||||
class="grid grid-cols-2 gap-4 px-4 py-3 text-sm hover:bg-slate-50 cursor-pointer border-t border-slate-200"
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
@click="goToCarrier(carrier.id)"
|
|
||||||
@keydown.enter="goToCarrier(carrier.id)"
|
|
||||||
>
|
|
||||||
<div>{{ carrier.name}}</div>
|
|
||||||
<div>{{ carrier.code }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import type {CarrierData} from "~/services/dto/carrier-data";
|
|
||||||
import {getCarrierList} from "~/services/carrier";
|
|
||||||
|
|
||||||
const carrierList = ref<CarrierData[]>()
|
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
const goToCarrier = (id: number) => {
|
|
||||||
router.push(`/admin/carrier/${id}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
definePageMeta({
|
|
||||||
layout: 'admin'
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
carrierList.value = await getCarrierList(false)
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<AdminUserForm/>
|
<admin-users v-if="activeCode === 'users'" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: 'admin'
|
layout: 'admin'
|
||||||
})
|
})
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const activeCode = computed(() => (route.query.code as string))
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<h1 class="text-3xl font-bold uppercase"> Fournisseurs </h1>
|
|
||||||
<NuxtLink to="/admin/supplier"
|
|
||||||
class="flex items-center justify-center text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
|
||||||
>
|
|
||||||
Ajouter
|
|
||||||
</NuxtLink>
|
|
||||||
</div>
|
|
||||||
<div class="mt-6 border border-slate-200 mb-16">
|
|
||||||
<div class="max-h-96 overflow-y-auto">
|
|
||||||
<div
|
|
||||||
class="sticky top-0 z-10 grid grid-cols-6 gap-4 bg-slate-100 px-4 py-3 text-sm font-semibold uppercase tracking-wide"
|
|
||||||
>
|
|
||||||
<div>Nom</div>
|
|
||||||
<div>Mail</div>
|
|
||||||
<div>Rue</div>
|
|
||||||
<div>Complément</div>
|
|
||||||
<div>Code Postal</div>
|
|
||||||
<div>Ville</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-for="supplier in supplierList" :key="supplier.id">
|
|
||||||
<template v-if="supplier.addresses?.length">
|
|
||||||
<div
|
|
||||||
v-for="addr in supplier.addresses"
|
|
||||||
:key="addr.id"
|
|
||||||
class="grid grid-cols-6 hover:bg-slate-50 border-t gap-4 px-4 py-2"
|
|
||||||
@click="goToSupplier(supplier.id)"
|
|
||||||
>
|
|
||||||
<div class="truncate">
|
|
||||||
{{ supplier.name }}
|
|
||||||
</div>
|
|
||||||
<div class="truncate">
|
|
||||||
{{ supplier.email }}
|
|
||||||
</div>
|
|
||||||
<div class="truncate">
|
|
||||||
{{ addr.street }}
|
|
||||||
</div>
|
|
||||||
<div class="truncate">
|
|
||||||
{{ addr.street2 }}
|
|
||||||
</div>
|
|
||||||
<div>{{ addr.postalCode }}</div>
|
|
||||||
<div class="uppercase truncate">
|
|
||||||
{{ addr.city }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import type {SupplierData} from "~/services/dto/supplier-data"
|
|
||||||
import {getSupplierList} from "~/services/supplier"
|
|
||||||
|
|
||||||
definePageMeta({layout: "admin"})
|
|
||||||
|
|
||||||
const supplierList = ref<SupplierData[]>([])
|
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
|
|
||||||
const goToSupplier = (id: number) => {
|
|
||||||
router.push(`/admin/supplier/${id}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
supplierList.value = (await getSupplierList(false)) ?? []
|
|
||||||
})
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between gap-10">
|
||||||
<h1 class="text-3xl font-bold uppercase">Liste des utilisateurs</h1>
|
<h1 class="text-3xl font-bold uppercase">Utilisateurs</h1>
|
||||||
<NuxtLink
|
<button
|
||||||
class="flex items-center justify-center text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
||||||
@click="router.push('/admin/user/')"
|
@click="null"
|
||||||
>
|
>
|
||||||
Ajouter
|
Ajouter
|
||||||
</NuxtLink>
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@@ -15,43 +14,51 @@
|
|||||||
<div class="grid grid-cols-3 gap-4 bg-slate-100 px-4 py-3 text-sm font-semibold uppercase tracking-wide">
|
<div class="grid grid-cols-3 gap-4 bg-slate-100 px-4 py-3 text-sm font-semibold uppercase tracking-wide">
|
||||||
<div>Username</div>
|
<div>Username</div>
|
||||||
<div>Role</div>
|
<div>Role</div>
|
||||||
|
<div>Action</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-for="user in userList"
|
v-for="user in userList"
|
||||||
:key="user.id"
|
:key="user.id"
|
||||||
class="grid grid-cols-3 gap-4 px-4 py-3 text-sm hover:bg-slate-50 cursor-pointer border-t items-center"
|
class="grid grid-cols-3 gap-4 px-4 py-3 text-sm hover:bg-slate-50 cursor-pointer border-t border-slate-200 items-center"
|
||||||
role="button"
|
role="button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
@click="goToUser(user.id)"
|
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
{{ user.username }}
|
{{ user.username}}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{{ user.roles?.join(', ') || ' ---' }}
|
{{ user.roles?.join(', ') || ' ---' }}
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="p-4">
|
||||||
|
<button
|
||||||
|
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
||||||
|
@click="null"
|
||||||
|
>
|
||||||
|
Modifier
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: 'admin'
|
layout: 'admin'
|
||||||
})
|
})
|
||||||
|
|
||||||
import type {UserData} from "~/services/dto/user-data";
|
import type {UserData} from "~/services/dto/user-data";
|
||||||
import {getAdminUsers, getUsers} from "~/services/auth";
|
import {getUsers} from "~/services/auth";
|
||||||
|
|
||||||
const userList = ref<UserData[]>([])
|
const userList = ref<UserData[]>([])
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
const goToUser = (id: number) => {
|
|
||||||
router.push(`/admin/user/${id}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
userList.value = await getAdminUsers()
|
userList.value = await getUsers()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<template>
|
|
||||||
<UserForm/>
|
|
||||||
</template>
|
|
||||||
<script setup lang="ts">
|
|
||||||
definePageMeta({
|
|
||||||
layout: 'admin'
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { useApi } from '~/composables/useApi'
|
import { useApi } from '~/composables/useApi'
|
||||||
import type { UserData } from '~/services/dto/user-data'
|
import type { UserData } from '~/services/dto/user-data'
|
||||||
import type {UserPayload} from "~/services/dto/user-data";
|
|
||||||
|
|
||||||
export async function getUsers() {
|
export async function getUsers() {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
@@ -13,40 +12,7 @@ export async function getUsers() {
|
|||||||
|
|
||||||
return data['hydra:member'] ?? []
|
return data['hydra:member'] ?? []
|
||||||
}
|
}
|
||||||
export async function getAdminUsers() {
|
|
||||||
const api = useApi()
|
|
||||||
const data = await api.get<UserData[] | { 'hydra:member': UserData[] }>('admin/users', {}, {
|
|
||||||
toastErrorKey: 'errors.auth.users'
|
|
||||||
})
|
|
||||||
if (Array.isArray(data)) {
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
return data['hydra:member'] ?? []
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getUser(id: number) {
|
|
||||||
const api = useApi()
|
|
||||||
return api.get<UserData>(`users/${id}`, {}, {
|
|
||||||
toastErrorKey: 'errors.auth.user'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function createUser(payload: UserPayload = {}) {
|
|
||||||
const api = useApi()
|
|
||||||
return api.post<UserData>('users', payload, {
|
|
||||||
toastErrorKey: 'errors.auth.create',
|
|
||||||
toastSuccessKey : 'success.auth.create'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function updateUser(id : number, playload: UserPayload = {}){
|
|
||||||
const api = useApi()
|
|
||||||
return api.patch<UserData>(`users/${id}`, playload, {
|
|
||||||
toastErrorKey: 'errors.auth.update',
|
|
||||||
toastSuccessKey: 'success.auth.update'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export async function getCurrentUser() {
|
export async function getCurrentUser() {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
return api.get<UserData>('me', {}, {
|
return api.get<UserData>('me', {}, {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useApi } from '~/composables/useApi'
|
import { useApi } from '~/composables/useApi'
|
||||||
import type {CarrierData, CarrierPayload} from "~/services/dto/carrier-data";
|
import type { CarrierData } from '~/services/dto/carrier-data'
|
||||||
|
|
||||||
export type CarrierListResponse =
|
export type CarrierListResponse =
|
||||||
| CarrierData[]
|
| CarrierData[]
|
||||||
@@ -21,26 +21,3 @@ export async function getCarrierList(): Promise<CarrierData[]> {
|
|||||||
|
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCarrier(id: number) {
|
|
||||||
const api = useApi()
|
|
||||||
return api.get<CarrierData>(`carriers/${id}`, {}, {
|
|
||||||
toastErrorKey: 'errors.carrier.fetch'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function updateCarrier(id: number, payload: CarrierPayload) {
|
|
||||||
const api = useApi()
|
|
||||||
return api.patch<CarrierData>(`carriers/${id}`, payload, {
|
|
||||||
toastErrorKey: 'errors.carrier.update',
|
|
||||||
toastSuccessKey: 'success.carrier.update'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function createCarrier(payload: CarrierPayload = {}) {
|
|
||||||
const api = useApi()
|
|
||||||
return api.post<CarrierData>('carriers', payload, {
|
|
||||||
toastErrorKey: 'errors.carrier.create',
|
|
||||||
toastSuccessKey: 'success.carrier.update'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,13 +3,3 @@ export interface CarrierData {
|
|||||||
name: string
|
name: string
|
||||||
code: string
|
code: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CarrierFormData {
|
|
||||||
name: string
|
|
||||||
code: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type CarrierPayload = {
|
|
||||||
name?: string | null
|
|
||||||
code?: string
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,17 +1,5 @@
|
|||||||
export interface UserData {
|
export interface UserData {
|
||||||
id: number
|
id: number
|
||||||
username: string
|
username: string
|
||||||
roles: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export type UserPayload = {
|
|
||||||
username?: string
|
|
||||||
password?: string
|
|
||||||
roles?: string[]
|
roles?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UserFormData = {
|
|
||||||
username: string
|
|
||||||
password: string
|
|
||||||
role: string
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,80 +1,63 @@
|
|||||||
import {defineStore} from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import type {UserData} from '~/services/dto/user-data'
|
import type { UserData } from '~/services/dto/user-data'
|
||||||
import {getCurrentUser, createUser, login, logout} from '~/services/auth'
|
import { getCurrentUser, login, logout } from '~/services/auth'
|
||||||
import type {UserPayload} from "~/services/dto/user-data";
|
|
||||||
import {ROLE} from '~/utils/constants'
|
|
||||||
|
|
||||||
export const useAuthStore = defineStore('auth', {
|
export const useAuthStore = defineStore('auth', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
user: null as UserData | null,
|
user: null as UserData | null,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
checked: false
|
checked: false
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
isAuthenticated: (state) => Boolean(state.user),
|
isAuthenticated: (state) => Boolean(state.user)
|
||||||
isAdmin: (state) => Boolean(state.user?.roles?.includes(ROLE[0].value))
|
},
|
||||||
|
actions: {
|
||||||
|
clearSession() {
|
||||||
|
this.user = null
|
||||||
|
this.checked = true
|
||||||
|
this.isLoading = false
|
||||||
},
|
},
|
||||||
actions: {
|
async ensureSession() {
|
||||||
clearSession() {
|
if (this.checked) {
|
||||||
this.user = null
|
return this.user
|
||||||
this.checked = true
|
}
|
||||||
this.isLoading = false
|
|
||||||
},
|
|
||||||
async ensureSession() {
|
|
||||||
if (this.checked) {
|
|
||||||
return this.user
|
|
||||||
}
|
|
||||||
|
|
||||||
this.checked = true
|
this.checked = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const me = await getCurrentUser()
|
const me = await getCurrentUser()
|
||||||
this.user = me
|
this.user = me
|
||||||
return me
|
return me
|
||||||
} catch {
|
} catch {
|
||||||
this.user = null
|
this.user = null
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async login(username: string, password: string) {
|
async login(username: string, password: string) {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await login(username, password)
|
await login(username, password)
|
||||||
const me = await getCurrentUser()
|
const me = await getCurrentUser()
|
||||||
this.user = me
|
this.user = me
|
||||||
this.checked = true
|
this.checked = true
|
||||||
return me
|
return me
|
||||||
} finally {
|
} finally {
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async createUser(payload: UserPayload = {}) {
|
async logout() {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
const result = await createUser(payload).finally(() => {
|
|
||||||
this.isLoading = false
|
|
||||||
})
|
|
||||||
return result
|
|
||||||
},
|
|
||||||
async updateUser(id: number, payload: UserPayload) {
|
|
||||||
this.isLoading = true
|
|
||||||
const result = await createUser(payload).finally(() => {
|
|
||||||
this.isLoading = false
|
|
||||||
})
|
|
||||||
return result
|
|
||||||
},
|
|
||||||
async logout() {
|
|
||||||
this.isLoading = true
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await logout()
|
await logout()
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore logout errors so we can still clear local auth state.
|
// Ignore logout errors so we can still clear local auth state.
|
||||||
} finally {
|
} finally {
|
||||||
this.user = null
|
this.user = null
|
||||||
this.checked = true
|
this.checked = true
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,10 +8,6 @@ export const MERCHANDISE_TYPE_CODES = {
|
|||||||
AUTRES: 'AUTRES'
|
AUTRES: 'AUTRES'
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export const ROLE = [
|
|
||||||
{ label: 'Administrateur', value: 'ROLE_ADMIN' },
|
|
||||||
{ label: 'Utilisateur', value: 'ROLE_USER' }
|
|
||||||
]
|
|
||||||
export const SUPLLIER_CODE = {
|
export const SUPLLIER_CODE = {
|
||||||
LIOT: 'LIOT'
|
LIOT: 'LIOT'
|
||||||
}
|
}
|
||||||
|
|||||||
2
makefile
2
makefile
@@ -79,7 +79,7 @@ migration-migrate:
|
|||||||
$(SYMFONY_CONSOLE) --no-interaction doctrine:migrations:migrate --allow-no-migration
|
$(SYMFONY_CONSOLE) --no-interaction doctrine:migrations:migrate --allow-no-migration
|
||||||
|
|
||||||
fixtures:
|
fixtures:
|
||||||
$(SYMFONY_CONSOLE) --no-interaction doctrine:fixtures:load
|
$(SYMFONY_CONSOLE) doctrine:fixtures:load
|
||||||
|
|
||||||
# Attention, supprime votre bdd local
|
# Attention, supprime votre bdd local
|
||||||
db-reset:
|
db-reset:
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace DoctrineMigrations;
|
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
|
||||||
use Doctrine\Migrations\AbstractMigration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Auto-generated Migration: Please modify to your needs!
|
|
||||||
*/
|
|
||||||
final class Version20260204101625 extends AbstractMigration
|
|
||||||
{
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this up() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('CREATE TABLE bovin_shipment (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, nb_bovin_send INT NOT NULL, shipment_id INT DEFAULT NULL, shipment_type_id INT DEFAULT NULL, PRIMARY KEY (id))');
|
|
||||||
$this->addSql('CREATE INDEX IDX_7049F4507BE036FC ON bovin_shipment (shipment_id)');
|
|
||||||
$this->addSql('CREATE INDEX IDX_7049F4502EE48A36 ON bovin_shipment (shipment_type_id)');
|
|
||||||
$this->addSql('CREATE TABLE customer (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, label VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY (id))');
|
|
||||||
$this->addSql('CREATE TABLE customer_address (customer_id INT NOT NULL, address_id INT NOT NULL, PRIMARY KEY (customer_id, address_id))');
|
|
||||||
$this->addSql('CREATE INDEX IDX_1193CB3F9395C3F3 ON customer_address (customer_id)');
|
|
||||||
$this->addSql('CREATE INDEX IDX_1193CB3FF5B7AF75 ON customer_address (address_id)');
|
|
||||||
$this->addSql('CREATE TABLE shipment (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, licence_plate VARCHAR(255) NOT NULL, identification_number VARCHAR(20) DEFAULT NULL, current_step INT DEFAULT 0 NOT NULL, is_valid BOOLEAN NOT NULL, shipment_date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, carrier_id INT DEFAULT NULL, vehicle_id INT DEFAULT NULL, truck_id INT DEFAULT NULL, customer_id INT DEFAULT NULL, PRIMARY KEY (id))');
|
|
||||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_2CB20DC347639A5 ON shipment (identification_number)');
|
|
||||||
$this->addSql('CREATE INDEX IDX_2CB20DC21DFC797 ON shipment (carrier_id)');
|
|
||||||
$this->addSql('CREATE INDEX IDX_2CB20DC545317D1 ON shipment (vehicle_id)');
|
|
||||||
$this->addSql('CREATE INDEX IDX_2CB20DCC6957CCE ON shipment (truck_id)');
|
|
||||||
$this->addSql('CREATE INDEX IDX_2CB20DC9395C3F3 ON shipment (customer_id)');
|
|
||||||
$this->addSql('CREATE TABLE shipment_type (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, label VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY (id))');
|
|
||||||
$this->addSql('ALTER TABLE bovin_shipment ADD CONSTRAINT FK_7049F4507BE036FC FOREIGN KEY (shipment_id) REFERENCES shipment (id)');
|
|
||||||
$this->addSql('ALTER TABLE bovin_shipment ADD CONSTRAINT FK_7049F4502EE48A36 FOREIGN KEY (shipment_type_id) REFERENCES shipment_type (id)');
|
|
||||||
$this->addSql('ALTER TABLE customer_address ADD CONSTRAINT FK_1193CB3F9395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id) ON DELETE CASCADE');
|
|
||||||
$this->addSql('ALTER TABLE customer_address ADD CONSTRAINT FK_1193CB3FF5B7AF75 FOREIGN KEY (address_id) REFERENCES address (id) ON DELETE CASCADE');
|
|
||||||
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC21DFC797 FOREIGN KEY (carrier_id) REFERENCES carrier (id) NOT DEFERRABLE');
|
|
||||||
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC545317D1 FOREIGN KEY (vehicle_id) REFERENCES vehicle (id)');
|
|
||||||
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DCC6957CCE FOREIGN KEY (truck_id) REFERENCES truck (id) NOT DEFERRABLE');
|
|
||||||
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC9395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id)');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('ALTER TABLE bovin_shipment DROP CONSTRAINT FK_7049F4507BE036FC');
|
|
||||||
$this->addSql('ALTER TABLE bovin_shipment DROP CONSTRAINT FK_7049F4502EE48A36');
|
|
||||||
$this->addSql('ALTER TABLE customer_address DROP CONSTRAINT FK_1193CB3F9395C3F3');
|
|
||||||
$this->addSql('ALTER TABLE customer_address DROP CONSTRAINT FK_1193CB3FF5B7AF75');
|
|
||||||
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC21DFC797');
|
|
||||||
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC545317D1');
|
|
||||||
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DCC6957CCE');
|
|
||||||
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC9395C3F3');
|
|
||||||
$this->addSql('DROP TABLE bovin_shipment');
|
|
||||||
$this->addSql('DROP TABLE customer');
|
|
||||||
$this->addSql('DROP TABLE customer_address');
|
|
||||||
$this->addSql('DROP TABLE shipment');
|
|
||||||
$this->addSql('DROP TABLE shipment_type');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace DoctrineMigrations;
|
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
|
||||||
use Doctrine\Migrations\AbstractMigration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Auto-generated Migration: Please modify to your needs!
|
|
||||||
*/
|
|
||||||
final class Version20260204102423 extends AbstractMigration
|
|
||||||
{
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this up() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT fk_2cb20dc545317d1');
|
|
||||||
$this->addSql('DROP INDEX idx_2cb20dc545317d1');
|
|
||||||
$this->addSql('ALTER TABLE shipment DROP vehicle_id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('ALTER TABLE shipment ADD vehicle_id INT DEFAULT NULL');
|
|
||||||
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT fk_2cb20dc545317d1 FOREIGN KEY (vehicle_id) REFERENCES vehicle (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
||||||
$this->addSql('CREATE INDEX idx_2cb20dc545317d1 ON shipment (vehicle_id)');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -35,27 +35,27 @@ class Address
|
|||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 120)]
|
#[ORM\Column(length: 120)]
|
||||||
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
|
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||||
private string $label = '';
|
private string $label = '';
|
||||||
|
|
||||||
#[ORM\Column(length: 180)]
|
#[ORM\Column(length: 180)]
|
||||||
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
|
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||||
private string $street = '';
|
private string $street = '';
|
||||||
|
|
||||||
#[ORM\Column(name: 'street2', length: 180, nullable: true)]
|
#[ORM\Column(name: 'street2', length: 180, nullable: true)]
|
||||||
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
|
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||||
private ?string $street2 = null;
|
private ?string $street2 = null;
|
||||||
|
|
||||||
#[ORM\Column(name: 'postal_code', length: 20)]
|
#[ORM\Column(name: 'postal_code', length: 20)]
|
||||||
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
|
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||||
private string $postalCode = '';
|
private string $postalCode = '';
|
||||||
|
|
||||||
#[ORM\Column(length: 120)]
|
#[ORM\Column(length: 120)]
|
||||||
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
|
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||||
private string $city = '';
|
private string $city = '';
|
||||||
|
|
||||||
#[ORM\Column(name: 'country_code', length: 2)]
|
#[ORM\Column(name: 'country_code', length: 2)]
|
||||||
#[Groups(['address:read', 'supplier:read', 'customer:read'])]
|
#[Groups(['address:read', 'supplier:read'])]
|
||||||
private string $countryCode = '';
|
private string $countryCode = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
|
||||||
use ApiPlatform\Metadata\Get;
|
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use Symfony\Component\Serializer\Attribute\Groups;
|
|
||||||
|
|
||||||
#[ORM\Entity]
|
|
||||||
#[ORM\Table(name: 'bovin_shipment')]
|
|
||||||
#[ApiResource(
|
|
||||||
operations: [
|
|
||||||
new Get(
|
|
||||||
requirements: ['id' => '\d+'],
|
|
||||||
normalizationContext: ['groups' => ['bovin-shipment:read']],
|
|
||||||
),
|
|
||||||
new GetCollection(
|
|
||||||
normalizationContext: ['groups' => ['bovin-shipment:read']],
|
|
||||||
),
|
|
||||||
|
|
||||||
// new Get(
|
|
||||||
// uriTemplate: '/receptions/weigh',
|
|
||||||
// openapi: new OpenApiOperation(
|
|
||||||
// summary: 'Fetch the current weight reading',
|
|
||||||
// description: 'Queries the pont-bascule and returns the weight data.',
|
|
||||||
// ),
|
|
||||||
// normalizationContext: ['groups' => ['reception:weigh:read']],
|
|
||||||
// output: PontBasculeReading::class,
|
|
||||||
// provider: ReceptionWeighingProvider::class,
|
|
||||||
// ),
|
|
||||||
// new Get(
|
|
||||||
// uriTemplate: '/receptions/{id}/receipt',
|
|
||||||
// requirements: ['id' => '\d+'],
|
|
||||||
// openapi: new OpenApiOperation(
|
|
||||||
// summary: 'Render a reception receipt',
|
|
||||||
// description: 'Returns a PDF receipt for the reception.',
|
|
||||||
// ),
|
|
||||||
// output: false,
|
|
||||||
// provider: ReceptionReceiptProvider::class,
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
)]
|
|
||||||
class BovinShipment
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
#[Groups(['shipment:read', 'bovine-shipment:read'])]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'shipment_types')]
|
|
||||||
#[Groups(['bovine-shipment:read'])]
|
|
||||||
private ?Shipment $shipment = null;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne]
|
|
||||||
#[Groups(['shipment:read', 'bovine-shipment:read'])]
|
|
||||||
private ?ShipmentType $shipmentType = null;
|
|
||||||
|
|
||||||
#[ORM\Column]
|
|
||||||
#[Groups(['shipment:read', 'bovine-shipment:read'])]
|
|
||||||
private ?int $nbBovinSend = null;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShipment(): ?Shipment
|
|
||||||
{
|
|
||||||
return $this->shipment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setShipment(?Shipment $shipment): void
|
|
||||||
{
|
|
||||||
$this->shipment = $shipment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShipmentType(): ?ShipmentType
|
|
||||||
{
|
|
||||||
return $this->shipmentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setShipmentType(?ShipmentType $shipmentType): void
|
|
||||||
{
|
|
||||||
$this->shipmentType = $shipmentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNbBovinSend(): ?int
|
|
||||||
{
|
|
||||||
return $this->nbBovinSend;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setNbBovinSend(?int $nbBovinSend): void
|
|
||||||
{
|
|
||||||
$this->nbBovinSend = $nbBovinSend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,8 +7,6 @@ namespace App\Entity;
|
|||||||
use ApiPlatform\Metadata\ApiResource;
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
use ApiPlatform\Metadata\Get;
|
use ApiPlatform\Metadata\Get;
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
use ApiPlatform\Metadata\GetCollection;
|
||||||
use ApiPlatform\Metadata\Patch;
|
|
||||||
use ApiPlatform\Metadata\Post;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Serializer\Attribute\Groups;
|
use Symfony\Component\Serializer\Attribute\Groups;
|
||||||
|
|
||||||
@@ -23,15 +21,6 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
|||||||
new GetCollection(
|
new GetCollection(
|
||||||
normalizationContext: ['groups' => ['carrier:read']],
|
normalizationContext: ['groups' => ['carrier:read']],
|
||||||
),
|
),
|
||||||
new Post(
|
|
||||||
normalizationContext: ['groups' => ['carrier:read']],
|
|
||||||
denormalizationContext: ['groups' => ['carrier:write']],
|
|
||||||
),
|
|
||||||
new Patch(
|
|
||||||
requirements: ['id' => '\d+'],
|
|
||||||
normalizationContext: ['groups' => ['carrier:read']],
|
|
||||||
denormalizationContext: ['groups' => ['carrier:write']],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
security: "is_granted('ROLE_USER')",
|
security: "is_granted('ROLE_USER')",
|
||||||
)]
|
)]
|
||||||
@@ -40,15 +29,15 @@ class Carrier
|
|||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read', 'shipment:read'])]
|
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read'])]
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 180)]
|
#[ORM\Column(length: 180)]
|
||||||
#[Groups(['carrier:read', 'carrier:write', 'driver:read', 'vehicle:read', 'reception:read', 'shipment:read'])]
|
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read'])]
|
||||||
private string $name = '';
|
private string $name = '';
|
||||||
|
|
||||||
#[ORM\Column(length: 30, nullable: true)]
|
#[ORM\Column(length: 30, nullable: true)]
|
||||||
#[Groups(['carrier:read', 'carrier:write', 'driver:read', 'vehicle:read', 'reception:read', 'shipment:read'])]
|
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read'])]
|
||||||
private ?string $code = null;
|
private ?string $code = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use ApiPlatform\Metadata\ApiProperty;
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
|
||||||
use ApiPlatform\Metadata\Get;
|
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use Symfony\Component\Serializer\Attribute\Groups;
|
|
||||||
|
|
||||||
#[ORM\Entity]
|
|
||||||
#[ORM\Table(name: 'customer')]
|
|
||||||
#[ApiResource(
|
|
||||||
operations: [
|
|
||||||
new Get(
|
|
||||||
requirements: ['id' => '\d+'],
|
|
||||||
normalizationContext: ['groups' => ['customer:read']],
|
|
||||||
),
|
|
||||||
new GetCollection(
|
|
||||||
normalizationContext: ['groups' => ['customer:read']],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
security: "is_granted('ROLE_USER')",
|
|
||||||
)]
|
|
||||||
class Customer
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
#[Groups(['shipment:read', 'customer:read'])]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
#[Groups(['customer:read', 'shipment:read'])]
|
|
||||||
private ?string $label = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
#[Groups(['customer:read', 'shipment:read'])]
|
|
||||||
private ?string $code = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Collection<int, Address>
|
|
||||||
*/
|
|
||||||
#[ORM\ManyToMany(targetEntity: Address::class, inversedBy: 'customers')]
|
|
||||||
#[ORM\JoinTable(name: 'customer_address')]
|
|
||||||
#[Groups(['customer:read'])]
|
|
||||||
#[ApiProperty(readableLink: true)]
|
|
||||||
private Collection $addresses;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->addresses = new ArrayCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLabel(): ?string
|
|
||||||
{
|
|
||||||
return $this->label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setLabel(?string $label): void
|
|
||||||
{
|
|
||||||
$this->label = $label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCode(): ?string
|
|
||||||
{
|
|
||||||
return $this->code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCode(?string $code): void
|
|
||||||
{
|
|
||||||
$this->code = $code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAddresses(): Collection
|
|
||||||
{
|
|
||||||
return $this->addresses;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setAddresses(Collection $addresses): void
|
|
||||||
{
|
|
||||||
$this->addresses = $addresses;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,244 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use ApiPlatform\Metadata\ApiProperty;
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
|
||||||
use ApiPlatform\Metadata\Get;
|
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
|
||||||
use ApiPlatform\Metadata\Patch;
|
|
||||||
use ApiPlatform\Metadata\Post;
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use Symfony\Component\Serializer\Attribute\Context;
|
|
||||||
use Symfony\Component\Serializer\Attribute\Groups;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
|
||||||
|
|
||||||
#[ORM\Entity]
|
|
||||||
#[ORM\Table(name: 'shipment')]
|
|
||||||
#[ApiResource(
|
|
||||||
operations: [
|
|
||||||
new Get(
|
|
||||||
requirements: ['id' => '\d+'],
|
|
||||||
normalizationContext: ['groups' => ['shipment:read']],
|
|
||||||
),
|
|
||||||
new GetCollection(
|
|
||||||
normalizationContext: ['groups' => ['shipment:read']],
|
|
||||||
),
|
|
||||||
new Post(
|
|
||||||
normalizationContext: ['groups' => ['shipment:read']],
|
|
||||||
denormalizationContext: ['groups' => ['shipment:write']],
|
|
||||||
),
|
|
||||||
new Patch(
|
|
||||||
requirements: ['id' => '\d+'],
|
|
||||||
normalizationContext: ['groups' => ['shipment:read']],
|
|
||||||
denormalizationContext: ['groups' => ['shipment:write']],
|
|
||||||
),
|
|
||||||
// new Get(
|
|
||||||
// uriTemplate: '/shipments/weigh',
|
|
||||||
// openapi: new OpenApiOperation(
|
|
||||||
// summary: 'Fetch the current weight reading',
|
|
||||||
// description: 'Queries the pont-bascule and returns the weight data.',
|
|
||||||
// ),
|
|
||||||
// normalizationContext: ['groups' => ['shipment:weigh:read']],
|
|
||||||
// output: PontBasculeReading::class,
|
|
||||||
// provider: shipmentWeighingProvider::class,
|
|
||||||
// ),
|
|
||||||
// new Get(
|
|
||||||
// uriTemplate: '/shipments/{id}/receipt',
|
|
||||||
// requirements: ['id' => '\d+'],
|
|
||||||
// openapi: new OpenApiOperation(
|
|
||||||
// summary: 'Render a shipment receipt',
|
|
||||||
// description: 'Returns a PDF receipt for the shipment.',
|
|
||||||
// ),
|
|
||||||
// output: false,
|
|
||||||
// provider: shipmentReceiptProvider::class,
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
)]
|
|
||||||
class Shipment
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
#[Groups(['shipment:read'])]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
private ?string $licencePlate = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 20, unique: true, nullable: true)]
|
|
||||||
#[Groups(['shipment:read'])]
|
|
||||||
private ?string $identificationNumber = null;
|
|
||||||
|
|
||||||
#[ORM\Column(options: ['default' => 0])]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
private int $currentStep = 0;
|
|
||||||
|
|
||||||
#[ORM\Column]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
private ?bool $isValid = null;
|
|
||||||
|
|
||||||
#[ORM\Column(name: 'shipment_date', type: 'datetime_immutable')]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
|
|
||||||
private ?DateTimeImmutable $shipmentDate = null;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne]
|
|
||||||
#[ORM\JoinColumn(nullable: true)]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
#[ApiProperty(readableLink: true)]
|
|
||||||
private ?Carrier $carrier = null;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne]
|
|
||||||
#[ORM\JoinColumn(nullable: true)]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
#[ApiProperty(readableLink: true)]
|
|
||||||
private ?Truck $truck = null;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
private ?Customer $customer = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Collection<int, BovinShipment>
|
|
||||||
*/
|
|
||||||
#[ORM\OneToMany(targetEntity: BovinShipment::class, mappedBy: 'shipment')]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
private Collection $bovinShipments;
|
|
||||||
|
|
||||||
public function __construct(Collection $bovinShipments)
|
|
||||||
{
|
|
||||||
$this->bovinShipments = $bovinShipments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLicencePlate(): ?string
|
|
||||||
{
|
|
||||||
return $this->licencePlate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setLicencePlate(?string $licencePlate): void
|
|
||||||
{
|
|
||||||
$this->licencePlate = $licencePlate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIdentificationNumber(): ?string
|
|
||||||
{
|
|
||||||
return $this->identificationNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setIdentificationNumber(?string $identificationNumber): void
|
|
||||||
{
|
|
||||||
$this->identificationNumber = $identificationNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCurrentStep(): int
|
|
||||||
{
|
|
||||||
return $this->currentStep;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCurrentStep(int $currentStep): void
|
|
||||||
{
|
|
||||||
$this->currentStep = $currentStep;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIsValid(): ?bool
|
|
||||||
{
|
|
||||||
return $this->isValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setIsValid(?bool $isValid): void
|
|
||||||
{
|
|
||||||
$this->isValid = $isValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShipmentDate(): ?DateTimeImmutable
|
|
||||||
{
|
|
||||||
return $this->shipmentDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setShipmentDate(?DateTimeImmutable $shipmentDate): void
|
|
||||||
{
|
|
||||||
$this->shipmentDate = $shipmentDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCarrier(): ?Carrier
|
|
||||||
{
|
|
||||||
return $this->carrier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCarrier(?Carrier $carrier): void
|
|
||||||
{
|
|
||||||
$this->carrier = $carrier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getVehicle(): ?Vehicle
|
|
||||||
{
|
|
||||||
return $this->vehicle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setVehicle(?Vehicle $vehicle): void
|
|
||||||
{
|
|
||||||
$this->vehicle = $vehicle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTruck(): ?Truck
|
|
||||||
{
|
|
||||||
return $this->truck;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTruck(?Truck $truck): void
|
|
||||||
{
|
|
||||||
$this->truck = $truck;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCustomer(): ?Customer
|
|
||||||
{
|
|
||||||
return $this->customer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCustomer(?Customer $customer): void
|
|
||||||
{
|
|
||||||
$this->customer = $customer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBovinShipments(): Collection
|
|
||||||
{
|
|
||||||
return $this->bovinShipments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setBovinShipments(Collection $bovinShipments): void
|
|
||||||
{
|
|
||||||
$this->bovinShipments = $bovinShipments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addPelletBuilding(BovinShipment $bovinShipments): self
|
|
||||||
{
|
|
||||||
if (!$this->bovinShipments->contains($bovinShipments)) {
|
|
||||||
$this->bovinShipments->add($bovinShipments);
|
|
||||||
$bovinShipments->setReception($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removePelletBuilding(BovinShipment $bovinShipments): self
|
|
||||||
{
|
|
||||||
if ($this->bovinShipments->removeElement($bovinShipments)) {
|
|
||||||
if ($bovinShipments->getReception() === $this) {
|
|
||||||
$bovinShipments->setReception(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
|
||||||
use ApiPlatform\Metadata\Get;
|
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use Symfony\Component\Serializer\Attribute\Groups;
|
|
||||||
|
|
||||||
#[ORM\Entity]
|
|
||||||
#[ORM\Table(name: 'shipment_type')]
|
|
||||||
#[ApiResource(
|
|
||||||
operations: [
|
|
||||||
new Get(
|
|
||||||
requirements: ['id' => '\d+'],
|
|
||||||
normalizationContext: ['groups' => ['shipment-type:read']],
|
|
||||||
),
|
|
||||||
new GetCollection(
|
|
||||||
normalizationContext: ['groups' => ['shipment-type:read']],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
security: "is_granted('ROLE_USER')",
|
|
||||||
)]
|
|
||||||
class ShipmentType
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
#[Groups(['shipment-type:read', 'shipment:read'])]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
#[Groups(['shipment-type:read', 'shipment:read'])]
|
|
||||||
private ?string $label = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
#[Groups(['shipment-type:read', 'shipment:read'])]
|
|
||||||
private ?string $code = null;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLabel(): ?string
|
|
||||||
{
|
|
||||||
return $this->label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setLabel(string $label): static
|
|
||||||
{
|
|
||||||
$this->label = $label;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCode(): ?string
|
|
||||||
{
|
|
||||||
return $this->code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCode(string $code): self
|
|
||||||
{
|
|
||||||
$this->code = $code;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,10 +7,7 @@ namespace App\Entity;
|
|||||||
use ApiPlatform\Metadata\ApiResource;
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
use ApiPlatform\Metadata\Get;
|
use ApiPlatform\Metadata\Get;
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
use ApiPlatform\Metadata\GetCollection;
|
||||||
use ApiPlatform\Metadata\Patch;
|
|
||||||
use ApiPlatform\Metadata\Post;
|
|
||||||
use App\State\MeProvider;
|
use App\State\MeProvider;
|
||||||
use App\State\UserPasswordProcessor;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
@@ -31,27 +28,10 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
|||||||
normalizationContext: ['groups' => ['user:read']],
|
normalizationContext: ['groups' => ['user:read']],
|
||||||
security: "is_granted('ROLE_USER')"
|
security: "is_granted('ROLE_USER')"
|
||||||
),
|
),
|
||||||
new Post(
|
|
||||||
normalizationContext: ['groups' => ['user:read']],
|
|
||||||
denormalizationContext: ['groups' => ['user:write']],
|
|
||||||
security: "is_granted('ROLE_ADMIN')",
|
|
||||||
processor: UserPasswordProcessor::class
|
|
||||||
),
|
|
||||||
new Patch(
|
|
||||||
normalizationContext: ['groups' => ['user:read']],
|
|
||||||
denormalizationContext: ['groups' => ['user:write']],
|
|
||||||
security: "is_granted('ROLE_ADMIN')",
|
|
||||||
processor: UserPasswordProcessor::class
|
|
||||||
),
|
|
||||||
new GetCollection(
|
new GetCollection(
|
||||||
normalizationContext: ['groups' => ['user-login:read']],
|
normalizationContext: ['groups' => ['user:read']],
|
||||||
security: "is_granted('PUBLIC_ACCESS')"
|
security: "is_granted('PUBLIC_ACCESS')"
|
||||||
),
|
),
|
||||||
new GetCollection(
|
|
||||||
uriTemplate: '/admin/users',
|
|
||||||
normalizationContext: ['groups' => ['user:read']],
|
|
||||||
security: "is_granted('ROLE_ADMIN')"
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
normalizationContext: ['groups' => ['user:read']],
|
normalizationContext: ['groups' => ['user:read']],
|
||||||
paginationEnabled: false
|
paginationEnabled: false
|
||||||
@@ -61,19 +41,18 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
#[ORM\Column(type: 'integer')]
|
#[ORM\Column(type: 'integer')]
|
||||||
#[Groups(['user:read', 'user-login:read', 'reception:read'])]
|
#[Groups(['user:read', 'reception:read'])]
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 180, unique: true)]
|
#[ORM\Column(length: 180, unique: true)]
|
||||||
#[Groups(['user:read', 'user:write', 'user-login:read', 'reception:read'])]
|
#[Groups(['user:read', 'reception:read'])]
|
||||||
private string $username = '';
|
private string $username = '';
|
||||||
|
|
||||||
#[ORM\Column(type: 'json')]
|
#[ORM\Column(type: 'json')]
|
||||||
#[Groups(['user:write', 'user:read'])]
|
#[Groups(['user:read'])]
|
||||||
private array $roles = [];
|
private array $roles = [];
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
#[Groups(['user:write'])]
|
|
||||||
private string $password = '';
|
private string $password = '';
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\State;
|
|
||||||
|
|
||||||
use ApiPlatform\Metadata\Operation;
|
|
||||||
use ApiPlatform\State\ProcessorInterface;
|
|
||||||
use App\Entity\User;
|
|
||||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
|
||||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
|
||||||
|
|
||||||
final class UserPasswordProcessor implements ProcessorInterface
|
|
||||||
{
|
|
||||||
public function __construct(
|
|
||||||
private readonly UserPasswordHasherInterface $hasher,
|
|
||||||
#[Autowire(service: 'api_platform.doctrine.orm.state.persist_processor')]
|
|
||||||
private readonly ProcessorInterface $persistProcessor
|
|
||||||
) {}
|
|
||||||
|
|
||||||
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): mixed
|
|
||||||
{
|
|
||||||
if ($data instanceof User) {
|
|
||||||
$plain = $data->getPassword();
|
|
||||||
if ('' !== $plain) {
|
|
||||||
$data->setPassword($this->hasher->hashPassword(
|
|
||||||
$data,
|
|
||||||
$plain
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->persistProcessor->process(
|
|
||||||
$data,
|
|
||||||
$operation,
|
|
||||||
$uriVariables,
|
|
||||||
$context
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user