generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:ita-social-projects/Forum into #…
…682_improvingTheMaskForEnteringA_PhoneNumberInTheContact_Tab
- Loading branch information
Showing
9 changed files
with
163 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 4.2.3 on 2024-07-05 11:48 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("profiles", "0017_remove_profile_banner_image_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="profile", | ||
name="status", | ||
field=models.CharField( | ||
choices=[ | ||
("undefined", "Undefined"), | ||
("pending", "Pending Moderation"), | ||
("blocked", "Blocked"), | ||
("approved", "Approved"), | ||
("auto_approved", "Auto Approved"), | ||
], | ||
default="undefined", | ||
max_length=15, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
FrontEnd/src/components/adminPage/auto-approve-delay/AutoApproveDelay.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useState, useEffect } from 'react'; | ||
import { toast } from 'react-toastify'; | ||
import { Tooltip } from 'antd'; | ||
import useSWR from 'swr'; | ||
import axios from 'axios'; | ||
import css from './AutoApproveDelay.module.css'; | ||
|
||
const AutoApproveDelay = () => { | ||
const fetcher = url => axios.get(url).then(res => res.data); | ||
const url = `${process.env.REACT_APP_BASE_API_URL}/api/admin/automoderation/`; | ||
const { data, mutate } = useSWR(url, fetcher); | ||
const [delay, setDelay] = useState(null); | ||
const [error, setError] = useState(null); | ||
|
||
useEffect(() => { | ||
if (data && data.auto_moderation_hours) { | ||
setDelay(data.auto_moderation_hours); | ||
} | ||
}, [data]); | ||
|
||
const handleInputChange = (e) => { | ||
let value = Number(e.target.value); | ||
setError(null); | ||
setDelay(value); | ||
if (!(1 <= value && value <= 48) || !Number.isInteger(value)) { | ||
setError('Кількість годин має бути в діапазоні 1-48 години'); | ||
} | ||
}; | ||
|
||
const handleSubmit = () => { | ||
!error && axios.put(`${process.env.REACT_APP_BASE_API_URL}/api/admin/automoderation/`, { 'auto_moderation_hours': delay }) | ||
.then(() => { toast.success('Зміни успішно застосовано.'); mutate({ ...data, auto_moderation_hours: delay }); }) | ||
.catch((e) => toast.error(e.message)); | ||
}; | ||
return ( | ||
<div className={css['autoapprove-section']}> | ||
<Tooltip | ||
title={'Введіть значення 1-48'} | ||
placement="top" | ||
pointAtCenter={true}> | ||
<input className={css['autoapprove-input']} type="number" step={1} onChange={handleInputChange} value={delay} /> | ||
</Tooltip> | ||
{error && | ||
<p className={css['error-message']}>{error}</p>} | ||
<button className={css['save-button']} onClick={handleSubmit}>Змінити</button> | ||
</div> | ||
); | ||
|
||
}; | ||
|
||
export default AutoApproveDelay; |
44 changes: 44 additions & 0 deletions
44
FrontEnd/src/components/adminPage/auto-approve-delay/AutoApproveDelay.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.autoapprove-section { | ||
display: flex; | ||
flex-direction: column; | ||
padding: 20px; | ||
gap: 10px; | ||
} | ||
|
||
.autoapprove-input { | ||
width: 150px; | ||
height: 20px; | ||
} | ||
.save-button { | ||
display: flex; | ||
padding: 5px 15px; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 10px; | ||
width: 150px; | ||
|
||
border-radius: 4px; | ||
border: 1px solid #1F9A7C; | ||
background: #1F9A7C; | ||
|
||
box-shadow: 0px 2px 0px 0px rgba(0, 0, 0, 0.04); | ||
|
||
/* Button Text */ | ||
color: #FFF; | ||
text-align: center; | ||
font-feature-settings: 'calt' off; | ||
text-decoration: none; | ||
font-family: var(--font-main); | ||
font-size: 16px; | ||
font-style: normal; | ||
font-weight: 600; | ||
line-height: 20px; | ||
letter-spacing: -0.16px; | ||
cursor: pointer; | ||
} | ||
|
||
.error-message { | ||
color: rgb(212, 21, 21); | ||
font-family: var(--font-main); | ||
font-size: 14px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters