10 Commits

Author SHA1 Message Date
Julien Aldon
4c3c5cfc60 fix status fetch for refresh token
All checks were successful
Deploy Amap / deploy (push) Successful in 41s
2026-03-10 14:28:09 +01:00
Julien Aldon
85df411724 fix status fetch for refresh token
All checks were successful
Deploy Amap / deploy (push) Successful in 40s
2026-03-10 12:45:28 +01:00
Julien Aldon
f0fd0efb7f add status check after refetch
All checks were successful
Deploy Amap / deploy (push) Successful in 42s
2026-03-10 11:38:26 +01:00
Julien Aldon
6a4de725b5 fix recap sort
All checks were successful
Deploy Amap / deploy (push) Successful in 15s
2026-03-09 10:01:10 +01:00
Julien Aldon
71839b0ccf fix recap
All checks were successful
Deploy Amap / deploy (push) Successful in 14s
2026-03-09 09:42:19 +01:00
Julien Aldon
7bf20bafa8 fix sort order for contract recap
All checks were successful
Deploy Amap / deploy (push) Successful in 15s
2026-03-09 09:32:56 +01:00
Julien Aldon
76bc1c2302 fix locales sorting and add form name to contract deletion name
All checks were successful
Deploy Amap / deploy (push) Successful in 42s
2026-03-06 17:17:05 +01:00
Julien Aldon
46b369ecd9 add all suppress modal
All checks were successful
Deploy Amap / deploy (push) Successful in 41s
2026-03-06 16:48:38 +01:00
Julien Aldon
74bf1474e2 fix delete modal
All checks were successful
Deploy Amap / deploy (push) Successful in 41s
2026-03-06 15:50:30 +01:00
Julien Aldon
61710a0347 add delete modal
All checks were successful
Deploy Amap / deploy (push) Successful in 40s
2026-03-06 15:19:07 +01:00
46 changed files with 1278 additions and 767 deletions

View File

@@ -24,3 +24,6 @@
### Show on cascade deletion ### Show on cascade deletion
## Update contract after (without registration) ## Update contract after (without registration)
## Preview form (if not visible can be accessed by referer nothing is stored)
## View and edit contract application (dashboard/contracts/id/edit/)

View File

