Skip to content

Commit

Permalink
1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilSpartans committed Jan 5, 2024
1 parent e1248da commit 7cee281
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jobibox",
"version": "1.0.1",
"version": "1.0.2",
"description": "La cabine accoustique pour créer un cv vidéo",
"repository": "https://github.com/EvilSpartans/JobiBox",
"main": "main.js",
Expand Down
15 changes: 12 additions & 3 deletions src/components/forms/PostForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function PostForm() {
const [startDate, setStartDate] = useState(null);
const BASE_URL = "https://test.jobissim.com";
const businessId = localStorage.getItem('businessId') | null;
const showPortalCheckbox = businessId !== null && businessId !== 0;

const handleSelectContracts = (selectedValues) => {
setContracts(selectedValues);
Expand Down Expand Up @@ -190,13 +191,13 @@ export default function PostForm() {
contracts: selectedContracts,
video: selectedVideo,
image: selectedImage,
businessId
businessId,
portal: data.portal
};

try {
const res = await dispatch(createPost(postData));
console.log(res);

// console.log(res);
if (res?.payload?.title) {
navigate("/thanks");
sendConfirmNotification();
Expand Down Expand Up @@ -277,6 +278,14 @@ export default function PostForm() {
error={errors?.category?.message}
options={categoryOptions}
/>
{showPortalCheckbox && (
<Checkbox
name="portal"
label="Portail"
register={register}
error={errors?.portal?.message}
/>
)}
<Input
name="city"
type="text"
Expand Down
2 changes: 1 addition & 1 deletion src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ select, input, textarea {
animation: blink 1.5s infinite;
}

label[for=terms]
label[for=terms], label[for=portal]
{
margin-right: 2%;
}
21 changes: 19 additions & 2 deletions src/screens/Home.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from "react";
import React, { useEffect, useCallback } from "react";
import { useNavigate } from "react-router-dom";
import { useSelector } from "react-redux";
import Logout from "../components/Logout";
Expand All @@ -7,9 +7,26 @@ export default function Home() {

const navigate = useNavigate();
const user = useSelector((state) => state.user.user);
const existingBusiness = localStorage.getItem("businessId");

// Hidden cmd to reset config
const handleKeyDown = useCallback((e) => {
if (e.ctrlKey && e.altKey && e.key.toLowerCase() === "b") {
localStorage.removeItem("businessId");
alert("Configuration réinitialisée");
navigate("/config");
}
}, []);

useEffect(() => {
window.addEventListener("keydown", handleKeyDown);
return () => {
window.removeEventListener("keydown", handleKeyDown);
};
}, [handleKeyDown]);
// ----------------------------

useEffect(() => {
const existingBusiness = localStorage.getItem("businessId");
if (!existingBusiness) {
navigate("/config");
}
Expand Down
4 changes: 3 additions & 1 deletion src/store/features/postSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const createPost = createAsyncThunk(
video,
image,
date,
businessId
businessId,
portal
// cpf,
// compagny
} = values;
Expand All @@ -51,6 +52,7 @@ export const createPost = createAsyncThunk(
formData.append("video", video);
formData.append("date", date);
formData.append("businessId", businessId);
formData.append("portal", portal);
// formData.append("cpf", cpf);
// formData.append("compagny", compagny);

Expand Down
17 changes: 13 additions & 4 deletions src/utils/Validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,19 @@ export const signInSchema = Yup.object({
password: Yup.string().required("Le mot de passe est requis"),
});

export const PostSchema = Yup.object({
export const PostSchema = Yup.object().shape({
title: Yup.string().required("Le titre est requis."),
category: Yup.string().required("La catégorie est requise."),
subCategory: Yup.string().required("La classification est requise."),
subCategory: Yup.string().when("portal", {
is: (portal) => !portal,
then: () => Yup.string().required("La classification est requise."),
otherwise: () => Yup.string().notRequired(),
}),
portal: Yup.boolean().when("subCategory", {
is: (subCategory) => !subCategory,
then: () => Yup.boolean().oneOf([true], "Tu dois choisir une classification ou un portail."),
otherwise: () => Yup.boolean().notRequired(),
}),
description: Yup.string(),
city: Yup.string(),
salary: Yup.string().matches(/^[0-9, ]*$/, "Ce champ doit contenir uniquement des chiffres et des virgules."),
Expand All @@ -54,8 +63,8 @@ export const PostSchema = Yup.object({
cpf: Yup.boolean(),
compagny: Yup.string(),
formation: Yup.string(),
businessId: Yup.boolean(),
});
businessId: Yup.boolean()
}, ['subCategory', 'portal']);

export const portalSchema = Yup.object({
business: Yup.string().required("Le portail est requis."),
Expand Down

0 comments on commit 7cee281

Please sign in to comment.