Skip to content

Commit

Permalink
Merge master (#390)
Browse files Browse the repository at this point in the history
* Feat/delete image (#389)

* fix: image put true if already true

* feat: delete button + deleteImage function

* feat: add delete button and function

* todo

* feat: checkbox to delete image works

* feat: argg

---------

Co-authored-by: Antoine D <[email protected]>

* fix: image preview no longer in itemModal

* fix: lol username "with #"

* change image upload text color

* fix: delete img (normaly it works)

* fix: Change the environment variable

* fix: image input fix color

---------

Co-authored-by: Antoine D <[email protected]>
  • Loading branch information
Suboyyy and Antoine D authored Sep 27, 2024
1 parent cb89e6b commit c53c54a
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/app/(dashboard)/dashboard/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ const Account = () => {
<Input label="Email" value={user.email} autocomplete="off" disabled />
<Input label="Prénom" value={firstname} onChange={setFirstname} autocomplete="off" disabled />
<Input label="Nom" value={lastname} onChange={setLastname} autocomplete="off" disabled />
<Input label="Pseudo (Nom d'invocateur pour LoL)" value={username} onChange={setUsername} autocomplete="off" />
<Input
label="Pseudo (Nom d'invocateur pour LoL avec #)"
value={username}
onChange={setUsername}
autocomplete="off"
/>
<Input
label="Nouveau mot de passe"
value={password}
Expand Down
2 changes: 1 addition & 1 deletion src/app/robots.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MetadataRoute } from 'next';

export default function robots(): MetadataRoute.Robots {
if (process.env.NODE_ENV === 'production') {
if (process.env.ENVIRONMENT === 'production') {
return {
rules: {
userAgent: '*',
Expand Down
5 changes: 4 additions & 1 deletion src/components/UI/FileInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import { ChangeEvent, useRef, useState } from 'react';
* Renders a component that allows the user to upload a file.
*/
const FileUpload = ({
textColor = 'white',
label,
value = '',
onChange,
type,
className = '',
bg = 'white',
}: {
/** The text color when there no image has been uploaded */
textColor?: string;
/** The label to display. */
label: string;
/** The value of the file. */
Expand Down Expand Up @@ -77,7 +80,7 @@ const FileUpload = ({
</>
)}

<p className={error || (value === '' && preview === null) ? 'black' : ''}>
<p style={{ color: textColor }} className={error || (value === '' && preview === null) ? 'black' : ''}>
Choisir un fichier{' '}
{type
.map((t) => `.${t}`)
Expand Down
17 changes: 15 additions & 2 deletions src/components/dashboard/ItemModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const ItemModal = ({
const [infos, setInfos] = useState(item?.infos || null);
const [logo, setLogo] = useState<File | null>(null);
const [display, setDisplay] = useState(item?.display || false);
const [deleteImg, setDeleteImg] = useState(false);

const [attribute, setAttribute] = useState(item?.attribute || null);
const [category, setCategory] = useState(item?.category || null);
Expand All @@ -47,6 +48,10 @@ const ItemModal = ({
return `${year}-${month}-${day}T${hours}:${minutes}`;
};

function deleteLogo(): void {
setDeleteImg(!deleteImg);
}

return (
<Modal
visible={true}
Expand All @@ -58,7 +63,7 @@ const ItemModal = ({
primary
onClick={() => {
let image;
if (item?.image || logo) {
if ((item?.image || logo) && !deleteImg) {
image = true;
}

Expand Down Expand Up @@ -129,7 +134,15 @@ const ItemModal = ({
onChange={(value) => setQuantity(value as unknown as number)}
/>
<Textarea label="Description" value={infos ?? ''} onChange={setInfos} />
<FileInput label="Logo" value={item ? getItemImageLink(item.id) : ''} onChange={setLogo} type={['png']} />
<FileInput
textColor="black"
label="Logo"
value={item && item?.image ? getItemImageLink(item.id) : ''}
onChange={setLogo}
type={['png']}
/>
<Checkbox label="Supprimer l'image" value={deleteImg} onChange={deleteLogo} />
<br />
<Checkbox label="Display" value={display} onChange={setDisplay} />
</>
</Modal>
Expand Down
1 change: 1 addition & 0 deletions src/components/dashboard/PartnerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const PartnerModal = ({
<Input label="Lien" value={link ?? ''} onChange={setLink} />
<Textarea label="Description" value={description ?? ''} onChange={setDescription} />
<FileInput
textColor="black"
label="Logo"
value={partner ? getPartnerLogoLink(partner.id) : ''}
onChange={setLogo}
Expand Down
3 changes: 3 additions & 0 deletions src/components/dashboard/TournamentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,21 @@ const TournamentModal = ({
</div>

<FileInput
textColor="black"
label="Image"
value={tournament ? getTournamentImageLink(tournament.id) : ''}
onChange={setImage}
type={['jpg']}
/>
<FileInput
textColor="black"
label="Image de fond"
value={tournament ? getTournamentBackgroundLink(tournament.id) : ''}
onChange={setBackgroundImage}
type={['jpg']}
/>
<FileInput
textColor="black"
label="Règles"
value={tournament ? getTournamentRulesLink(tournament.id) : ''}
onChange={setRules}
Expand Down
2 changes: 1 addition & 1 deletion src/components/landing/LoginModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function LoginModal({
autocomplete="family-name"
/>
<Input
label="Pseudo (Nom d'invocateur pour LoL)"
label="Pseudo (Nom d'invocateur pour LoL avec #)"
value={signupForm.username}
onChange={(value: string) => updateSignup('username', value)}
autocomplete="nickname"
Expand Down

0 comments on commit c53c54a

Please sign in to comment.