@@ -196,6 +196,24 @@ def get_contract_file(
) )
@router.get(
'/{_id}/preview-delete',
response_model=list[models.DeleteDependency]
)
async def preview_delete(
_id: int,
session: Session = Depends(get_session),
user: models.User = Depends(get_current_user),
):
if not service.is_allowed(session, user, _id=_id):
raise HTTPException(
status_code=403,
detail=messages.Messages.not_allowed('contract', 'delete')
)
result = []
return result
@router.get('/{form_id}/files') @router.get('/{form_id}/files')
def get_contract_files( def get_contract_files(
form_id: int, form_id: int,
@@ -203,7 +221,7 @@ def get_contract_files(
user: models.User = Depends(get_current_user) user: models.User = Depends(get_current_user)
): ):
"""Get all contract files for a given form""" """Get all contract files for a given form"""
if not service.is_allowed(session, user, form_id): if not form_service.is_allowed(session, user, form_id):
raise HTTPException( raise HTTPException(
status_code=403, status_code=403,
detail=messages.Messages.not_allowed('contracts', 'get') detail=messages.Messages.not_allowed('contracts', 'get')
@@ -250,8 +268,13 @@ def get_contract_recap(
form = form_service.get_one(session, form_id=form_id) form = form_service.get_one(session, form_id=form_id)
contracts = service.get_all(session, user, forms=[form.name]) contracts = service.get_all(session, user, forms=[form.name])
filename = f'{form.name}_recapitulatif_contrats.ods' filename = f'{form.name}_recapitulatif_contrats.ods'
recap = generate_recap(contracts, form)
if recap is None:
raise HTTPException(
status_code=404, detail=messages.Messages.not_found('contracts')
)
return StreamingResponse( return StreamingResponse(
io.BytesIO(generate_recap(contracts, form)), io.BytesIO(recap),
media_type='application/vnd.oasis.opendocument.spreadsheet', media_type='application/vnd.oasis.opendocument.spreadsheet',
headers={ headers={
'Content-Disposition': ( 'Content-Disposition': (

View File

@@ -412,20 +412,34 @@ def generate_recap(
'2': 'Kg', '2': 'Kg',
'3': 'Piece' '3': 'Piece'
} }
if len(contracts) <= 0:
# TODO: raise correct exception
return None
first_contract = contracts[0]
reccurents_sorted = sorted(
[
product for product in first_contract.products
if product.product.type == models.ProductType.RECCURENT
],
key=lambda x: (x.product.name, x.product.quantity)
)
recurrents = [ recurrents = [
f'{pr.name}{f' - {pr.quantity}{pr.quantity_unit}' f'{pr.product.name}{f' - {pr.product.quantity}{pr.product.quantity_unit}'
if pr.quantity else ''} ({product_unit_map[pr.unit]})' if pr.product.quantity else ''} ({product_unit_map[pr.product.unit]})'
for pr in form.productor.products for pr in reccurents_sorted
if pr.type == models.ProductType.RECCURENT
] ]
recurrents.sort() occasionnals_sorted = sorted(
[
product for product in first_contract.products
if product.product.type == models.ProductType.OCCASIONAL
],
key=lambda x: (x.shipment.name, x.product.name)
)
occasionnals = [ occasionnals = [
f'{pr.name}{f' - {pr.quantity}{pr.quantity_unit}' f'{pr.product.name}{f' - {pr.product.quantity}{pr.product.quantity_unit}'
if pr.quantity else ''} ({product_unit_map[pr.unit]})' if pr.product.quantity else ''} ({product_unit_map[pr.product.unit]})'
for pr in form.productor.products for pr in occasionnals_sorted
if pr.type == models.ProductType.OCCASIONAL
] ]
occasionnals.sort()
shipments = form.shipments shipments = form.shipments
occasionnals_header = [ occasionnals_header = [
occ for shipment in shipments for occ in occasionnals occ for shipment in shipments for occ in occasionnals
@@ -501,7 +515,7 @@ def generate_recap(
product for product in contract.products product for product in contract.products
if product.product.type == models.ProductType.RECCURENT if product.product.type == models.ProductType.RECCURENT
], ],
key=lambda x: x.product.name key=lambda x: (x.product.name, x.product.quantity)
) )
main_data.append([ main_data.append([
@@ -567,8 +581,6 @@ def generate_recap(
4, 4,
5, 5,
6, 6,
len(info_header) + len(payment_header),
len(info_header) + len(payment_header) + 1 + len(occasionnals),
] ]
) )
doc.body.append(sheet) doc.body.append(sheet)

View File

@@ -30,6 +30,30 @@ async def get_forms_filtered(
return service.get_all(session, seasons, productors, current_season, user) return service.get_all(session, seasons, productors, current_season, user)
@router.get(
'/{_id}/preview-delete',
response_model=list[models.DeleteDependency]
)
async def preview_delete(
_id: int,
session: Session = Depends(get_session),
user: models.User = Depends(get_current_user),
):
if not service.is_allowed(session, user, _id=_id):
raise HTTPException(
status_code=403,
detail=messages.Messages.not_allowed('forms', 'delete')
)
try:
result = service.get_delete_dependencies(
session,
_id
)
except exceptions.FormNotFoundError as error:
raise HTTPException(status_code=404, detail=str(error)) from error
return result
@router.get('/{_id}', response_model=models.FormPublic) @router.get('/{_id}', response_model=models.FormPublic)
async def get_form( async def get_form(
_id: int, _id: int,

View File

@@ -107,6 +107,43 @@ def delete_one(session: Session, _id: int) -> models.FormPublic:
return result return result
def get_delete_dependencies(
session: Session,
_id: int
) -> list[models.DeleteDependency]:
statement = select(models.Form).where(models.Form.id == _id)
result = session.exec(statement)
form = result.first()
if not form:
raise exceptions.FormNotFoundError(messages.Messages.not_found('form'))
statement_shipment = (
select(models.Shipment)
.where(models.Shipment.form_id == _id)
.distinct()
)
statement_contracts = (
select(models.Contract)
.where(models.Contract.form_id == _id)
.distinct()
)
shipments = session.exec(statement_shipment).all()
contracts = session.exec(statement_contracts).all()
result = [
models.DeleteDependency(
name=sh.name,
id=sh.id,
type='shipment'
) for sh in shipments
] + [
models.DeleteDependency(
name=f'{co.firstname} {co.lastname}',
id=co.id,
type='contract'
) for co in contracts
]
return result
def is_allowed( def is_allowed(
session: Session, session: Session,
user: models.User, user: models.User,

View File

@@ -5,6 +5,12 @@ from typing import Optional
from sqlmodel import Column, Field, LargeBinary, Relationship, SQLModel from sqlmodel import Column, Field, LargeBinary, Relationship, SQLModel
class DeleteDependency(SQLModel):
id: int
name: str
type: str
class ContractType(SQLModel, table=True): class ContractType(SQLModel, table=True):
id: int | None = Field( id: int | None = Field(
default=None, default=None,

View File

@@ -18,6 +18,30 @@ def get_productors(
return service.get_all(session, user, names, types) return service.get_all(session, user, names, types)
@router.get(
'/{_id}/preview-delete',
response_model=list[models.DeleteDependency]
)
async def preview_delete(
_id: int,
session: Session = Depends(get_session),
user: models.User = Depends(get_current_user),
):
if not service.is_allowed(session, user, _id=_id):
raise HTTPException(
status_code=403,
detail=messages.Messages.not_allowed('productors', 'delete')
)
try:
result = service.get_delete_dependencies(
session,
_id
)
except exceptions.ProductorNotFoundError as error:
raise HTTPException(status_code=404, detail=str(error)) from error
return result
@router.get('/{_id}', response_model=models.ProductorPublic) @router.get('/{_id}', response_model=models.ProductorPublic)
def get_productor( def get_productor(
_id: int, _id: int,

View File

@@ -93,6 +93,33 @@ def delete_one(session: Session, _id: int) -> models.ProductorPublic:
session.commit() session.commit()
return result return result
def get_delete_dependencies(
session: Session,
_id: int
) -> list[models.DeleteDependency]:
statement = select(models.Productor).where(models.Productor.id == _id)
result = session.exec(statement)
productor = result.first()
if not productor:
raise exceptions.ProductorNotFoundError(
messages.Messages.not_found('productor'))
products_statement = (
select(models.Product)
.where(models.Product.productor_id == _id)
.distinct()
)
products = session.exec(products_statement).all()
result = [
models.DeleteDependency(
name=pro.name,
id=pro.id,
type='product'
) for pro in products
]
return result
def is_allowed( def is_allowed(
session: Session, session: Session,
user: models.User, user: models.User,

View File

@@ -26,6 +26,23 @@ def get_products(
) )
@router.get(
'/{_id}/preview-delete',
response_model=list[models.DeleteDependency]
)
async def preview_delete(
_id: int,
session: Session = Depends(get_session),
user: models.User = Depends(get_current_user),
):
if not service.is_allowed(session, user, _id=_id):
raise HTTPException(
status_code=403,
detail=messages.Messages.not_allowed('product', 'delete')
)
return []
@router.get('/{_id}', response_model=models.ProductPublic) @router.get('/{_id}', response_model=models.ProductPublic)
def get_product( def get_product(
_id: int, _id: int,

View File

@@ -93,6 +93,7 @@ def delete_one(
session.commit() session.commit()
return result return result
def is_allowed( def is_allowed(
session: Session, session: Session,
user: models.User, user: models.User,
@@ -103,12 +104,8 @@ def is_allowed(
return False return False
if not _id: if not _id:
statement = ( statement = (
select(models.Product) select(models.Productor)
.join( .where(models.Productor.id == product.productor_id)
models.Productor,
models.Product.productor_id == models.Productor.id
)
.where(models.Product.id == product.productor_id)
) )
productor = session.exec(statement).first() productor = session.exec(statement).first()
return productor.type in [r.name for r in user.roles] return productor.type in [r.name for r in user.roles]

View File

@@ -138,11 +138,7 @@ def is_allowed(
return False return False
if not _id: if not _id:
statement = ( statement = (
select(models.Shipment) select(models.Form)
.join(
models.Form,
models.Shipment.form_id == models.Form.id
)
.where(models.Form.id == shipment.form_id) .where(models.Form.id == shipment.form_id)
) )
form = session.exec(statement).first() form = session.exec(statement).first()
@@ -162,4 +158,3 @@ def is_allowed(
.distinct() .distinct()
) )
return len(session.exec(statement).all()) > 0 return len(session.exec(statement).all()) > 0

View File

@@ -26,6 +26,23 @@ def get_shipments(
) )
@router.get(
'/{_id}/preview-delete',
response_model=list[models.DeleteDependency]
)
async def preview_delete(
_id: int,
session: Session = Depends(get_session),
user: models.User = Depends(get_current_user),
):
if not service.is_allowed(session, user, _id=_id):
raise HTTPException(
status_code=403,
detail=messages.Messages.not_allowed('shipment', 'delete')
)
return []
@router.get('/{_id}', response_model=models.ShipmentPublic) @router.get('/{_id}', response_model=models.ShipmentPublic)
def get_shipment( def get_shipment(
_id: int, _id: int,

View File

@@ -36,6 +36,22 @@ def get_roles(
return service.get_roles(session) return service.get_roles(session)
@router.get(
'/{_id}/preview-delete',
response_model=list[models.DeleteDependency]
)
async def preview_delete(
_id: int,
user: models.User = Depends(get_current_user),
):
if not service.is_allowed(user):
raise HTTPException(
status_code=403,
detail=messages.Messages.not_allowed('user', 'delete')
)
return []
@router.get('/{_id}', response_model=models.UserPublic) @router.get('/{_id}', response_model=models.UserPublic)
def get_user( def get_user(
_id: int, _id: int,

View File

@@ -1,215 +1,225 @@
{ {
"help": "help", "a address": "an address",
"how to use dashboard": "how to use the dashboard", "a email": "an email address",
"product name": "product name", "a end date": "an end date",
"product price": "product price", "a fistname": "a first name",
"product quantity": "product quantity", "a form": "a contract form",
"product quantity unit": "product quantity unit", "a lastname": "a last name",
"product type": "product type", "a name": "a name",
"occasional": "occasional", "a new contract form should be created for each new season, do not edit a previous contract and change it's values (for history purpose)": "a new contract form must be created for each new season. Do not edit past contracts.",
"occasional products": "occasional products per shipment", "a payment method": "a payment method",
"select products per shipment": "select products for each shipment.", "a phone": "a phone number",
"recurrent": "recurrent", "a price": "a price",
"recurrent products": "recurrent products", "a price or priceKg": "a price or price per kilogram",
"your selection in this category will apply for all shipments": "your selection will apply to all shipments (Example: For 6 shipments, the product will be counted 6 times: once per shipment).", "a priceKg": "a price per kilogram",
"product price kg": "product price per kilogram", "a product": "a product",
"product unit": "product sales unit", "a product can be edited if its informations change, it should not be recreated for each contracts": "a product can be edited if information changes. It should not be recreated for each contract.",
"piece": "piece", "a product type define the way it will be organized on the final contract form (showed to users) it can be reccurent or occassional. Recurrent products will be set for all shipments if selected by user, Occasional products can be choosen for each shipments": "a product type defines how it will be organized in the final contract form. It can be recurrent or occasional. Recurrent products will be set for all shipments if selected. Occasional products can be chosen for each shipment.",
"in": "in", "a productor": "a producer",
"enter quantity": "enter quantity", "a productor can be edited if its informations change, it should not be recreated for each contracts": "a producer can be edited if information changes. It should not be recreated for each contract.",
"filter by season": "filter by season", "a quantity": "a quantity",
"filter by form": "filter by form", "a quantity unit": "a quantity unit",
"filter by productor": "filter by producer", "a referer": "a referent",
"name": "name", "a season": "a season",
"season": "season", "a sell unit": "a sales unit",
"start": "start", "a shipment": "a shipment",
"end": "end", "a start date": "a start date",
"productor": "producer", "a type": "a type",
"referer": "referent",
"edit form": "edit contract form",
"form name": "contract form name",
"contract season": "contract season",
"contract season recommandation": "recommendation: <Season>-<year> (Example: Winter-2025), if a form is already created, reuse it's season name.",
"start date": "start date",
"end date": "end date",
"nothing found": "nothing to display",
"number of shipment": "number of shipments",
"cancel": "cancel",
"create form": "create contract form",
"create productor": "create producer",
"edit productor": "edit producer",
"remove productor": "remove producer",
"home": "home",
"dashboard": "dashboard",
"filter by name": "filter by name",
"filter by type": "filter by type",
"address": "address",
"payment methods": "payment methods",
"type": "type",
"cheque": "cheque",
"transfer": "bank transfer",
"order name": "cheque payable to",
"productor name": "producer name",
"productor type": "producer type",
"productor address": "producer address",
"productor payment": "producer payment methods",
"priceKg": "price per kilogram",
"quantity": "quantity",
"quantity unit": "quantity unit",
"unit": "sales unit",
"price": "price",
"total price": "total price",
"create product": "create product",
"informations": "information",
"remove product": "remove product",
"edit product": "edit product",
"shipment name": "shipment name",
"shipment date": "shipment date",
"shipments": "shipments",
"shipment": "shipment",
"shipment products": "shipment products",
"shipment form": "shipment related form",
"minimum shipment value": "minimum shipment value (€)",
"shipment products is necessary only for occasional products (if all products are recurrent leave empty)": "shipment products configuration is only necessary for occasional products (leave empty if all products are recurrent).",
"recurrent product is for all shipments, occasional product is for a specific shipment (see shipment form)": "recurrent products are for all shipments, occasional products are for a specific shipment (see shipment form).",
"some contracts require a minimum value per shipment, ignore this field if it's not the case": "some contracts require a minimum value per shipment. Ignore this field if it does not apply to your contract.",
"export contracts": "export contracts",
"download recap": "download recap",
"fill contract online": "fill contract online",
"download base template to print": "download base template to print",
"to export contracts submissions before sending to the productor go to the contracts section": "to export contracts submissions before sending to the productor go to the contracts section.",
"in this page you can view all contracts submissions, you can remove duplicates submission or download a specific contract": "in this page you can view all contracts submissions, you can remove duplicates submission or download a specific contract",
"you can download all contracts for your form using the export all": "you can download all contracts for your form using the export all",
"in the same corner you can download a recap by clicking on the button": "in the same corner you can download a recap by clicking on the",
"once all contracts downloaded, you can delete the form (to avoid new submissions) and hide it from the home page": "once all contracts downloaded, you can delete the form (to avoid new submissions) and hide it from the home page",
"by checking this option the form will be accessible publicly on the home page, only check it if everything is fine with your form": "by checking this option the form will be accessible publicly on the home page, only check it if everything is fine with your form",
"contracts": "contracts",
"hidden": "hidden",
"visible": "visible",
"minimum price for this shipment should be at least": "minimum price for this shipment should be at least",
"there is": "there is",
"for this contract": "for this contract.",
"remove shipment": "remove shipment",
"productors": "producers",
"products": "products",
"templates": "templates",
"users": "users",
"forms": "contract forms",
"max cheque number": "max cheque number",
"can be empty default to 3": "can be empty default to 3",
"form": "contract form",
"select a form": "select a form",
"download contracts": "download contracts",
"all contracts": "all contracts",
"remove contract": "remove contract",
"download contract": "download contract",
"by selecting a form here you can download all contracts of your form": "by selecting a form here you can download all contracts of your form.",
"edit user": "edit user",
"remove user": "remove user",
"logout": "logout",
"all forms": "all contract forms",
"create new form": "create new contract form",
"actions": "actions", "actions": "actions",
"add all products linked to this productor in the products section": "add your products linked to the producer in the \"Products\" section.",
"address": "address",
"all contracts": "all contracts",
"all forms": "all contract forms",
"all productors": "all producers", "all productors": "all producers",
"all products": "all products", "all products": "all products",
"all shipments": "all shipments",
"all referers": "all referents", "all referers": "all referents",
"is required": "is required", "all shipments": "all shipments",
"a name": "a name",
"a season": "a season",
"a start date": "a start date",
"a end date": "an end date",
"a productor": "a producer",
"a referer": "a referent",
"a phone": "a phone number",
"a fistname": "a first name",
"a lastname": "a last name",
"a email": "an email address",
"a price or priceKg": "a price or price per kilogram",
"a address": "an address",
"a type": "a type",
"a form": "a contract form",
"a price": "a price",
"a priceKg": "a price per kilogram",
"a quantity": "a quantity",
"a product": "a product",
"a quantity unit": "a quantity unit",
"a payment method": "a payment method",
"a sell unit": "a sales unit",
"sell unit": "sales unit",
"product": "product",
"a shipment": "a shipment",
"the products": "the products",
"the shipments": "the shipments",
"link to the section": "link to section: {{section}}",
"to add a use the": "to add {{section}} use the button",
"to edit a use the": "to edit {{section}} use the button",
"to delete a use the": "to delete {{section}} use the button",
"button in top right of the page": "at the top right of the {{section}} page.",
"button in front of the line you want to edit": "in front of the line you want to edit (in the actions column).",
"button in front of the line you want to delete": "in front of the line you want to delete (in the actions column).",
"glossary": "glossary",
"start to create a productor in the productors section": "start by creating a producer in the \"Producers\" section.",
"add all products linked to this productor in the products section": "add your products linked to the producer in the \"Products\" section.",
"create your contract form, it will create a form in the home page (accessible to users)": "create your contract form in the \"Contract Forms\" section. Adding an entry here will create a form on the home page.",
"create shipments for your contract form": "create shipments for your contract",
"creation order": "creation order",
"dashboard is for referers only, with this dashboard you can create productors, products, forms and shipments": "the dashboard is only visible to referents. You can create your producer, products, contract forms, and shipments.",
"is defined by": "is defined by",
"a product type define the way it will be organized on the final contract form (showed to users) it can be reccurent or occassional. Recurrent products will be set for all shipments if selected by user, Occasional products can be choosen for each shipments": "a product type defines how it will be organized in the final contract form. It can be recurrent or occasional. Recurrent products will be set for all shipments if selected. Occasional products can be chosen for each shipment.",
"and/or": "and/or",
"form name recommandation": "recommendation: Contract <contract-type> (Example: Pork-Lamb Contract)",
"submit contract": "submit contract",
"submit": "submit",
"example in user forms": "example in user contract form",
"occasional product": "occasional product",
"recurrent product": "recurrent product",
"with grams as product unit selected": "with grams selected as product unit",
"product example": "product example",
"payment methods are defined for a productor. At the end of a form a section payment method let the user select his prefered payment method": "payment methods are defined for a producer. At the end of the form, users can select their preferred payment method.",
"with cheque and transfer": "with cheque and transfer configured for the producer",
"mililiter": "milliliters (ml)",
"this field is optionnal a product can have a quantity if configured inside the product it will be shown inside the form": "this field is optional. It represents the product quantity and will be shown in the form.",
"this field is also optionnal if a product have a quantity you can select the correct unit (metric system). It will be shown next to product quantity inside the form": "this field is optional. It represents the measurement unit and will be shown next to the quantity.",
"with 150 set as quantity and g as quantity unit in product": "with 150 set as quantity and grams selected as quantity unit",
"all shipments should be recreated for each form creation": "shipments must be recreated for each new contract form.", "all shipments should be recreated for each form creation": "shipments must be recreated for each new contract form.",
"a productor can be edited if its informations change, it should not be recreated for each contracts": "a producer can be edited if information changes. It should not be recreated for each contract.", "all theses informations are for contract generation": "all this information is required for contract generation.",
"a product can be edited if its informations change, it should not be recreated for each contracts": "a product can be edited if information changes. It should not be recreated for each contract.", "and/or": "and/or",
"a new contract form should be created for each new season, do not edit a previous contract and change it's values (for history purpose)": "a new contract form must be created for each new season. Do not edit past contracts.", "are you sure you want to delete": "are you sure you want to delete",
"grams": "grams (g)", "button in front of the line you want to delete": "in front of the line you want to delete (in the actions column).",
"kilo": "kilograms (kg)", "button in front of the line you want to edit": "in front of the line you want to edit (in the actions column).",
"liter": "liters (L)", "button in top right of the page": "at the top right of the {{section}} page.",
"success": "success", "by checking this option the form will be accessible publicly on the home page, only check it if everything is fine with your form": "by checking this option the form will be accessible publicly on the home page, only check it if everything is fine with your form",
"success edit": "{{entity}} correctly edited", "by selecting a form here you can download all contracts of your form": "by selecting a form here you can download all contracts of your form.",
"success create": "{{entity}} correctly created", "can be empty default to 3": "can be empty default to 3",
"success delete": "{{entity}} correctly deleted", "cancel": "cancel",
"cheque": "cheque",
"cheque id": "cheque identifier",
"cheque quantity": "number of cheques",
"cheque value": "cheque amount",
"choose payment method": "choose your payment method (you do not need to pay now).",
"contract": "contract",
"contract season": "contract season",
"contract season recommandation": "recommendation: <Season>-<year> (Example: Winter-2025), if a form is already created, reuse it's season name.",
"contracts": "contracts",
"create form": "create contract form",
"create new form": "create new contract form",
"create product": "create product",
"create productor": "create producer",
"create shipment": "create shipment",
"create shipments for your contract form": "create shipments for your contract",
"create user": "create user",
"create your contract form, it will create a form in the home page (accessible to users)": "create your contract form in the \"Contract Forms\" section. Adding an entry here will create a form on the home page.",
"creation order": "creation order",
"dashboard": "dashboard",
"dashboard is for referers only, with this dashboard you can create productors, products, forms and shipments": "the dashboard is only visible to referents. You can create your producer, products, contract forms, and shipments.",
"delete": "delete",
"delete entity": "delete {{entity}}",
"download base template to print": "download base template to print",
"download contract": "download contract",
"download contracts": "download contracts",
"download recap": "download recap",
"edit form": "edit contract form",
"edit product": "edit product",
"edit productor": "edit producer",
"edit shipment": "edit shipment",
"edit user": "edit user",
"end": "end",
"end date": "end date",
"enter cheque quantity": "enter number of cheques",
"enter cheque value": "enter cheque amount",
"enter payment method": "select your payment method",
"enter quantity": "enter quantity",
"error": "error", "error": "error",
"error edit": "error during edit {{entity}}",
"error create": "error during create {{entity}}", "error create": "error during create {{entity}}",
"error delete": "error during suppress {{entity}}", "error delete": "error during suppress {{entity}}",
"of the user": "of the user", "error edit": "error during edit {{entity}}",
"example in user forms": "example in user contract form",
"export contracts": "export contracts",
"fill contract online": "fill contract online",
"filter by form": "filter by form",
"filter by name": "filter by name",
"filter by productor": "filter by producer",
"filter by season": "filter by season",
"filter by type": "filter by type",
"for this contract": "for this contract.",
"for transfer method contact your referer or productor": "for bank transfer, contact your referent or producer.",
"form": "contract form",
"form name": "contract form name",
"form name recommandation": "recommendation: Contract <contract-type> (Example: Pork-Lamb Contract)",
"forms": "contract forms",
"glossary": "glossary",
"grams": "grams (g)",
"help": "help",
"hidden": "hidden",
"home": "home",
"how to use dashboard": "how to use the dashboard",
"in": "in",
"in the same corner you can download a recap by clicking on the button": "in the same corner you can download a recap by clicking on the",
"in this page you can view all contracts submissions, you can remove duplicates submission or download a specific contract": "in this page you can view all contracts submissions, you can remove duplicates submission or download a specific contract",
"informations": "information",
"is defined by": "is defined by",
"is required": "is required",
"kilo": "kilograms (kg)",
"link to the section": "link to section: {{section}}",
"liter": "liters (L)",
"login with keycloak": "login with keycloak",
"logout": "logout",
"max cheque number": "max cheque number",
"mililiter": "milliliters (ml)",
"minimum price for this shipment should be at least": "minimum price for this shipment should be at least",
"minimum shipment value": "minimum shipment value (€)",
"name": "name",
"nothing found": "nothing to display",
"number of cheques between 1 and 3 cheques also enter your cheques identifiers, value is calculated automatically": "number of cheques between 1 and 3. Also enter cheque identifiers.",
"number of shipment": "number of shipments",
"occasional": "occasional",
"occasional product": "occasional product",
"occasional products": "occasional products per shipment",
"of the contract": "of the contract",
"of the form": "of the form", "of the form": "of the form",
"of the product": "of the product", "of the product": "of the product",
"of the productor": "of the producer", "of the productor": "of the producer",
"of the shipment": "of the shipment", "of the shipment": "of the shipment",
"of the contract": "of the contract", "of the user": "of the user",
"login with keycloak": "login with keycloak", "once all contracts downloaded, you can delete the form (to avoid new submissions) and hide it from the home page": "once all contracts downloaded, you can delete the form (to avoid new submissions) and hide it from the home page",
"there is no contract for now": "there is no contract at the moment.", "order name": "cheque payable to",
"for transfer method contact your referer or productor": "for bank transfer, contact your referent or producer.",
"cheque quantity": "number of cheques",
"enter cheque quantity": "enter number of cheques",
"cheque id": "cheque identifier",
"cheque value": "cheque amount",
"enter cheque value": "enter cheque amount",
"enter payment method": "select your payment method",
"number of cheques between 1 and 3 cheques also enter your cheques identifiers, value is calculated automatically": "number of cheques between 1 and 3. Also enter cheque identifiers.",
"payment method": "payment method", "payment method": "payment method",
"your session has expired please log in again": "your session has expired please log in again", "payment methods": "payment methods",
"session expired": "session expired", "payment methods are defined for a productor. At the end of a form a section payment method let the user select his prefered payment method": "payment methods are defined for a producer. At the end of the form, users can select their preferred payment method.",
"user not allowed": "user not allowed", "piece": "piece",
"price": "price",
"priceKg": "price per kilogram",
"product": "product",
"product example": "product example",
"product name": "product name",
"product price": "product price",
"product price kg": "product price per kilogram",
"product quantity": "product quantity",
"product quantity unit": "product quantity unit",
"product type": "product type",
"product unit": "product sales unit",
"productor": "producer",
"productor address": "producer address",
"productor name": "producer name",
"productor payment": "producer payment methods",
"productor type": "producer type",
"productors": "producers",
"products": "products",
"quantity": "quantity",
"quantity unit": "quantity unit",
"recurrent": "recurrent",
"recurrent product": "recurrent product",
"recurrent product is for all shipments, occasional product is for a specific shipment (see shipment form)": "recurrent products are for all shipments, occasional products are for a specific shipment (see shipment form).",
"recurrent products": "recurrent products",
"referer": "referent",
"remove contract": "remove contract",
"remove form": "remove form",
"remove product": "remove product",
"remove productor": "remove producer",
"remove shipment": "remove shipment",
"remove user": "remove user",
"roles": "roles", "roles": "roles",
"your keycloak user has no roles, please contact your administrator": "your keycloak user has no roles, please contact your administrator", "season": "season",
"choose payment method": "choose your payment method (you do not need to pay now).", "select a form": "select a form",
"select products per shipment": "select products for each shipment.",
"sell unit": "sales unit",
"session expired": "session expired",
"shipment": "shipment",
"shipment date": "shipment date",
"shipment form": "shipment related form",
"shipment name": "shipment name",
"shipment products": "shipment products",
"shipment products is necessary only for occasional products (if all products are recurrent leave empty)": "shipment products configuration is only necessary for occasional products (leave empty if all products are recurrent).",
"shipments": "shipments",
"some contracts require a minimum value per shipment, ignore this field if it's not the case": "some contracts require a minimum value per shipment. Ignore this field if it does not apply to your contract.",
"start": "start",
"start date": "start date",
"start to create a productor in the productors section": "start by creating a producer in the \"Producers\" section.",
"submit": "submit",
"submit contract": "submit contract",
"success": "success",
"success create": "{{entity}} correctly created",
"success delete": "{{entity}} correctly deleted",
"success edit": "{{entity}} correctly edited",
"templates": "templates",
"the product unit will be assigned to the quantity requested in the form": "the product unit defines the unit used in the contract form.", "the product unit will be assigned to the quantity requested in the form": "the product unit defines the unit used in the contract form.",
"all theses informations are for contract generation": "all this information is required for contract generation." "the products": "the products",
"the shipments": "the shipments",
"there is": "there is",
"there is no contract for now": "there is no contract at the moment.",
"this field is also optionnal if a product have a quantity you can select the correct unit (metric system). It will be shown next to product quantity inside the form": "this field is optional. It represents the measurement unit and will be shown next to the quantity.",
"this field is optionnal a product can have a quantity if configured inside the product it will be shown inside the form": "this field is optional. It represents the product quantity and will be shown in the form.",
"this will also delete": "this will also delete",
"to add a use the": "to add {{section}} use the button",
"to delete a use the": "to delete {{section}} use the button",
"to edit a use the": "to edit {{section}} use the button",
"to export contracts submissions before sending to the productor go to the contracts section": "to export contracts submissions before sending to the productor go to the contracts section.",
"total price": "total price",
"transfer": "bank transfer",
"type": "type",
"unit": "sales unit",
"user": "user",
"user not allowed": "user not allowed",
"users": "users",
"visible": "visible",
"with 150 set as quantity and g as quantity unit in product": "with 150 set as quantity and grams selected as quantity unit",
"with cheque and transfer": "with cheque and transfer configured for the producer",
"with grams as product unit selected": "with grams selected as product unit",
"you can download all contracts for your form using the export all": "you can download all contracts for your form using the export all",
"your keycloak user has no roles, please contact your administrator": "your keycloak user has no roles, please contact your administrator",
"your selection in this category will apply for all shipments": "your selection will apply to all shipments (Example: For 6 shipments, the product will be counted 6 times: once per shipment).",
"your session has expired please log in again": "your session has expired please log in again"
} }

View File

@@ -1,215 +1,225 @@
{ {
"help": "aide", "a address": "une adresse",
"how to use dashboard": "comment utiliser le tableau de bord", "a email": "une adresse email",
"product name": "nom du produit", "a end date": "une date de fin",
"product price": "prix du produit", "a fistname": "un prénom",
"product quantity": "quantité du produit", "a form": "un formulaire de contrat",
"product quantity unit": "unité de quantité du produit", "a lastname": "un nom",
"product type": "type de produit", "a name": "un nom",
"occasional": "occasionnel", "a new contract form should be created for each new season, do not edit a previous contract and change it's values (for history purpose)": "un formulaire de contrat doit être créé pour chaque nouvelle saison, pour des raison d'historique, n'éditez pas un formulaire de contrat passé pour une nouvelle saison, recréez en un nouveau.",
"occasional products": "produits occasionnels par livraison", "a payment method": "une méthode de paiement",
"select products per shipment": "sélectionnez les produits pour chaque livraison.", "a phone": "un numéro de téléphone",
"recurrent": "récurent", "a price": "un prix",
"recurrent products": "produits récurrents", "a price or priceKg": "un prix ou un prix au kilo",
"your selection in this category will apply for all shipments": "votre sélection sera appliquée pour chaque livraisons (Exemple: Pour 6 livraisons, le produits sera compté 6 fois : une fois par livraison).", "a priceKg": "un prix au kilo",
"product price kg": "prix du produit au Kilo", "a product": "un produit",
"product unit": "unité de vente du produit", "a product can be edited if its informations change, it should not be recreated for each contracts": "un produit peut être édité si ses informations changent, il ne doit pas être recréé pour chaque nouveau formulaire de contrat.",
"piece": "pièce", "a product type define the way it will be organized on the final contract form (showed to users) it can be reccurent or occassional. Recurrent products will be set for all shipments if selected by user, Occasional products can be choosen for each shipments": "un type de produit définit la manière dont un produit va être présenté aux amapiens dans le formulaire de contrat. Il peut être récurrent ou occasionnel. Un produit récurrent si selectionné sera compté pour toutes les livraisons. Un produit occasionnel sera facultatif pour chaques livraison (l'amapien devra selectionner la quantité voulue pour chaque livraisons).",
"in": "en", "a productor": "un(e) producteur·trice",
"enter quantity": "entrez la quantité", "a productor can be edited if its informations change, it should not be recreated for each contracts": "un(e) producteur·trice peut être édité si ses informations changent, il/elle ne doit pas être recréé pour chaque nouveau contrat.",
"filter by season": "filtrer par saisons", "a quantity": "une quantité",
"filter by form": "filtrer par formulaire", "a quantity unit": "une unité de quantité",
"filter by productor": "filtrer par producteur·trice", "a referer": "un(e) référent·e",
"name": "nom", "a season": "une saison",
"season": "saison", "a sell unit": "une unité de vente",
"start": "début", "a shipment": "une livraison",
"end": "fin", "a start date": "une date de début",
"productor": "producteur·trice", "a type": "un type",
"referer": "référent·e",
"edit form": "modifier le formulaire de contrat",
"form name": "nom du formulaire de contrat",
"contract season": "saison du contrat",
"contract season recommandation": "recommandation : <Saison>-<année> (Exemple: Hiver-2025), si un formulaire est déjà créé pour la saison, reprenez son nom de saison si possible.",
"start date": "date de début",
"end date": "date de fin",
"nothing found": "rien à afficher",
"number of shipment": "nombre de livraisons",
"cancel": "annuler",
"create form": "créer un formulaire de contrat",
"create productor": "créer le/la producteur·trice",
"edit productor": "modifier le/la producteur·trice",
"remove productor": "supprimer le/la producteur·trice",
"home": "accueil",
"dashboard": "tableau de bord",
"filter by name": "filtrer par nom",
"filter by type": "filtrer par type",
"address": "adresse",
"payment methods": "méthodes de paiement",
"type": "type",
"cheque": "chèque",
"transfer": "virement",
"order name": "ordre du chèque",
"productor name": "nom du producteur·trice",
"productor type": "type du producteur·trice",
"productor address": "adresse du producteur·trice",
"productor payment": "méthodes de paiement du producteur·trice",
"priceKg": "prix au kilo",
"quantity": "quantité",
"quantity unit": "unité de quantité",
"unit": "unité de vente",
"price": "prix",
"total price": "prix total",
"create product": "créer le produit",
"informations": "informations",
"remove product": "supprimer le produit",
"edit product": "modifier le produit",
"shipment name": "nom de la livraison",
"shipment date": "date de la livraison",
"shipments": "livraisons",
"shipment": "livraison",
"shipment products": "produits pour la livraison",
"shipment form": "formulaire lié a la livraison",
"minimum shipment value": "valeur minimum d'une livraison (€)",
"shipment products is necessary only for occasional products (if all products are recurrent leave empty)": "il est nécessaire de configurer les produits pour la livraison uniquement si il y a des produits occasionnels (laisser vide si tous les produits sont récurents).",
"recurrent product is for all shipments, occasional product is for a specific shipment (see shipment form)": "les produits récurrents sont pour toutes les livraisons, les produits occasionnels sont pour une livraison particulière (voir formulaire de création de livraison).",
"some contracts require a minimum value per shipment, ignore this field if it's not the case": "certains contrats nécessitent une valeur minimum par livraison. Ce champ peut être ignoré sil ne sapplique pas à votre contrat.",
"by checking this option the form will be accessible publicly on the home page, only check it if everything is fine with your form": "en cochant cette option le formulaire sera accessible publiquement sur la page d'accueil, cochez cette option uniquement si tout est prêt avec votre formulaire.",
"contracts": "contrats",
"hidden": "caché",
"visible": "visible",
"minimum price for this shipment should be at least": "le prix minimum d'une livraison doit être au moins de",
"there is": "il y a",
"for this contract": "pour ce contrat.",
"remove shipment": "supprimer la livraison",
"productors": "producteur·trices",
"products": "produits",
"templates": "modèles",
"users": "utilisateur·trices",
"forms": "formulaires de contrat",
"form": "formulaire de contrat",
"select a form": "selectionnez un formulaire",
"download contracts": "télécharger les contrats",
"all contracts": "tous les contrats",
"remove contract": "supprimer le contrat",
"download contract": "télécharger le contrat",
"fill contract online": "remplir le contrat en ligne",
"download base template to print": "télécharger le contrat à remplir sur papier",
"by selecting a form here you can download all contracts of your form": "en selectionnant un formulaire, vous téléchargez tous les contrats pour un formulaire donné.",
"edit user": "modifier l'utilisateur·trice",
"remove user": "supprimer l'utilisateur·trice",
"max cheque number": "numbre maximum de cheques possible",
"can be empty default to 3": "optionnel, la valeur par défaut est à 3 cheques",
"all forms": "tous les formulaires de contrat",
"create new form": "créer un nouveau formulaire de contrat",
"actions": "actions", "actions": "actions",
"add all products linked to this productor in the products section": "ajoutez vos produits liés au/à la producteur·trice dans la section \"Produits\".",
"address": "adresse",
"all contracts": "tous les contrats",
"all forms": "tous les formulaires de contrat",
"all productors": "tous les producteur·trices", "all productors": "tous les producteur·trices",
"all products": "tous les produits", "all products": "tous les produits",
"all shipments": "toutes les livraisons",
"all referers": "tous les référent·es", "all referers": "tous les référent·es",
"is required": "est requis·e", "all shipments": "toutes les livraisons",
"a name": "un nom",
"a season": "une saison",
"a start date": "une date de début",
"a end date": "une date de fin",
"a productor": "un(e) producteur·trice",
"a referer": "un(e) référent·e",
"a phone": "un numéro de téléphone",
"a fistname": "un prénom",
"a lastname": "un nom",
"a email": "une adresse email",
"a price or priceKg": "un prix ou un prix au kilo",
"a address": "une adresse",
"a type": "un type",
"a form": "un formulaire de contrat",
"a price": "un prix",
"a priceKg": "un prix au kilo",
"a quantity": "une quantité",
"a product": "un produit",
"a quantity unit": "une unité de quantité",
"a payment method": "une méthode de paiement",
"a sell unit": "une unité de vente",
"sell unit": "unité de vente",
"product": "produit",
"a shipment": "une livraison",
"the products": "les produits",
"the shipments": "les livraisons",
"link to the section": "lien vers la section : {{section}}",
"to add a use the": "pour ajouter {{section}} utilisez le bouton",
"to edit a use the": "pour éditer {{section}} utilisez le bouton",
"to delete a use the": "pour supprimer {{section}} utilisez le bouton",
"button in top right of the page": "en haut à droite de la page {{section}}.",
"button in front of the line you want to edit": "en face de la ligne que vous souhaitez éditer. (dans la colonne actions).",
"button in front of the line you want to delete": "en face de la ligne que vous souhaitez supprimer. (dans la colonne actions).",
"glossary": "glossaire",
"logout": "se déconnecter",
"start to create a productor in the productors section": "commencez par créer un(e) producteur·trice dans la section \"Producteur·trices\".",
"add all products linked to this productor in the products section": "ajoutez vos produits liés au/à la producteur·trice dans la section \"Produits\".",
"create your contract form, it will create a form in the home page (accessible to users)": "créez votre formulaire de contrat dans la section \"Formulaire de contrat\". Ajouter une entrée dans cette section ajoutera un formulaire dans la page d'accueil.",
"export contracts": "Télécharger les contrats",
"download recap": "Télécharger le récapitulatif",
"in this page you can view all contracts submissions, you can remove duplicates submission or download a specific contract": "dans cette page vous pouvez voir tous les contrats, vous pouvez supprimer un contrat en doublon, ou télécharger uniquement un contrat.",
"create shipments for your contract form": "créez les livraisons pour votre contrat",
"creation order": "ordre de création",
"in the same corner you can download a recap by clicking on the button": "au même endroit vous pouvez exporter votre récapitulatif (format odt) à vérifier et transmettre au producteur en cliquant sur le bouton",
"to export contracts submissions before sending to the productor go to the contracts section": "pour exporter les contrats avant de les envoyer aux producteurs allez dans la section \"contrats\".",
"once all contracts downloaded, you can delete the form (to avoid new submissions) and hide it from the home page": "une fois tous les contrats récupérés vous pouvez supprimer le formulaire (pour éviter les nouvelles demandes de contrat et pour cacher le formulaire de la page principale).",
"you can download all contracts for your form using the export all": "vous pouvez télécharger tous les contrats de votre formulaire en utilisant le bouton",
"dashboard is for referers only, with this dashboard you can create productors, products, forms and shipments": "le tableau de bord est visible uniquement pour les référents, vous pouvez créer votre producteur, vos produits, vos formulaires de contrat et vos livraisons.",
"is defined by": "est defini par",
"a product type define the way it will be organized on the final contract form (showed to users) it can be reccurent or occassional. Recurrent products will be set for all shipments if selected by user, Occasional products can be choosen for each shipments": "un type de produit définit la manière dont un produit va être présenté aux amapiens dans le formulaire de contrat. Il peut être récurrent ou occasionnel. Un produit récurrent si selectionné sera compté pour toutes les livraisons. Un produit occasionnel sera facultatif pour chaques livraison (l'amapien devra selectionner la quantité voulue pour chaque livraisons).",
"and/or": "et/ou",
"form name recommandation": "recommandation : Contrat <contract-type> (Exemple : Contrat Porc-Agneau)",
"submit contract": "envoyer le contrat",
"submit": "envoyer",
"example in user forms": "exemple dans le formulaire à destination des amapiens",
"occasional product": "produit occasionnel",
"recurrent product": "produit récurrent",
"with grams as product unit selected": "avec \"grammes\" selectionné pour l'unité de produit",
"product example": "exemple de produit",
"payment methods are defined for a productor. At the end of a form a section payment method let the user select his prefered payment method": "les méthodes de paiement sont définies par producteurs. À la fin du formulaire de contrat l'amapien pourra séléctionner sa méthode de paiement parmis celles que vous avez ajoutés.",
"with cheque and transfer": "avec chèques et virements configuré pour le producteur",
"mililiter": "mililitres (ml)",
"this field is optionnal a product can have a quantity if configured inside the product it will be shown inside the form": "ce champ est optionnel dans la configuration d'un produit, il représente la quantité d'un produit (poids d'une tranche de foie, poids d'un panier, taille d'un bocal...). Si ce champs est renseigné il sera affiché dans le formulaire à destination des amapiens.",
"this field is also optionnal if a product have a quantity you can select the correct unit (metric system). It will be shown next to product quantity inside the form": "ce champs est optionnel dans la configuation d'un produit, il représente l'unité de mesure associée à la quantité d'un produit (g, kg, ml, L). Si ce champs est renseigné il sera affiché dans le formulaire à destination des amapiens à coté de la quantité du produit.",
"with 150 set as quantity and g as quantity unit in product": "avec \"150\" en quantité de produit et \"grammes\" selectionné dans l'unité de quantité du produit",
"all shipments should be recreated for each form creation": "les livraisons étant liées à un formulaire elles doivent être recréés pour chaque nouveau formulaire.", "all shipments should be recreated for each form creation": "les livraisons étant liées à un formulaire elles doivent être recréés pour chaque nouveau formulaire.",
"a productor can be edited if its informations change, it should not be recreated for each contracts": "un(e) producteur·trice peut être édité si ses informations changent, il/elle ne doit pas être recréé pour chaque nouveau contrat.", "all theses informations are for contract generation": "ces informations sont nécessaires pour la génération de contrat.",
"a product can be edited if its informations change, it should not be recreated for each contracts": "un produit peut être édité si ses informations changent, il ne doit pas être recréé pour chaque nouveau formulaire de contrat.", "and/or": "et/ou",
"a new contract form should be created for each new season, do not edit a previous contract and change it's values (for history purpose)": "un formulaire de contrat doit être créé pour chaque nouvelle saison, pour des raison d'historique, n'éditez pas un formulaire de contrat passé pour une nouvelle saison, recréez en un nouveau.", "are you sure you want to delete": "êtes vous sûr de vouloir supprimer",
"grams": "grammes (g)", "button in front of the line you want to delete": "en face de la ligne que vous souhaitez supprimer. (dans la colonne actions).",
"kilo": "kilogrammes (kg)", "button in front of the line you want to edit": "en face de la ligne que vous souhaitez éditer. (dans la colonne actions).",
"liter": "litres (L)", "button in top right of the page": "en haut à droite de la page {{section}}.",
"success": "succès", "by checking this option the form will be accessible publicly on the home page, only check it if everything is fine with your form": "en cochant cette option le formulaire sera accessible publiquement sur la page d'accueil, cochez cette option uniquement si tout est prêt avec votre formulaire.",
"success edit": "{{entity}} correctement édité", "by selecting a form here you can download all contracts of your form": "en selectionnant un formulaire, vous téléchargez tous les contrats pour un formulaire donné.",
"success create": "{{entity}} correctement créé", "can be empty default to 3": "optionnel, la valeur par défaut est à 3 cheques",
"success delete": "{{entity}} correctement supprimé", "cancel": "annuler",
"cheque": "chèque",
"cheque id": "identifiant du chèque",
"cheque quantity": "quantité de chèques (pour le paiement en plusieurs fois)",
"cheque value": "valeur du chèque",
"choose payment method": "choisissez votre méthode de paiement (vous n'avez pas à payer tout de suite, uniquement renseigner comment vous souhaitez régler votre commande).",
"contract": "contrat",
"contract season": "saison du contrat",
"contract season recommandation": "recommandation : <Saison>-<année> (Exemple: Hiver-2025), si un formulaire est déjà créé pour la saison, reprenez son nom de saison si possible.",
"contracts": "contrats",
"create form": "créer un formulaire de contrat",
"create new form": "créer un nouveau formulaire de contrat",
"create product": "créer le produit",
"create productor": "créer le/la producteur·trice",
"create shipment": "créer la livraison",
"create shipments for your contract form": "créez les livraisons pour votre contrat",
"create user": "créer l'utilisateur·trice",
"create your contract form, it will create a form in the home page (accessible to users)": "créez votre formulaire de contrat dans la section \"Formulaire de contrat\". Ajouter une entrée dans cette section ajoutera un formulaire dans la page d'accueil.",
"creation order": "ordre de création",
"dashboard": "tableau de bord",
"dashboard is for referers only, with this dashboard you can create productors, products, forms and shipments": "le tableau de bord est visible uniquement pour les référents, vous pouvez créer votre producteur, vos produits, vos formulaires de contrat et vos livraisons.",
"delete": "supprimer",
"delete entity": "supprimer le/la {{entity}}",
"download base template to print": "télécharger le contrat à remplir sur papier",
"download contract": "télécharger le contrat",
"download contracts": "télécharger les contrats",
"download recap": "Télécharger le récapitulatif",
"edit form": "modifier le formulaire de contrat",
"edit product": "modifier le produit",
"edit productor": "modifier le/la producteur·trice",
"edit shipment": "modifier la livraison",
"edit user": "modifier l'utilisateur·trice",
"end": "fin",
"end date": "date de fin",
"enter cheque quantity": "entrez la quantité de chèques",
"enter cheque value": "entrez la valeur du chèque",
"enter payment method": "sélectionnez votre méthode de paiement",
"enter quantity": "entrez la quantité",
"error": "erreur", "error": "erreur",
"error edit": "erreur pendant l'édition {{entity}}",
"error create": "erreur pendant la création {{entity}}", "error create": "erreur pendant la création {{entity}}",
"error delete": "erreur pendant la suppression {{entity}}", "error delete": "erreur pendant la suppression {{entity}}",
"of the user": "de l'utilisateur·trice", "error edit": "erreur pendant l'édition {{entity}}",
"example in user forms": "exemple dans le formulaire à destination des amapiens",
"export contracts": "Télécharger les contrats",
"fill contract online": "remplir le contrat en ligne",
"filter by form": "filtrer par formulaire",
"filter by name": "filtrer par nom",
"filter by productor": "filtrer par producteur·trice",
"filter by season": "filtrer par saisons",
"filter by type": "filtrer par type",
"for this contract": "pour ce contrat.",
"for transfer method contact your referer or productor": "pour mettre en place le virement automatique, contactez votre référent ou le producteur.",
"form": "formulaire de contrat",
"form name": "nom du formulaire de contrat",
"form name recommandation": "recommandation : Contrat <contract-type> (Exemple : Contrat Porc-Agneau)",
"forms": "formulaires de contrat",
"glossary": "glossaire",
"grams": "grammes (g)",
"help": "aide",
"hidden": "caché",
"home": "accueil",
"how to use dashboard": "comment utiliser le tableau de bord",
"in": "en",
"in the same corner you can download a recap by clicking on the button": "au même endroit vous pouvez exporter votre récapitulatif (format odt) à vérifier et transmettre au producteur en cliquant sur le bouton",
"in this page you can view all contracts submissions, you can remove duplicates submission or download a specific contract": "dans cette page vous pouvez voir tous les contrats, vous pouvez supprimer un contrat en doublon, ou télécharger uniquement un contrat.",
"informations": "informations",
"is defined by": "est defini par",
"is required": "est requis·e",
"kilo": "kilogrammes (kg)",
"link to the section": "lien vers la section : {{section}}",
"liter": "litres (L)",
"login with keycloak": "se connecter avec keycloak",
"logout": "se déconnecter",
"max cheque number": "numbre maximum de cheques possible",
"mililiter": "mililitres (ml)",
"minimum price for this shipment should be at least": "le prix minimum d'une livraison doit être au moins de",
"minimum shipment value": "valeur minimum d'une livraison (€)",
"name": "nom",
"nothing found": "rien à afficher",
"number of cheques between 1 and 3 cheques also enter your cheques identifiers, value is calculated automatically": "nombre de chèques entre 1 et 3, entrez également les identifiants des chèques utilisés.",
"number of shipment": "nombre de livraisons",
"occasional": "occasionnel",
"occasional product": "produit occasionnel",
"occasional products": "produits occasionnels par livraison",
"of the contract": "du contrat",
"of the form": "du formulaire", "of the form": "du formulaire",
"of the product": "du produit", "of the product": "du produit",
"of the productor": "du producteur·trice", "of the productor": "du producteur·trice",
"of the shipment": "de la livraison", "of the shipment": "de la livraison",
"of the contract": "du contrat", "of the user": "de l'utilisateur·trice",
"login with keycloak": "se connecter avec keycloak", "once all contracts downloaded, you can delete the form (to avoid new submissions) and hide it from the home page": "une fois tous les contrats récupérés vous pouvez supprimer le formulaire (pour éviter les nouvelles demandes de contrat et pour cacher le formulaire de la page principale).",
"there is no contract for now": "il n'y a pas de contrats pour le moment.", "order name": "ordre du chèque",
"for transfer method contact your referer or productor": "pour mettre en place le virement automatique, contactez votre référent ou le producteur.",
"cheque quantity": "quantité de chèques (pour le paiement en plusieurs fois)",
"enter cheque quantity": "entrez la quantité de chèques",
"cheque id": "identifiant du chèque",
"cheque value": "valeur du chèque",
"enter cheque value": "entrez la valeur du chèque",
"enter payment method": "sélectionnez votre méthode de paiement",
"number of cheques between 1 and 3 cheques also enter your cheques identifiers, value is calculated automatically": "nombre de chèques entre 1 et 3, entrez également les identifiants des chèques utilisés.",
"payment method": "méthode de paiement", "payment method": "méthode de paiement",
"your session has expired please log in again": "votre session a expiré veuillez vous reconnecter.", "payment methods": "méthodes de paiement",
"session expired": "session expirée", "payment methods are defined for a productor. At the end of a form a section payment method let the user select his prefered payment method": "les méthodes de paiement sont définies par producteurs. À la fin du formulaire de contrat l'amapien pourra séléctionner sa méthode de paiement parmis celles que vous avez ajoutés.",
"user not allowed": "utilisateur non authorisé", "piece": "pièce",
"price": "prix",
"priceKg": "prix au kilo",
"product": "produit",
"product example": "exemple de produit",
"product name": "nom du produit",
"product price": "prix du produit",
"product price kg": "prix du produit au Kilo",
"product quantity": "quantité du produit",
"product quantity unit": "unité de quantité du produit",
"product type": "type de produit",
"product unit": "unité de vente du produit",
"productor": "producteur·trice",
"productor address": "adresse du producteur·trice",
"productor name": "nom du producteur·trice",
"productor payment": "méthodes de paiement du producteur·trice",
"productor type": "type du producteur·trice",
"productors": "producteur·trices",
"products": "produits",
"quantity": "quantité",
"quantity unit": "unité de quantité",
"recurrent": "récurent",
"recurrent product": "produit récurrent",
"recurrent product is for all shipments, occasional product is for a specific shipment (see shipment form)": "les produits récurrents sont pour toutes les livraisons, les produits occasionnels sont pour une livraison particulière (voir formulaire de création de livraison).",
"recurrent products": "produits récurrents",
"referer": "référent·e",
"remove contract": "supprimer le contrat",
"remove form": "supprimer un formulaire de contrat",
"remove product": "supprimer le produit",
"remove productor": "supprimer le/la producteur·trice",
"remove shipment": "supprimer la livraison",
"remove user": "supprimer l'utilisateur·trice",
"roles": "roles", "roles": "roles",
"your keycloak user has no roles, please contact your administrator": "votre utilisateur keycloak n'a pas de roles configurés, contactez votre administrateur.", "season": "saison",
"choose payment method": "choisissez votre méthode de paiement (vous n'avez pas à payer tout de suite, uniquement renseigner comment vous souhaitez régler votre commande).", "select a form": "selectionnez un formulaire",
"select products per shipment": "sélectionnez les produits pour chaque livraison.",
"sell unit": "unité de vente",
"session expired": "session expirée",
"shipment": "livraison",
"shipment date": "date de la livraison",
"shipment form": "formulaire lié a la livraison",
"shipment name": "nom de la livraison",
"shipment products": "produits pour la livraison",
"shipment products is necessary only for occasional products (if all products are recurrent leave empty)": "il est nécessaire de configurer les produits pour la livraison uniquement si il y a des produits occasionnels (laisser vide si tous les produits sont récurents).",
"shipments": "livraisons",
"some contracts require a minimum value per shipment, ignore this field if it's not the case": "certains contrats nécessitent une valeur minimum par livraison. Ce champ peut être ignoré sil ne sapplique pas à votre contrat.",
"start": "début",
"start date": "date de début",
"start to create a productor in the productors section": "commencez par créer un(e) producteur·trice dans la section \"Producteur·trices\".",
"submit": "envoyer",
"submit contract": "envoyer le contrat",
"success": "succès",
"success create": "{{entity}} correctement créé",
"success delete": "{{entity}} correctement supprimé",
"success edit": "{{entity}} correctement édité",
"templates": "modèles",
"the product unit will be assigned to the quantity requested in the form": "l'unité de vente du produit définit l'unité associée à la quantité demandée dans le formulaire des amapiens.", "the product unit will be assigned to the quantity requested in the form": "l'unité de vente du produit définit l'unité associée à la quantité demandée dans le formulaire des amapiens.",
"all theses informations are for contract generation": "ces informations sont nécessaires pour la génération de contrat." "the products": "les produits",
"the shipments": "les livraisons",
"there is": "il y a",
"there is no contract for now": "il n'y a pas de contrats pour le moment.",
"this field is also optionnal if a product have a quantity you can select the correct unit (metric system). It will be shown next to product quantity inside the form": "ce champs est optionnel dans la configuation d'un produit, il représente l'unité de mesure associée à la quantité d'un produit (g, kg, ml, L). Si ce champs est renseigné il sera affiché dans le formulaire à destination des amapiens à coté de la quantité du produit.",
"this field is optionnal a product can have a quantity if configured inside the product it will be shown inside the form": "ce champ est optionnel dans la configuration d'un produit, il représente la quantité d'un produit (poids d'une tranche de foie, poids d'un panier, taille d'un bocal...). Si ce champs est renseigné il sera affiché dans le formulaire à destination des amapiens.",
"this will also delete": "cette action supprimera aussi",
"to add a use the": "pour ajouter {{section}} utilisez le bouton",
"to delete a use the": "pour supprimer {{section}} utilisez le bouton",
"to edit a use the": "pour éditer {{section}} utilisez le bouton",
"to export contracts submissions before sending to the productor go to the contracts section": "pour exporter les contrats avant de les envoyer aux producteurs allez dans la section \"contrats\".",
"total price": "prix total",
"transfer": "virement",
"type": "type",
"unit": "unité de vente",
"user": "utilisateur·trice",
"user not allowed": "utilisateur non authorisé",
"users": "utilisateur·trices",
"visible": "visible",
"with 150 set as quantity and g as quantity unit in product": "avec \"150\" en quantité de produit et \"grammes\" selectionné dans l'unité de quantité du produit",
"with cheque and transfer": "avec chèques et virements configuré pour le producteur",
"with grams as product unit selected": "avec \"grammes\" selectionné pour l'unité de produit",
"you can download all contracts for your form using the export all": "vous pouvez télécharger tous les contrats de votre formulaire en utilisant le bouton",
"your keycloak user has no roles, please contact your administrator": "votre utilisateur keycloak n'a pas de roles configurés, contactez votre administrateur.",
"your selection in this category will apply for all shipments": "votre sélection sera appliquée pour chaque livraisons (Exemple: Pour 6 livraisons, le produits sera compté 6 fois : une fois par livraison).",
"your session has expired please log in again": "votre session a expiré veuillez vous reconnecter."
} }

View File

@@ -2,16 +2,17 @@ import { ActionIcon, Table, Tooltip } from "@mantine/core";
import { type Contract } from "@/services/resources/contracts"; import { type Contract } from "@/services/resources/contracts";
import { IconDownload, IconX } from "@tabler/icons-react"; import { IconDownload, IconX } from "@tabler/icons-react";
import { t } from "@/config/i18n"; import { t } from "@/config/i18n";
import { useDeleteContract, useGetContractFile } from "@/services/api"; import { useGetContractFile } from "@/services/api";
import { useCallback } from "react"; import { useCallback } from "react";
import { useNavigate } from "react-router";
export type ContractRowProps = { export type ContractRowProps = {
contract: Contract; contract: Contract;
}; };
export default function ContractRow({ contract }: ContractRowProps) { export default function ContractRow({ contract }: ContractRowProps) {
const deleteMutation = useDeleteContract();
const getContractMutation = useGetContractFile(); const getContractMutation = useGetContractFile();
const navigate = useNavigate();
const handleDownload = useCallback(async () => { const handleDownload = useCallback(async () => {
getContractMutation.mutateAsync(contract.id); getContractMutation.mutateAsync(contract.id);
@@ -29,12 +30,10 @@ export default function ContractRow({ contract }: ContractRowProps) {
{contract.cheque_quantity > 0 && contract.cheque_quantity} {contract.payment_method} {contract.cheque_quantity > 0 && contract.cheque_quantity} {contract.payment_method}
</Table.Td> </Table.Td>
<Table.Td> <Table.Td>
{ {`${Intl.NumberFormat("fr-FR", {
`${Intl.NumberFormat("fr-FR", {
style: "currency", style: "currency",
currency: "EUR", currency: "EUR",
}).format(contract.total_price)}` }).format(contract.total_price)}`}
}
</Table.Td> </Table.Td>
<Table.Td> <Table.Td>
<Tooltip label={t("download contract", { capfirst: true })}> <Tooltip label={t("download contract", { capfirst: true })}>
@@ -54,8 +53,9 @@ export default function ContractRow({ contract }: ContractRowProps) {
color="red" color="red"
size="sm" size="sm"
mr="5" mr="5"
onClick={() => { onClick={(e) => {
deleteMutation.mutate(contract.id); e.stopPropagation();
navigate(`/dashboard/contracts/${contract.id}/delete`);
}} }}
> >
<IconX /> <IconX />

View File

@@ -0,0 +1,78 @@
import { t } from "@/config/i18n";
import { useGetDeleteDependencies } from "@/services/api";
import { Button, Group, List, Modal, Text, type ModalBaseProps } from "@mantine/core";
import { IconCancel, IconCheck } from "@tabler/icons-react";
import { Link } from "react-router";
export type DeleteModalProps = ModalBaseProps & {
handleSubmit: (id: number) => void;
entityType: string;
entity?: { name: string; id: number } | undefined;
};
export function DeleteModal({
opened,
onClose,
handleSubmit,
entityType,
entity,
}: DeleteModalProps) {
if (!entity) {
return null;
}
const { data: deleteDependencies } = useGetDeleteDependencies(entityType, entity.id);
return (
<Modal
opened={opened}
onClose={onClose}
title={t("delete entity", { capfirst: true, entity: t(entityType) })}
>
<Text>{`${t("are you sure you want to delete", { capfirst: true })} : "${entity.name}"`}</Text>
{deleteDependencies && deleteDependencies.length > 0 ? (
<Text>{`${t("this will also delete", { capfirst: true })} :`}</Text>
) : null}
{
<List>
{deleteDependencies?.map((dependency) => (
<List.Item key={dependency.id}>
{dependency.type === "contract" ? (
`${t(dependency.type, { capfirst: true })} - ${dependency.name}`
) : (
<Link
to={`/dashboard/${dependency.type}s/${dependency.id}/edit`}
target="_blank"
rel="noopener noreferrer"
>
{`${t(dependency.type, { capfirst: true })} - ${dependency.name}`}
</Link>
)}
</List.Item>
))}
</List>
}
<Group mt="sm" justify="space-between">
<Button
variant="filled"
color="red"
aria-label={t("cancel", { capfirst: true })}
leftSection={<IconCancel />}
onClick={onClose}
>
{t("cancel", { capfirst: true })}
</Button>
<Button
variant="filled"
aria-label={t("delete entity", { capfirst: true, entity: t(entityType) })}
leftSection={<IconCheck />}
onClick={() => {
handleSubmit(entity.id);
onClose();
}}
>
{t("delete", { capfirst: true })}
</Button>
</Group>
</Modal>
);
}

View File

@@ -10,26 +10,22 @@ export type FormCardProps = {
}; };
export function FormCard({ form }: FormCardProps) { export function FormCard({ form }: FormCardProps) {
const contractBaseTemplate = useGetContractFileTemplate() const contractBaseTemplate = useGetContractFileTemplate();
return ( return (
<Paper shadow="xl" p="xl" miw={{ base: "100vw", md: "25vw", lg: "20vw" }}> <Paper shadow="xl" p="xl" miw={{ base: "100vw", md: "25vw", lg: "20vw" }}>
<Group justify="start" mb="md"> <Group justify="start" mb="md">
<Tooltip <Tooltip label={t("download base template to print")}>
label={t("download base template to print")}
>
<ActionIcon <ActionIcon
variant={"outline"} variant={"outline"}
aria-label={t("download base template to print")} aria-label={t("download base template to print")}
onClick={async () => { onClick={async () => {
await contractBaseTemplate.mutateAsync(form.id) await contractBaseTemplate.mutateAsync(form.id);
}} }}
> >
<IconDownload /> <IconDownload />
</ActionIcon> </ActionIcon>
</Tooltip> </Tooltip>
<Tooltip <Tooltip label={t("fill contract online")}>
label={t("fill contract online")}
>
<ActionIcon <ActionIcon
variant={"outline"} variant={"outline"}
aria-label={t("fill contract online")} aria-label={t("fill contract online")}

View File

@@ -34,7 +34,7 @@ export default function FormModal({ opened, onClose, currentForm, handleSubmit }
productor_id: currentForm?.productor?.id.toString() ?? "", productor_id: currentForm?.productor?.id.toString() ?? "",
referer_id: currentForm?.referer?.id.toString() ?? "", referer_id: currentForm?.referer?.id.toString() ?? "",
minimum_shipment_value: currentForm?.minimum_shipment_value ?? null, minimum_shipment_value: currentForm?.minimum_shipment_value ?? null,
visible: currentForm?.visible ?? false visible: currentForm?.visible ?? false,
}, },
validate: { validate: {
name: (value) => name: (value) =>
@@ -53,8 +53,7 @@ export default function FormModal({ opened, onClose, currentForm, handleSubmit }
}); });
const usersSelect = useMemo(() => { const usersSelect = useMemo(() => {
if (!users) if (!users) return [];
return [];
return users?.map((user) => ({ return users?.map((user) => ({
value: String(user.id), value: String(user.id),
label: `${user.name}`, label: `${user.name}`,
@@ -62,8 +61,7 @@ export default function FormModal({ opened, onClose, currentForm, handleSubmit }
}, [users]); }, [users]);
const productorsSelect = useMemo(() => { const productorsSelect = useMemo(() => {
if (!productors) if (!productors) return [];
return [];
return productors?.map((prod) => ({ return productors?.map((prod) => ({
value: String(prod.id), value: String(prod.id),
label: `${prod.name}`, label: `${prod.name}`,
@@ -142,9 +140,13 @@ export default function FormModal({ opened, onClose, currentForm, handleSubmit }
radius="sm" radius="sm"
{...form.getInputProps("minimum_shipment_value")} {...form.getInputProps("minimum_shipment_value")}
/> />
<Checkbox mt="lg" <Checkbox
mt="lg"
label={t("visible", { capfirst: true })} label={t("visible", { capfirst: true })}
description={t("by checking this option the form will be accessible publicly on the home page, only check it if everything is fine with your form", {capfirst: true})} description={t(
"by checking this option the form will be accessible publicly on the home page, only check it if everything is fine with your form",
{ capfirst: true },
)}
{...form.getInputProps("visible", { type: "checkbox" })} {...form.getInputProps("visible", { type: "checkbox" })}
/> />
<Group mt="sm" justify="space-between"> <Group mt="sm" justify="space-between">

View File

@@ -1,6 +1,5 @@
import { ActionIcon, Badge, Table, Tooltip } from "@mantine/core"; import { ActionIcon, Badge, Table, Tooltip } from "@mantine/core";
import { useNavigate, useSearchParams } from "react-router"; import { useNavigate, useSearchParams } from "react-router";
import { useDeleteForm } from "@/services/api";
import { IconEdit, IconX } from "@tabler/icons-react"; import { IconEdit, IconX } from "@tabler/icons-react";
import { t } from "@/config/i18n"; import { t } from "@/config/i18n";
import type { Form } from "@/services/resources/forms"; import type { Form } from "@/services/resources/forms";
@@ -11,16 +10,15 @@ export type FormRowProps = {
export default function FormRow({ form }: FormRowProps) { export default function FormRow({ form }: FormRowProps) {
const [searchParams] = useSearchParams(); const [searchParams] = useSearchParams();
const deleteMutation = useDeleteForm();
const navigate = useNavigate(); const navigate = useNavigate();
return ( return (
<Table.Tr key={form.id}> <Table.Tr key={form.id}>
<Table.Td> <Table.Td>
{form.visible ? {form.visible ? (
<Badge color="green">{t("visible", {capfirst: true})}</Badge> : <Badge color="green">{t("visible", { capfirst: true })}</Badge>
) : (
<Badge color="red">{t("hidden", { capfirst: true })}</Badge> <Badge color="red">{t("hidden", { capfirst: true })}</Badge>
} )}
</Table.Td> </Table.Td>
<Table.Td>{form.name}</Table.Td> <Table.Td>{form.name}</Table.Td>
<Table.Td>{form.season}</Table.Td> <Table.Td>{form.season}</Table.Td>
@@ -29,7 +27,7 @@ export default function FormRow({ form }: FormRowProps) {
<Table.Td>{form.productor.name}</Table.Td> <Table.Td>{form.productor.name}</Table.Td>
<Table.Td>{form.referer.name}</Table.Td> <Table.Td>{form.referer.name}</Table.Td>
<Table.Td> <Table.Td>
<Tooltip label={t("edit productor", { capfirst: true })}> <Tooltip label={t("edit form", { capfirst: true })}>
<ActionIcon <ActionIcon
size="sm" size="sm"
mr="5" mr="5"
@@ -43,13 +41,16 @@ export default function FormRow({ form }: FormRowProps) {
<IconEdit /> <IconEdit />
</ActionIcon> </ActionIcon>
</Tooltip> </Tooltip>
<Tooltip label={t("remove productor", { capfirst: true })}> <Tooltip label={t("remove form", { capfirst: true })}>
<ActionIcon <ActionIcon
color="red" color="red"
size="sm" size="sm"
mr="5" mr="5"
onClick={() => { onClick={(e) => {
deleteMutation.mutate(form.id); e.stopPropagation();
navigate(
`/dashboard/forms/${form.id}/delete${searchParams ? `?${searchParams.toString()}` : ""}`,
);
}} }}
> >
<IconX /> <IconX />

View File

@@ -43,7 +43,7 @@ export function ContractCheque({ inputForm, price, productor }: ContractChequePr
}, [inputForm.values.cheque_quantity, price, inputForm.values.cheques]); }, [inputForm.values.cheque_quantity, price, inputForm.values.cheques]);
const paymentMethod = useMemo(() => { const paymentMethod = useMemo(() => {
return productor?.payment_methods.find((el) => el.name === "cheque") return productor?.payment_methods.find((el) => el.name === "cheque");
}, [productor]); }, [productor]);
return ( return (
@@ -57,7 +57,9 @@ export function ContractCheque({ inputForm, price, productor }: ContractChequePr
{ capfirst: true }, { capfirst: true },
)} )}
min={1} min={1}
max={paymentMethod?.max && paymentMethod?.max !== "" ? Number(paymentMethod?.max) : 3} max={
paymentMethod?.max && paymentMethod?.max !== "" ? Number(paymentMethod?.max) : 3
}
{...inputForm.getInputProps(`cheque_quantity`)} {...inputForm.getInputProps(`cheque_quantity`)}
/> />
<Group grow> <Group grow>
@@ -67,11 +69,7 @@ export function ContractCheque({ inputForm, price, productor }: ContractChequePr
label={t("cheque id", { capfirst: true })} label={t("cheque id", { capfirst: true })}
placeholder={t("cheque id", { capfirst: true })} placeholder={t("cheque id", { capfirst: true })}
{...inputForm.getInputProps(`cheques.${index}.name`)} {...inputForm.getInputProps(`cheques.${index}.name`)}
error={ error={cheque.name == "" ? inputForm?.errors.cheques : null}
cheque.name == "" ?
inputForm?.errors.cheques :
null
}
/> />
<NumberInput <NumberInput
readOnly readOnly

View File

@@ -49,20 +49,30 @@ export function ProductorModal({
type: (value) => type: (value) =>
!value ? `${t("type", { capfirst: true })} ${t("is required")}` : null, !value ? `${t("type", { capfirst: true })} ${t("is required")}` : null,
payment_methods: (value) => payment_methods: (value) =>
value.length === 0 || value.some( value.length === 0 ||
(payment) => value.some((payment) => payment.name === "cheque" && payment.details === "")
payment.name === "cheque" && ? `${t("a payment method", { capfirst: true })} ${t("is required")}`
payment.details === "") ? : null,
`${t("a payment method", { capfirst: true })} ${t("is required")}` : null,
}, },
}); });
const roleSelect = useMemo(() => { const roleSelect = useMemo(() => {
return loggedUser?.user?.roles?.map((role) => ({ value: String(role.name), label: role.name })); return loggedUser?.user?.roles?.map((role) => ({
value: String(role.name),
label: role.name,
}));
}, [loggedUser?.user?.roles]); }, [loggedUser?.user?.roles]);
return ( return (
<Modal opened={opened} onClose={onClose} title={t("create productor", { capfirst: true })}> <Modal
opened={opened}
onClose={onClose}
title={
currentProductor
? t("edit productor", { capfirst: true })
: t("create productor", { capfirst: true })
}
>
<Title order={4}>{t("Informations", { capfirst: true })}</Title> <Title order={4}>{t("Informations", { capfirst: true })}</Title>
<TextInput <TextInput
label={t("productor name", { capfirst: true })} label={t("productor name", { capfirst: true })}

View File

@@ -2,7 +2,6 @@ import { ActionIcon, Badge, Table, Tooltip } from "@mantine/core";
import { t } from "@/config/i18n"; import { t } from "@/config/i18n";
import { IconEdit, IconX } from "@tabler/icons-react"; import { IconEdit, IconX } from "@tabler/icons-react";
import type { Productor } from "@/services/resources/productors"; import type { Productor } from "@/services/resources/productors";
import { useDeleteProductor } from "@/services/api";
import { useNavigate, useSearchParams } from "react-router"; import { useNavigate, useSearchParams } from "react-router";
export type ProductorRowProps = { export type ProductorRowProps = {
@@ -11,7 +10,6 @@ export type ProductorRowProps = {
export default function ProductorRow({ productor }: ProductorRowProps) { export default function ProductorRow({ productor }: ProductorRowProps) {
const [searchParams] = useSearchParams(); const [searchParams] = useSearchParams();
const deleteMutation = useDeleteProductor();
const navigate = useNavigate(); const navigate = useNavigate();
return ( return (
@@ -46,8 +44,11 @@ export default function ProductorRow({ productor }: ProductorRowProps) {
color="red" color="red"
size="sm" size="sm"
mr="5" mr="5"
onClick={() => { onClick={(e) => {
deleteMutation.mutate(productor.id); e.stopPropagation();
navigate(
`/dashboard/productors/${productor.id}/delete${searchParams ? `?${searchParams.toString()}` : ""}`,
);
}} }}
> >
<IconX /> <IconX />

View File

@@ -59,8 +59,7 @@ export function ProductModal({ opened, onClose, currentProduct, handleSubmit }:
}); });
const productorsSelect = useMemo(() => { const productorsSelect = useMemo(() => {
if (!productors) if (!productors) return [];
return [];
return productors?.map((productor) => ({ return productors?.map((productor) => ({
value: String(productor.id), value: String(productor.id),
label: `${productor.name}`, label: `${productor.name}`,
@@ -68,7 +67,15 @@ export function ProductModal({ opened, onClose, currentProduct, handleSubmit }:
}, [productors]); }, [productors]);
return ( return (
<Modal opened={opened} onClose={onClose} title={t("create product", { capfirst: true })}> <Modal
opened={opened}
onClose={onClose}
title={
currentProduct
? t("edit product", { capfirst: true })
: t("create product", { capfirst: true })
}
>
<Title order={4}>{t("informations", { capfirst: true })}</Title> <Title order={4}>{t("informations", { capfirst: true })}</Title>
<Select <Select
label={t("productor", { capfirst: true })} label={t("productor", { capfirst: true })}

View File

@@ -2,7 +2,6 @@ import { ActionIcon, Table, Tooltip } from "@mantine/core";
import { t } from "@/config/i18n"; import { t } from "@/config/i18n";
import { IconEdit, IconX } from "@tabler/icons-react"; import { IconEdit, IconX } from "@tabler/icons-react";
import { ProductType, ProductUnit, type Product } from "@/services/resources/products"; import { ProductType, ProductUnit, type Product } from "@/services/resources/products";
import { useDeleteProduct } from "@/services/api";
import { useNavigate, useSearchParams } from "react-router"; import { useNavigate, useSearchParams } from "react-router";
export type ProductRowProps = { export type ProductRowProps = {
@@ -11,7 +10,6 @@ export type ProductRowProps = {
export default function ProductRow({ product }: ProductRowProps) { export default function ProductRow({ product }: ProductRowProps) {
const [searchParams] = useSearchParams(); const [searchParams] = useSearchParams();
const deleteMutation = useDeleteProduct();
const navigate = useNavigate(); const navigate = useNavigate();
return ( return (
@@ -59,8 +57,11 @@ export default function ProductRow({ product }: ProductRowProps) {
color="red" color="red"
size="sm" size="sm"
mr="5" mr="5"
onClick={() => { onClick={(e) => {
deleteMutation.mutate(product.id); e.stopPropagation();
navigate(
`/dashboard/products/${product.id}/delete${searchParams ? `?${searchParams.toString()}` : ""}`,
);
}} }}
> >
<IconX /> <IconX />

View File

@@ -48,8 +48,7 @@ export default function ShipmentModal({
const { data: allProductors } = useGetProductors(); const { data: allProductors } = useGetProductors();
const formsSelect = useMemo(() => { const formsSelect = useMemo(() => {
if (!allForms) if (!allForms) return [];
return [];
return allForms?.map((currentForm) => ({ return allForms?.map((currentForm) => ({
value: String(currentForm.id), value: String(currentForm.id),
label: `${currentForm.name} ${currentForm.season}`, label: `${currentForm.name} ${currentForm.season}`,
@@ -75,7 +74,11 @@ export default function ShipmentModal({
<Modal <Modal
opened={opened} opened={opened}
onClose={onClose} onClose={onClose}
title={currentShipment ? t("edit shipment") : t("create shipment")} title={
currentShipment
? t("edit shipment", { capfirst: true })
: t("create shipment", { capfirst: true })
}
> >
<TextInput <TextInput
label={t("shipment name", { capfirst: true })} label={t("shipment name", { capfirst: true })}

View File

@@ -1,6 +1,5 @@
import { ActionIcon, Table, Tooltip } from "@mantine/core"; import { ActionIcon, Table, Tooltip } from "@mantine/core";
import { useNavigate, useSearchParams } from "react-router"; import { useNavigate, useSearchParams } from "react-router";
import { useDeleteShipment } from "@/services/api";
import { IconEdit, IconX } from "@tabler/icons-react"; import { IconEdit, IconX } from "@tabler/icons-react";
import { t } from "@/config/i18n"; import { t } from "@/config/i18n";
import type { Shipment } from "@/services/resources/shipments"; import type { Shipment } from "@/services/resources/shipments";
@@ -11,7 +10,6 @@ export type ShipmentRowProps = {
export default function ShipmentRow({ shipment }: ShipmentRowProps) { export default function ShipmentRow({ shipment }: ShipmentRowProps) {
const [searchParams] = useSearchParams(); const [searchParams] = useSearchParams();
const deleteMutation = useDeleteShipment();
const navigate = useNavigate(); const navigate = useNavigate();
return ( return (
@@ -20,7 +18,7 @@ export default function ShipmentRow({ shipment }: ShipmentRowProps) {
<Table.Td>{shipment.date}</Table.Td> <Table.Td>{shipment.date}</Table.Td>
<Table.Td>{`${shipment.form.name} ${shipment.form.season}`}</Table.Td> <Table.Td>{`${shipment.form.name} ${shipment.form.season}`}</Table.Td>
<Table.Td> <Table.Td>
<Tooltip label={t("edit productor", { capfirst: true })}> <Tooltip label={t("edit shipment", { capfirst: true })}>
<ActionIcon <ActionIcon
size="sm" size="sm"
mr="5" mr="5"
@@ -34,13 +32,16 @@ export default function ShipmentRow({ shipment }: ShipmentRowProps) {
<IconEdit /> <IconEdit />
</ActionIcon> </ActionIcon>
</Tooltip> </Tooltip>
<Tooltip label={t("remove productor", { capfirst: true })}> <Tooltip label={t("remove shipment", { capfirst: true })}>
<ActionIcon <ActionIcon
color="red" color="red"
size="sm" size="sm"
mr="5" mr="5"
onClick={() => { onClick={(e) => {
deleteMutation.mutate(shipment.id); e.stopPropagation();
navigate(
`/dashboard/shipments/${shipment.id}/delete${searchParams ? `?${searchParams.toString()}` : ""}`,
);
}} }}
> >
<IconX /> <IconX />

View File

@@ -36,13 +36,20 @@ export function UserModal({ opened, onClose, currentUser, handleSubmit }: UserMo
}); });
const roleSelect = useMemo(() => { const roleSelect = useMemo(() => {
if (!allRoles) if (!allRoles) return [];
return [];
return allRoles?.map((role) => ({ value: String(role.name), label: role.name })); return allRoles?.map((role) => ({ value: String(role.name), label: role.name }));
}, [allRoles]); }, [allRoles]);
return ( return (
<Modal opened={opened} onClose={onClose} title={t("create user", { capfirst: true })}> <Modal
opened={opened}
onClose={onClose}
title={
currentUser
? t("edit user", { capfirst: true })
: t("create user", { capfirst: true })
}
>
<Title order={4}>{t("informations", { capfirst: true })}</Title> <Title order={4}>{t("informations", { capfirst: true })}</Title>
<TextInput <TextInput
label={t("user name", { capfirst: true })} label={t("user name", { capfirst: true })}

View File

@@ -2,7 +2,6 @@ import { ActionIcon, Badge, Box, Table, Tooltip } from "@mantine/core";
import { t } from "@/config/i18n"; import { t } from "@/config/i18n";
import { IconEdit, IconX } from "@tabler/icons-react"; import { IconEdit, IconX } from "@tabler/icons-react";
import { type User } from "@/services/resources/users"; import { type User } from "@/services/resources/users";
import { useDeleteUser } from "@/services/api";
import { useNavigate, useSearchParams } from "react-router"; import { useNavigate, useSearchParams } from "react-router";
export type UserRowProps = { export type UserRowProps = {
@@ -11,7 +10,6 @@ export type UserRowProps = {
export default function UserRow({ user }: UserRowProps) { export default function UserRow({ user }: UserRowProps) {
const [searchParams] = useSearchParams(); const [searchParams] = useSearchParams();
const deleteMutation = useDeleteUser();
const navigate = useNavigate(); const navigate = useNavigate();
return ( return (
@@ -21,8 +19,8 @@ export default function UserRow({ user }: UserRowProps) {
<Table.Td style={{ maxWidth: 200 }}> <Table.Td style={{ maxWidth: 200 }}>
<Box <Box
style={{ style={{
display: 'flex', display: "flex",
gap: 4 gap: 4,
}} }}
> >
{user.roles.slice(0, 3).map((value) => ( {user.roles.slice(0, 3).map((value) => (
@@ -30,17 +28,13 @@ export default function UserRow({ user }: UserRowProps) {
{t(value.name, { capfirst: true })} {t(value.name, { capfirst: true })}
</Badge> </Badge>
))} ))}
{ {user.roles.length > 3 && (
user.roles.length > 3 && ( <Tooltip label={user.roles.slice(3).map((role) => `${role.name} `)}>
<Tooltip
label={user.roles.slice(3).map(role=>`${role.name} `)}
>
<Badge size="xs" variant="light"> <Badge size="xs" variant="light">
+{user.roles.length - 3} +{user.roles.length - 3}
</Badge> </Badge>
</Tooltip> </Tooltip>
) )}
}
</Box> </Box>
</Table.Td> </Table.Td>
<Table.Td> <Table.Td>
@@ -63,8 +57,11 @@ export default function UserRow({ user }: UserRowProps) {
color="red" color="red"
size="sm" size="sm"
mr="5" mr="5"
onClick={() => { onClick={(e) => {
deleteMutation.mutate(user.id); e.stopPropagation();
navigate(
`/dashboard/users/${user.id}/delete${searchParams ? `?${searchParams.toString()}` : ""}`,
);
}} }}
> >
<IconX /> <IconX />

View File

@@ -51,7 +51,9 @@ export function Contract() {
payment_method: (value) => payment_method: (value) =>
!value ? `${t("a payment method", { capfirst: true })} ${t("is required")}` : null, !value ? `${t("a payment method", { capfirst: true })} ${t("is required")}` : null,
cheques: (value, values) => cheques: (value, values) =>
values.payment_method === "cheque" && value.some((val) => val.name == "") ? `${t("cheque id", {capfirst: true})} ${t("is required")}` : null, values.payment_method === "cheque" && value.some((val) => val.name == "")
? `${t("cheque id", { capfirst: true })} ${t("is required")}`
: null,
}, },
}); });
@@ -137,12 +139,13 @@ export function Contract() {
const formValues = inputForm.getValues(); const formValues = inputForm.getValues();
const contract = { const contract = {
...formValues, ...formValues,
cheque_quantity: formValues.payment_method === "cheque" ? formValues.cheque_quantity : 0, cheque_quantity:
formValues.payment_method === "cheque" ? formValues.cheque_quantity : 0,
form_id: form.id, form_id: form.id,
products: tranformProducts(withDefaultValues(formValues.products)), products: tranformProducts(withDefaultValues(formValues.products)),
}; };
await createContractMutation.mutateAsync(contract); await createContractMutation.mutateAsync(contract);
window.location.href = '/'; window.location.href = "/";
} else { } else {
const firstErrorField = Object.keys(errors.errors)[0]; const firstErrorField = Object.keys(errors.errors)[0];
const ref = inputRefs.current[firstErrorField]; const ref = inputRefs.current[firstErrorField];
@@ -165,7 +168,7 @@ export function Contract() {
); );
return ( return (
<Stack w={{ base: "100%", md: "80%", lg: "50%" }} p={{base: 'xs'}}> <Stack w={{ base: "100%", md: "80%", lg: "50%" }} p={{ base: "xs" }}>
<Title order={2}>{form.name}</Title> <Title order={2}>{form.name}</Title>
<Title order={3}>{t("informations", { capfirst: true })}</Title> <Title order={3}>{t("informations", { capfirst: true })}</Title>
<Text size="sm"> <Text size="sm">
@@ -289,11 +292,7 @@ export function Contract() {
}} }}
/> />
{inputForm.values.payment_method === "cheque" ? ( {inputForm.values.payment_method === "cheque" ? (
<ContractCheque <ContractCheque productor={form?.productor} price={price} inputForm={inputForm} />
productor={form?.productor}
price={price}
inputForm={inputForm}
/>
) : null} ) : null}
{inputForm.values.payment_method === "transfer" ? ( {inputForm.values.payment_method === "transfer" ? (
<Text> <Text>
@@ -322,7 +321,9 @@ export function Contract() {
</Text> </Text>
<Button <Button
leftSection={<IconDownload />} leftSection={<IconDownload />}
aria-label={t("submit contracts")} onClick={handleSubmit}> aria-label={t("submit contracts")}
onClick={handleSubmit}
>
{t("submit", { capfirst: true })} {t("submit", { capfirst: true })}
</Button> </Button>
</Overlay> </Overlay>

View File

@@ -1,6 +1,12 @@
import { ActionIcon, Group, Loader, ScrollArea, Stack, Table, Title, Tooltip } from "@mantine/core"; import { ActionIcon, Group, Loader, ScrollArea, Stack, Table, Title, Tooltip } from "@mantine/core";
import { t } from "@/config/i18n"; import { t } from "@/config/i18n";
import { useGetAllContractFile, useGetContracts, useGetRecap } from "@/services/api"; import {
useDeleteContract,
useGetAllContractFile,
useGetContract,
useGetContracts,
useGetRecap,
} from "@/services/api";
import { IconDownload, IconTableExport } from "@tabler/icons-react"; import { IconDownload, IconTableExport } from "@tabler/icons-react";
import ContractRow from "@/components/Contracts/Row"; import ContractRow from "@/components/Contracts/Row";
import { useLocation, useNavigate, useSearchParams } from "react-router"; import { useLocation, useNavigate, useSearchParams } from "react-router";
@@ -8,6 +14,7 @@ import { ContractModal } from "@/components/Contracts/Modal";
import { useCallback, useMemo } from "react"; import { useCallback, useMemo } from "react";
import { type Contract } from "@/services/resources/contracts"; import { type Contract } from "@/services/resources/contracts";
import ContractsFilters from "@/components/Contracts/Filter"; import ContractsFilters from "@/components/Contracts/Filter";
import { DeleteModal } from "@/components/DeleteModal";
export default function Contracts() { export default function Contracts() {
const [searchParams, setSearchParams] = useSearchParams(); const [searchParams, setSearchParams] = useSearchParams();
@@ -17,18 +24,29 @@ export default function Contracts() {
const getRecapMutation = useGetRecap(); const getRecapMutation = useGetRecap();
const isdownload = location.pathname.includes("/download"); const isdownload = location.pathname.includes("/download");
const isrecap = location.pathname.includes("/export"); const isrecap = location.pathname.includes("/export");
const isDelete = location.pathname.includes("/delete");
const deleteId = useMemo(() => {
if (isDelete) {
return location.pathname.split("/")[3];
}
return null;
}, [location]);
const closeModal = useCallback(() => { const closeModal = useCallback(() => {
navigate(`/dashboard/contracts${searchParams ? `?${searchParams.toString()}` : ""}`); navigate(`/dashboard/contracts${searchParams ? `?${searchParams.toString()}` : ""}`);
}, [navigate, searchParams]); }, [navigate, searchParams]);
const { data: contracts, isPending } = useGetContracts(searchParams); const { data: contracts, isPending } = useGetContracts(searchParams);
const { data: currentContract } = useGetContract(Number(deleteId), {
enabled: !!deleteId,
});
const { data: allContracts } = useGetContracts(); const { data: allContracts } = useGetContracts();
const deleteContractMutation = useDeleteContract();
const forms = useMemo(() => { const forms = useMemo(() => {
if (!allContracts) if (!allContracts) return [];
return [];
return allContracts return allContracts
?.map((contract: Contract) => contract.form.name) ?.map((contract: Contract) => contract.form.name)
.filter((contract, index, array) => array.indexOf(contract) === index); .filter((contract, index, array) => array.indexOf(contract) === index);
@@ -61,7 +79,7 @@ export default function Contracts() {
await getRecapMutation.mutateAsync(id); await getRecapMutation.mutateAsync(id);
}, },
[getAllContractFilesMutation], [getAllContractFilesMutation],
) );
if (!contracts || isPending) if (!contracts || isPending)
return ( return (
@@ -87,9 +105,7 @@ export default function Contracts() {
<IconDownload /> <IconDownload />
</ActionIcon> </ActionIcon>
</Tooltip> </Tooltip>
<Tooltip <Tooltip label={t("download recap", { capfirst: true })}>
label={t("download recap", { capfirst: true })}
>
<ActionIcon <ActionIcon
disabled={false} disabled={false}
onClick={(e) => { onClick={(e) => {
@@ -114,6 +130,18 @@ export default function Contracts() {
onClose={closeModal} onClose={closeModal}
handleSubmit={handleDownloadRecap} handleSubmit={handleDownloadRecap}
/> />
<DeleteModal
opened={isDelete}
onClose={closeModal}
handleSubmit={(id: number) => {
deleteContractMutation.mutate(id);
}}
entityType={"contract"}
entity={{
name: `${currentContract?.form.name} ${currentContract?.firstname} ${currentContract?.lastname}`,
id: currentContract?.id || 0,
}}
/>
</Group> </Group>
<ContractsFilters <ContractsFilters
forms={forms || []} forms={forms || []}

View File

@@ -16,17 +16,50 @@ export default function Dashboard() {
onChange={(value) => navigate(`/dashboard/${value}`)} onChange={(value) => navigate(`/dashboard/${value}`)}
> >
<Tabs.List mb="md"> <Tabs.List mb="md">
<Tabs.Tab renderRoot={(props) => (<Link to="/dashboard/help" {...props}></Link>)} value="help">{t("help", { capfirst: true })}</Tabs.Tab> <Tabs.Tab
<Tabs.Tab renderRoot={(props) => (<Link to="/dashboard/productors" {...props}></Link>)} value="productors">{t("productors", { capfirst: true })}</Tabs.Tab> renderRoot={(props) => <Link to="/dashboard/help" {...props}></Link>}
<Tabs.Tab renderRoot={(props) => (<Link to="/dashboard/products" {...props}></Link>)} value="products">{t("products", { capfirst: true })}</Tabs.Tab> value="help"
<Tabs.Tab renderRoot={(props) => (<Link to="/dashboard/forms" {...props}></Link>)} value="forms">{t("forms", { capfirst: true })}</Tabs.Tab> >
<Tabs.Tab renderRoot={(props) => (<Link to="/dashboard/shipments" {...props}></Link>)} value="shipments">{t("shipments", { capfirst: true })}</Tabs.Tab> {t("help", { capfirst: true })}
<Tabs.Tab renderRoot={(props) => (<Link to="/dashboard/contracts" {...props}></Link>)} value="contracts">{t("contracts", { capfirst: true })}</Tabs.Tab> </Tabs.Tab>
{ <Tabs.Tab
loggedUser?.user?.roles && loggedUser?.user?.roles?.length > 5 ? renderRoot={(props) => <Link to="/dashboard/productors" {...props}></Link>}
<Tabs.Tab renderRoot={(props) => (<Link to="/dashboard/users" {...props}></Link>)} value="users">{t("users", { capfirst: true })}</Tabs.Tab> : value="productors"
null >
} {t("productors", { capfirst: true })}
</Tabs.Tab>
<Tabs.Tab
renderRoot={(props) => <Link to="/dashboard/products" {...props}></Link>}
value="products"
>
{t("products", { capfirst: true })}
</Tabs.Tab>
<Tabs.Tab
renderRoot={(props) => <Link to="/dashboard/forms" {...props}></Link>}
value="forms"
>
{t("forms", { capfirst: true })}
</Tabs.Tab>
<Tabs.Tab
renderRoot={(props) => <Link to="/dashboard/shipments" {...props}></Link>}
value="shipments"
>
{t("shipments", { capfirst: true })}
</Tabs.Tab>
<Tabs.Tab
renderRoot={(props) => <Link to="/dashboard/contracts" {...props}></Link>}
value="contracts"
>
{t("contracts", { capfirst: true })}
</Tabs.Tab>
{loggedUser?.user?.roles && loggedUser?.user?.roles?.length > 5 ? (
<Tabs.Tab
renderRoot={(props) => <Link to="/dashboard/users" {...props}></Link>}
value="users"
>
{t("users", { capfirst: true })}
</Tabs.Tab>
) : null}
</Tabs.List> </Tabs.List>
<Outlet /> <Outlet />
</Tabs> </Tabs>

View File

@@ -1,5 +1,11 @@
import { Stack, Loader, Title, Group, ActionIcon, Tooltip, Table, ScrollArea } from "@mantine/core"; import { Stack, Loader, Title, Group, ActionIcon, Tooltip, Table, ScrollArea } from "@mantine/core";
import { useCreateForm, useEditForm, useGetForm, useGetReferentForms } from "@/services/api"; import {
useCreateForm,
useDeleteForm,
useEditForm,
useGetForm,
useGetReferentForms,
} from "@/services/api";
import { t } from "@/config/i18n"; import { t } from "@/config/i18n";
import { useLocation, useNavigate, useSearchParams } from "react-router"; import { useLocation, useNavigate, useSearchParams } from "react-router";
import { IconPlus } from "@tabler/icons-react"; import { IconPlus } from "@tabler/icons-react";
@@ -8,6 +14,7 @@ import FormModal from "@/components/Forms/Modal";
import FormRow from "@/components/Forms/Row"; import FormRow from "@/components/Forms/Row";
import type { Form, FormInputs } from "@/services/resources/forms"; import type { Form, FormInputs } from "@/services/resources/forms";
import FilterForms from "@/components/Forms/Filter"; import FilterForms from "@/components/Forms/Filter";
import { DeleteModal } from "@/components/DeleteModal";
export function Forms() { export function Forms() {
const [searchParams, setSearchParams] = useSearchParams(); const [searchParams, setSearchParams] = useSearchParams();
@@ -16,9 +23,10 @@ export function Forms() {
const isCreate = location.pathname === "/dashboard/forms/create"; const isCreate = location.pathname === "/dashboard/forms/create";
const isEdit = location.pathname.includes("/edit"); const isEdit = location.pathname.includes("/edit");
const isDelete = location.pathname.includes("/delete");
const editId = useMemo(() => { const editId = useMemo(() => {
if (isEdit) { if (isEdit || isDelete) {
return location.pathname.split("/")[3]; return location.pathname.split("/")[3];
} }
return null; return null;
@@ -36,12 +44,14 @@ export function Forms() {
const { data: allForms } = useGetReferentForms(); const { data: allForms } = useGetReferentForms();
const seasons = useMemo(() => { const seasons = useMemo(() => {
if (!allForms) return [];
return allForms return allForms
?.map((form: Form) => form.season) ?.map((form: Form) => form.season)
.filter((season, index, array) => array.indexOf(season) === index); .filter((season, index, array) => array.indexOf(season) === index);
}, [allForms]); }, [allForms]);
const productors = useMemo(() => { const productors = useMemo(() => {
if (!allForms) return [];
return allForms return allForms
?.map((form: Form) => form.productor.name) ?.map((form: Form) => form.productor.name)
.filter((productor, index, array) => array.indexOf(productor) === index); .filter((productor, index, array) => array.indexOf(productor) === index);
@@ -49,6 +59,7 @@ export function Forms() {
const createFormMutation = useCreateForm(); const createFormMutation = useCreateForm();
const editFormMutation = useEditForm(); const editFormMutation = useEditForm();
const deleteFormMutation = useDeleteForm();
const handleCreateForm = useCallback( const handleCreateForm = useCallback(
async (form: FormInputs) => { async (form: FormInputs) => {
@@ -144,6 +155,15 @@ export function Forms() {
currentForm={currentForm} currentForm={currentForm}
handleSubmit={handleEditForm} handleSubmit={handleEditForm}
/> />
<DeleteModal
opened={isDelete}
onClose={closeModal}
handleSubmit={(id: number) => {
deleteFormMutation.mutate(id);
}}
entityType={"form"}
entity={currentForm}
/>
<ScrollArea type="auto"> <ScrollArea type="auto">
<Table striped> <Table striped>
<Table.Thead> <Table.Thead>

View File

@@ -245,7 +245,10 @@ export function Help() {
<Title order={3}>{t("export contracts", { capfirst: true })}</Title> <Title order={3}>{t("export contracts", { capfirst: true })}</Title>
<Stack> <Stack>
<Text> <Text>
{t("to export contracts submissions before sending to the productor go to the contracts section", {capfirst: true})} {t(
"to export contracts submissions before sending to the productor go to the contracts section",
{ capfirst: true },
)}
<ActionIcon <ActionIcon
ml="4" ml="4"
size="xs" size="xs"
@@ -260,21 +263,32 @@ export function Help() {
<IconLink /> <IconLink />
</ActionIcon> </ActionIcon>
</Text> </Text>
<Text>{t("in this page you can view all contracts submissions, you can remove duplicates submission or download a specific contract", {capfirst: true})}</Text>
<Text> <Text>
{t("you can download all contracts for your form using the export all", {capfirst: true})}{" "} {t(
"in this page you can view all contracts submissions, you can remove duplicates submission or download a specific contract",
{ capfirst: true },
)}
</Text>
<Text>
{t("you can download all contracts for your form using the export all", {
capfirst: true,
})}{" "}
<ActionIcon size="sm"> <ActionIcon size="sm">
<IconDownload /> <IconDownload />
</ActionIcon>{" "} </ActionIcon>{" "}
{t("button in top right of the page", { section: t("contracts") })}{" "} {t("button in top right of the page", { section: t("contracts") })}{" "}
{t("in the same corner you can download a recap by clicking on the button", {capfirst: true})}{" "} {t("in the same corner you can download a recap by clicking on the button", {
capfirst: true,
})}{" "}
<ActionIcon size="sm"> <ActionIcon size="sm">
<IconTableExport /> <IconTableExport />
</ActionIcon>{" "} </ActionIcon>{" "}
</Text> </Text>
<Text> <Text>
{t("once all contracts downloaded, you can delete the form (to avoid new submissions) and hide it from the home page", {capfirst: true})} {t(
"once all contracts downloaded, you can delete the form (to avoid new submissions) and hide it from the home page",
{ capfirst: true },
)}
</Text> </Text>
</Stack> </Stack>
<Title order={3}>{t("glossary", { capfirst: true })}</Title> <Title order={3}>{t("glossary", { capfirst: true })}</Title>

View File

@@ -23,12 +23,14 @@ export function Home() {
if (searchParams.get("userNotAllowed")) { if (searchParams.get("userNotAllowed")) {
showNotification({ showNotification({
title: t("user not allowed", { capfirst: true }), title: t("user not allowed", { capfirst: true }),
message: t("your keycloak user has no roles, please contact your administrator", {capfirst: true}), message: t("your keycloak user has no roles, please contact your administrator", {
capfirst: true,
}),
color: "red", color: "red",
autoClose: 5000, autoClose: 5000,
}); });
} }
}, [searchParams]) }, [searchParams]);
return ( return (
<Stack mt="lg"> <Stack mt="lg">

View File

@@ -2,6 +2,7 @@ import { ActionIcon, Group, Loader, ScrollArea, Stack, Table, Title, Tooltip } f
import { t } from "@/config/i18n"; import { t } from "@/config/i18n";
import { import {
useCreateProductor, useCreateProductor,
useDeleteProductor,
useEditProductor, useEditProductor,
useGetProductor, useGetProductor,
useGetProductors, useGetProductors,
@@ -13,6 +14,7 @@ import { ProductorModal } from "@/components/Productors/Modal";
import { useCallback, useMemo } from "react"; import { useCallback, useMemo } from "react";
import type { Productor, ProductorInputs } from "@/services/resources/productors"; import type { Productor, ProductorInputs } from "@/services/resources/productors";
import ProductorsFilters from "@/components/Productors/Filter"; import ProductorsFilters from "@/components/Productors/Filter";
import { DeleteModal } from "@/components/DeleteModal";
export default function Productors() { export default function Productors() {
const [searchParams, setSearchParams] = useSearchParams(); const [searchParams, setSearchParams] = useSearchParams();
@@ -23,9 +25,10 @@ export default function Productors() {
const { data: allProductors } = useGetProductors(); const { data: allProductors } = useGetProductors();
const isCreate = location.pathname === "/dashboard/productors/create"; const isCreate = location.pathname === "/dashboard/productors/create";
const isEdit = location.pathname.includes("/edit"); const isEdit = location.pathname.includes("/edit");
const isDelete = location.pathname.includes("/delete");
const editId = useMemo(() => { const editId = useMemo(() => {
if (isEdit) { if (isEdit || isDelete) {
return location.pathname.split("/")[3]; return location.pathname.split("/")[3];
} }
return null; return null;
@@ -40,16 +43,14 @@ export default function Productors() {
}, [navigate, searchParams]); }, [navigate, searchParams]);
const names = useMemo(() => { const names = useMemo(() => {
if (!allProductors) if (!allProductors) return [];
return [];
return allProductors return allProductors
?.map((productor: Productor) => productor.name) ?.map((productor: Productor) => productor.name)
.filter((season, index, array) => array.indexOf(season) === index); .filter((season, index, array) => array.indexOf(season) === index);
}, [allProductors]); }, [allProductors]);
const types = useMemo(() => { const types = useMemo(() => {
if (!allProductors) if (!allProductors) return [];
return [];
return allProductors return allProductors
?.map((productor: Productor) => productor.type) ?.map((productor: Productor) => productor.type)
.filter((productor, index, array) => array.indexOf(productor) === index); .filter((productor, index, array) => array.indexOf(productor) === index);
@@ -57,6 +58,7 @@ export default function Productors() {
const createProductorMutation = useCreateProductor(); const createProductorMutation = useCreateProductor();
const editProductorMutation = useEditProductor(); const editProductorMutation = useEditProductor();
const deleteProductorMutation = useDeleteProductor();
const handleCreateProductor = useCallback( const handleCreateProductor = useCallback(
async (productor: ProductorInputs) => { async (productor: ProductorInputs) => {
@@ -65,8 +67,8 @@ export default function Productors() {
payment_methods: productor.payment_methods.map((payment) => ({ payment_methods: productor.payment_methods.map((payment) => ({
name: payment.name, name: payment.name,
details: payment.details, details: payment.details,
max: payment.max === "" ? null : payment.max max: payment.max === "" ? null : payment.max,
})) })),
}); });
closeModal(); closeModal();
}, },
@@ -83,8 +85,8 @@ export default function Productors() {
payment_methods: productor.payment_methods.map((payment) => ({ payment_methods: productor.payment_methods.map((payment) => ({
name: payment.name, name: payment.name,
details: payment.details, details: payment.details,
max: payment.max === "" ? null : payment.max max: payment.max === "" ? null : payment.max,
})) })),
}, },
}); });
closeModal(); closeModal();
@@ -143,6 +145,15 @@ export default function Productors() {
currentProductor={currentProductor} currentProductor={currentProductor}
handleSubmit={handleEditProductor} handleSubmit={handleEditProductor}
/> />
<DeleteModal
opened={isDelete}
onClose={closeModal}
handleSubmit={(id: number) => {
deleteProductorMutation.mutate(id);
}}
entityType={"productor"}
entity={currentProductor}
/>
</Group> </Group>
<ProductorsFilters <ProductorsFilters
names={names || []} names={names || []}

View File

@@ -1,6 +1,12 @@
import { ActionIcon, Group, Loader, ScrollArea, Stack, Table, Title, Tooltip } from "@mantine/core"; import { ActionIcon, Group, Loader, ScrollArea, Stack, Table, Title, Tooltip } from "@mantine/core";
import { t } from "@/config/i18n"; import { t } from "@/config/i18n";
import { useCreateProduct, useEditProduct, useGetProduct, useGetProducts } from "@/services/api"; import {
useCreateProduct,
useDeleteProduct,
useEditProduct,
useGetProduct,
useGetProducts,
} from "@/services/api";
import { IconPlus } from "@tabler/icons-react"; import { IconPlus } from "@tabler/icons-react";
import ProductRow from "@/components/Products/Row"; import ProductRow from "@/components/Products/Row";
import { useLocation, useNavigate, useSearchParams } from "react-router"; import { useLocation, useNavigate, useSearchParams } from "react-router";
@@ -12,6 +18,7 @@ import {
type ProductInputs, type ProductInputs,
} from "@/services/resources/products"; } from "@/services/resources/products";
import ProductsFilters from "@/components/Products/Filter"; import ProductsFilters from "@/components/Products/Filter";
import { DeleteModal } from "@/components/DeleteModal";
export default function Products() { export default function Products() {
const [searchParams, setSearchParams] = useSearchParams(); const [searchParams, setSearchParams] = useSearchParams();
@@ -19,9 +26,10 @@ export default function Products() {
const navigate = useNavigate(); const navigate = useNavigate();
const isCreate = location.pathname === "/dashboard/products/create"; const isCreate = location.pathname === "/dashboard/products/create";
const isEdit = location.pathname.includes("/edit"); const isEdit = location.pathname.includes("/edit");
const isDelete = location.pathname.includes("/delete");
const editId = useMemo(() => { const editId = useMemo(() => {
if (isEdit) { if (isEdit || isDelete) {
return location.pathname.split("/")[3]; return location.pathname.split("/")[3];
} }
return null; return null;
@@ -38,16 +46,14 @@ export default function Products() {
const { data: allProducts } = useGetProducts(); const { data: allProducts } = useGetProducts();
const names = useMemo(() => { const names = useMemo(() => {
if (!allProducts) if (!allProducts) return [];
return [];
return allProducts return allProducts
?.map((product: Product) => product.name) ?.map((product: Product) => product.name)
.filter((season, index, array) => array.indexOf(season) === index); .filter((season, index, array) => array.indexOf(season) === index);
}, [allProducts]); }, [allProducts]);
const productors = useMemo(() => { const productors = useMemo(() => {
if (!allProducts) if (!allProducts) return [];
return [];
return allProducts return allProducts
?.map((product: Product) => product.productor.name) ?.map((product: Product) => product.productor.name)
.filter((productor, index, array) => array.indexOf(productor) === index); .filter((productor, index, array) => array.indexOf(productor) === index);
@@ -55,6 +61,7 @@ export default function Products() {
const createProductMutation = useCreateProduct(); const createProductMutation = useCreateProduct();
const editProductMutation = useEditProduct(); const editProductMutation = useEditProduct();
const deleteProductMutation = useDeleteProduct();
const handleCreateProduct = useCallback( const handleCreateProduct = useCallback(
async (product: ProductInputs) => { async (product: ProductInputs) => {
@@ -134,6 +141,15 @@ export default function Products() {
currentProduct={currentProduct} currentProduct={currentProduct}
handleSubmit={handleEditProduct} handleSubmit={handleEditProduct}
/> />
<DeleteModal
opened={isDelete}
onClose={closeModal}
handleSubmit={(id: number) => {
deleteProductMutation.mutate(id);
}}
entityType={"product"}
entity={currentProduct}
/>
<ScrollArea type="auto"> <ScrollArea type="auto">
<Table striped> <Table striped>
<Table.Thead> <Table.Thead>

View File

@@ -2,6 +2,7 @@ import { ActionIcon, Group, Loader, ScrollArea, Stack, Table, Title, Tooltip } f
import { t } from "@/config/i18n"; import { t } from "@/config/i18n";
import { import {
useCreateShipment, useCreateShipment,
useDeleteShipment,
useEditShipment, useEditShipment,
useGetShipment, useGetShipment,
useGetShipments, useGetShipments,
@@ -17,6 +18,7 @@ import {
} from "@/services/resources/shipments"; } from "@/services/resources/shipments";
import ShipmentModal from "@/components/Shipments/Modal"; import ShipmentModal from "@/components/Shipments/Modal";
import ShipmentsFilters from "@/components/Shipments/Filter"; import ShipmentsFilters from "@/components/Shipments/Filter";
import { DeleteModal } from "@/components/DeleteModal";
export default function Shipments() { export default function Shipments() {
const [searchParams, setSearchParams] = useSearchParams(); const [searchParams, setSearchParams] = useSearchParams();
@@ -25,9 +27,10 @@ export default function Shipments() {
const isCreate = location.pathname === "/dashboard/shipments/create"; const isCreate = location.pathname === "/dashboard/shipments/create";
const isEdit = location.pathname.includes("/edit"); const isEdit = location.pathname.includes("/edit");
const isDelete = location.pathname.includes("/delete");
const editId = useMemo(() => { const editId = useMemo(() => {
if (isEdit) { if (isEdit || isDelete) {
return location.pathname.split("/")[3]; return location.pathname.split("/")[3];
} }
return null; return null;
@@ -44,16 +47,14 @@ export default function Shipments() {
const { data: allShipments } = useGetShipments(); const { data: allShipments } = useGetShipments();
const names = useMemo(() => { const names = useMemo(() => {
if (!allShipments) if (!allShipments) return [];
return [];
return allShipments return allShipments
?.map((shipment: Shipment) => shipment.name) ?.map((shipment: Shipment) => shipment.name)
.filter((season, index, array) => array.indexOf(season) === index); .filter((season, index, array) => array.indexOf(season) === index);
}, [allShipments]); }, [allShipments]);
const forms = useMemo(() => { const forms = useMemo(() => {
if (!allShipments) if (!allShipments) return [];
return [];
return allShipments return allShipments
?.map((shipment: Shipment) => shipment.form.name) ?.map((shipment: Shipment) => shipment.form.name)
.filter((season, index, array) => array.indexOf(season) === index); .filter((season, index, array) => array.indexOf(season) === index);
@@ -61,6 +62,7 @@ export default function Shipments() {
const createShipmentMutation = useCreateShipment(); const createShipmentMutation = useCreateShipment();
const editShipmentMutation = useEditShipment(); const editShipmentMutation = useEditShipment();
const deleteShipmentMutation = useDeleteShipment();
const handleCreateShipment = useCallback( const handleCreateShipment = useCallback(
async (shipment: ShipmentInputs) => { async (shipment: ShipmentInputs) => {
@@ -133,6 +135,15 @@ export default function Shipments() {
currentShipment={currentShipment} currentShipment={currentShipment}
handleSubmit={handleEditShipment} handleSubmit={handleEditShipment}
/> />
<DeleteModal
opened={isDelete}
onClose={closeModal}
handleSubmit={(id: number) => {
deleteShipmentMutation.mutate(id);
}}
entityType={"shipment"}
entity={currentShipment}
/>
</Group> </Group>
<ShipmentsFilters <ShipmentsFilters
forms={forms || []} forms={forms || []}
@@ -151,7 +162,7 @@ export default function Shipments() {
</Table.Tr> </Table.Tr>
</Table.Thead> </Table.Thead>
<Table.Tbody> <Table.Tbody>
{shipments.map((shipment) => ( {shipments?.map((shipment) => (
<ShipmentRow shipment={shipment} key={shipment.id} /> <ShipmentRow shipment={shipment} key={shipment.id} />
))} ))}
</Table.Tbody> </Table.Tbody>

View File

@@ -1,6 +1,6 @@
import { ActionIcon, Group, Loader, ScrollArea, Stack, Table, Title, Tooltip } from "@mantine/core"; import { ActionIcon, Group, Loader, ScrollArea, Stack, Table, Title, Tooltip } from "@mantine/core";
import { t } from "@/config/i18n"; import { t } from "@/config/i18n";
import { useCreateUser, useEditUser, useGetUser, useGetUsers } from "@/services/api"; import { useCreateUser, useDeleteUser, useEditUser, useGetUser, useGetUsers } from "@/services/api";
import { IconPlus } from "@tabler/icons-react"; import { IconPlus } from "@tabler/icons-react";
import UserRow from "@/components/Users/Row"; import UserRow from "@/components/Users/Row";
import { useLocation, useNavigate, useSearchParams } from "react-router"; import { useLocation, useNavigate, useSearchParams } from "react-router";
@@ -8,6 +8,7 @@ import { UserModal } from "@/components/Users/Modal";
import { useCallback, useMemo } from "react"; import { useCallback, useMemo } from "react";
import { type User, type UserInputs } from "@/services/resources/users"; import { type User, type UserInputs } from "@/services/resources/users";
import UsersFilters from "@/components/Users/Filter"; import UsersFilters from "@/components/Users/Filter";
import { DeleteModal } from "@/components/DeleteModal";
export default function Users() { export default function Users() {
const [searchParams, setSearchParams] = useSearchParams(); const [searchParams, setSearchParams] = useSearchParams();
@@ -16,9 +17,10 @@ export default function Users() {
const isCreate = location.pathname === "/dashboard/users/create"; const isCreate = location.pathname === "/dashboard/users/create";
const isEdit = location.pathname.includes("/edit"); const isEdit = location.pathname.includes("/edit");
const isDelete = location.pathname.includes("/delete");
const editId = useMemo(() => { const editId = useMemo(() => {
if (isEdit) { if (isEdit || isDelete) {
return location.pathname.split("/")[3]; return location.pathname.split("/")[3];
} }
return null; return null;
@@ -36,8 +38,7 @@ export default function Users() {
const { data: allUsers } = useGetUsers(); const { data: allUsers } = useGetUsers();
const names = useMemo(() => { const names = useMemo(() => {
if (!allUsers) if (!allUsers) return [];
return [];
return allUsers return allUsers
?.map((user: User) => user.name) ?.map((user: User) => user.name)
.filter((season, index, array) => array.indexOf(season) === index); .filter((season, index, array) => array.indexOf(season) === index);
@@ -45,6 +46,7 @@ export default function Users() {
const createUserMutation = useCreateUser(); const createUserMutation = useCreateUser();
const editUserMutation = useEditUser(); const editUserMutation = useEditUser();
const deleteUserMutation = useDeleteUser();
const handleCreateUser = useCallback( const handleCreateUser = useCallback(
async (user: UserInputs) => { async (user: UserInputs) => {
@@ -117,6 +119,15 @@ export default function Users() {
currentUser={currentUser} currentUser={currentUser}
handleSubmit={handleEditUser} handleSubmit={handleEditUser}
/> />
<DeleteModal
opened={isDelete}
onClose={closeModal}
handleSubmit={(id: number) => {
deleteUserMutation.mutate(id);
}}
entityType={"user"}
entity={currentUser}
/>
</Group> </Group>
<UsersFilters <UsersFilters
names={names || []} names={names || []}

View File

@@ -34,20 +34,26 @@ export const router = createBrowserRouter([
{ path: "productors", Component: Productors }, { path: "productors", Component: Productors },
{ path: "productors/create", Component: Productors }, { path: "productors/create", Component: Productors },
{ path: "productors/:id/edit", Component: Productors }, { path: "productors/:id/edit", Component: Productors },
{ path: "productors/:id/delete", Component: Productors },
{ path: "products", Component: Products }, { path: "products", Component: Products },
{ path: "products/create", Component: Products }, { path: "products/create", Component: Products },
{ path: "products/:id/edit", Component: Products }, { path: "products/:id/edit", Component: Products },
{ path: "products/:id/delete", Component: Products },
{ path: "contracts", Component: Contracts }, { path: "contracts", Component: Contracts },
{ path: "contracts/download", Component: Contracts }, { path: "contracts/download", Component: Contracts },
{ path: "contracts/export", Component: Contracts }, { path: "contracts/export", Component: Contracts },
{ path: "contracts/:id/delete", Component: Contracts },
{ path: "users", Component: Users }, { path: "users", Component: Users },
{ path: "users/create", Component: Users }, { path: "users/create", Component: Users },
{ path: "users/:id/edit", Component: Users }, { path: "users/:id/edit", Component: Users },
{ path: "users/:id/delete", Component: Users },
{ path: "forms", Component: Forms }, { path: "forms", Component: Forms },
{ path: "forms/:id/edit", Component: Forms }, { path: "forms/:id/edit", Component: Forms },
{ path: "forms/:id/delete", Component: Forms },
{ path: "forms/create", Component: Forms }, { path: "forms/create", Component: Forms },
{ path: "shipments", Component: Shipments }, { path: "shipments", Component: Shipments },
{ path: "shipments/:id/edit", Component: Shipments }, { path: "shipments/:id/edit", Component: Shipments },
{ path: "shipments/:id/delete", Component: Shipments },
{ path: "shipments/create", Component: Shipments }, { path: "shipments/create", Component: Shipments },
], ],
}, },

View File

@@ -24,6 +24,7 @@ import type { Product, ProductCreate, ProductEditPayload } from "./resources/pro
import type { Contract, ContractCreate } from "./resources/contracts"; import type { Contract, ContractCreate } from "./resources/contracts";
import { notifications } from "@mantine/notifications"; import { notifications } from "@mantine/notifications";
import { t } from "@/config/i18n"; import { t } from "@/config/i18n";
import type { DeleteDependencies, EntityName } from "./resources/common";
export async function refreshToken() { export async function refreshToken() {
return await fetch(`${Config.backend_uri}/auth/refresh`, {method: "POST", credentials: "include"}); return await fetch(`${Config.backend_uri}/auth/refresh`, {method: "POST", credentials: "include"});
@@ -37,7 +38,7 @@ export async function fetchWithAuth(input: RequestInfo, options?: RequestInit, r
if (res.status === 401) { if (res.status === 401) {
const refresh = await refreshToken(); const refresh = await refreshToken();
if (refresh.status == 400 || refresh.status == 401) { if (refresh.status !== 200) {
if (redirect) if (redirect)
window.location.href = `/?sessionExpired=True`; window.location.href = `/?sessionExpired=True`;
@@ -49,6 +50,13 @@ export async function fetchWithAuth(input: RequestInfo, options?: RequestInit, r
credentials: "include", credentials: "include",
...options, ...options,
}); });
if (newRes.status === 401 || newRes.status === 403) {
if (redirect)
window.location.href = `/?sessionExpired=True`;
const error = new Error("Unauthorized");
error.cause = 401
throw error;
}
return newRes; return newRes;
} }
if (res.status == 403) { if (res.status == 403) {
@@ -321,6 +329,24 @@ export function useGetForm(
}); });
} }
export function useGetDeleteDependencies(
entity: EntityName,
id?: number,
) {
return useQuery<DeleteDependencies[]>({
queryKey: [`${entity}_delete_preview_${id}`],
queryFn: () =>
fetchWithAuth(`${Config.backend_uri}/${entity}s/${id}/preview-delete`, {
credentials: "include",
}).then((res) => {
const result = res.json()
return result
}),
enabled: !!id,
});
}
export function useGetForms(filters?: URLSearchParams): UseQueryResult<Form[], Error> { export function useGetForms(filters?: URLSearchParams): UseQueryResult<Form[], Error> {
const queryString = filters?.toString(); const queryString = filters?.toString();
return useQuery<Form[]>({ return useQuery<Form[]>({

View File

@@ -5,9 +5,9 @@ import type { UserLogged } from "../resources/users";
export type Auth = { export type Auth = {
loggedUser: UserLogged | null; loggedUser: UserLogged | null;
isLoading: boolean; isLoading: boolean;
} };
const AuthContext = createContext<Auth | undefined>(undefined) const AuthContext = createContext<Auth | undefined>(undefined);
export function AuthProvider({ children }: { children: React.ReactNode }) { export function AuthProvider({ children }: { children: React.ReactNode }) {
const { data: loggedUser, isLoading } = useCurrentUser(); const { data: loggedUser, isLoading } = useCurrentUser();
@@ -17,11 +17,7 @@ export function AuthProvider({ children }: {children: React.ReactNode}) {
isLoading, isLoading,
}; };
return ( return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
<AuthContext.Provider value={value}>
{children}
</AuthContext.Provider>
)
} }
export function useAuth(): Auth { export function useAuth(): Auth {

View File

@@ -0,0 +1,16 @@
export const ENTITY_NAMES = [
'contract',
'form',
'productor',
'product',
'shipment',
'user',
]
export type EntityName = (typeof ENTITY_NAMES)[number];
export type DeleteDependencies = {
name: string;
id: number;
type: EntityName;
}