Reduce Card options to "active" and "inactive", remove delete

This commit is contained in:
Tanner Collin 2023-06-05 01:44:40 +00:00
parent 6091d255d2
commit 3f40545712
3 changed files with 34 additions and 69 deletions

View File

@ -476,10 +476,8 @@ class CardSerializer(serializers.ModelSerializer):
)])
member_id = serializers.SerializerMethodField()
active_status = serializers.ChoiceField([
'card_blocked',
'card_active',
'card_inactive',
'card_member_blocked',
'card_active'
])
class Meta:

View File

@ -246,7 +246,7 @@ class MemberViewSet(Base, Retrieve, Update):
return FileResponse(card_photo, filename='card.jpg')
class CardViewSet(Base, Create, Retrieve, Update, Destroy):
class CardViewSet(Base, Create, Retrieve, Update):
permission_classes = [AllowMetadata | IsAdmin]
queryset = models.Card.objects.all()
serializer_class = serializers.CardSerializer

View File

@ -12,7 +12,6 @@ function AdminCardDetail(props) {
const [error, setError] = useState(false);
const [loading, setLoading] = useState(false);
const [success, setSuccess] = useState(false);
const [yousure, setYousure] = useState(false);
const id = card.id;
const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value });
@ -37,22 +36,6 @@ function AdminCardDetail(props) {
});
};
const handleDelete = (e) => {
e.preventDefault();
if (yousure) {
requester('/cards/'+id+'/', 'DELETE', token)
.then(res => {
setInput(false);
})
.catch(err => {
console.log(err);
});
} else {
setYousure(true);
}
};
const makeProps = (name) => ({
name: name,
onChange: handleChange,
@ -62,13 +45,10 @@ function AdminCardDetail(props) {
const statusOptions = [
{ key: '0', text: 'Card Active', value: 'card_active' },
{ key: '1', text: 'Card Blocked', value: 'card_blocked' },
{ key: '2', text: 'Card Inactive', value: 'card_inactive' },
{ key: '3', text: 'Card Member Blocked', value: 'card_member_blocked' },
{ key: '1', text: 'Card Inactive', value: 'card_inactive' },
];
return (
input ?
<Segment raised color={input.active_status === 'card_active' ? 'green' : 'red'}>
<Form onSubmit={handleSubmit}>
<Form.Group widths='equal'>
@ -83,21 +63,12 @@ function AdminCardDetail(props) {
onChange={handleValues}
/>
<Form.Group widths='equal'>
<Form.Button
loading={loading}
error={error.non_field_errors}
>
{success ? 'Saved.' : 'Save'}
</Form.Button>
<Form.Button
color='red'
onClick={handleDelete}
>
{yousure ? 'You Sure?' : 'Delete'}
</Form.Button>
</Form.Group>
</Form.Group>
Notes: {input.notes || 'None'}<br />
@ -112,10 +83,6 @@ function AdminCardDetail(props) {
}
</Form>
</Segment>
:
<Segment raised color='black'>
Deleted card: {card.card_number}
</Segment>
);
};