Reduce Card options to "active" and "inactive", remove delete
This commit is contained in:
parent
6091d255d2
commit
3f40545712
|
@ -476,10 +476,8 @@ class CardSerializer(serializers.ModelSerializer):
|
||||||
)])
|
)])
|
||||||
member_id = serializers.SerializerMethodField()
|
member_id = serializers.SerializerMethodField()
|
||||||
active_status = serializers.ChoiceField([
|
active_status = serializers.ChoiceField([
|
||||||
'card_blocked',
|
'card_active',
|
||||||
'card_inactive',
|
'card_inactive',
|
||||||
'card_member_blocked',
|
|
||||||
'card_active'
|
|
||||||
])
|
])
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -246,7 +246,7 @@ class MemberViewSet(Base, Retrieve, Update):
|
||||||
return FileResponse(card_photo, filename='card.jpg')
|
return FileResponse(card_photo, filename='card.jpg')
|
||||||
|
|
||||||
|
|
||||||
class CardViewSet(Base, Create, Retrieve, Update, Destroy):
|
class CardViewSet(Base, Create, Retrieve, Update):
|
||||||
permission_classes = [AllowMetadata | IsAdmin]
|
permission_classes = [AllowMetadata | IsAdmin]
|
||||||
queryset = models.Card.objects.all()
|
queryset = models.Card.objects.all()
|
||||||
serializer_class = serializers.CardSerializer
|
serializer_class = serializers.CardSerializer
|
||||||
|
|
|
@ -12,7 +12,6 @@ function AdminCardDetail(props) {
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [success, setSuccess] = useState(false);
|
const [success, setSuccess] = useState(false);
|
||||||
const [yousure, setYousure] = useState(false);
|
|
||||||
const id = card.id;
|
const id = card.id;
|
||||||
|
|
||||||
const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value });
|
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) => ({
|
const makeProps = (name) => ({
|
||||||
name: name,
|
name: name,
|
||||||
onChange: handleChange,
|
onChange: handleChange,
|
||||||
|
@ -62,60 +45,44 @@ function AdminCardDetail(props) {
|
||||||
|
|
||||||
const statusOptions = [
|
const statusOptions = [
|
||||||
{ key: '0', text: 'Card Active', value: 'card_active' },
|
{ key: '0', text: 'Card Active', value: 'card_active' },
|
||||||
{ key: '1', text: 'Card Blocked', value: 'card_blocked' },
|
{ key: '1', text: 'Card Inactive', value: 'card_inactive' },
|
||||||
{ key: '2', text: 'Card Inactive', value: 'card_inactive' },
|
|
||||||
{ key: '3', text: 'Card Member Blocked', value: 'card_member_blocked' },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
input ?
|
<Segment raised color={input.active_status === 'card_active' ? 'green' : 'red'}>
|
||||||
<Segment raised color={input.active_status === 'card_active' ? 'green' : 'red'}>
|
<Form onSubmit={handleSubmit}>
|
||||||
<Form onSubmit={handleSubmit}>
|
<Form.Group widths='equal'>
|
||||||
<Form.Group widths='equal'>
|
<Form.Input
|
||||||
<Form.Input
|
fluid
|
||||||
fluid
|
{...makeProps('card_number')}
|
||||||
{...makeProps('card_number')}
|
/>
|
||||||
/>
|
<Form.Select
|
||||||
<Form.Select
|
fluid
|
||||||
fluid
|
options={statusOptions}
|
||||||
options={statusOptions}
|
{...makeProps('active_status')}
|
||||||
{...makeProps('active_status')}
|
onChange={handleValues}
|
||||||
onChange={handleValues}
|
/>
|
||||||
/>
|
|
||||||
|
|
||||||
<Form.Group widths='equal'>
|
<Form.Button
|
||||||
<Form.Button
|
loading={loading}
|
||||||
loading={loading}
|
error={error.non_field_errors}
|
||||||
error={error.non_field_errors}
|
>
|
||||||
>
|
{success ? 'Saved.' : 'Save'}
|
||||||
{success ? 'Saved.' : 'Save'}
|
</Form.Button>
|
||||||
</Form.Button>
|
</Form.Group>
|
||||||
|
|
||||||
<Form.Button
|
Notes: {input.notes || 'None'}<br />
|
||||||
color='red'
|
Last Seen:{' '}
|
||||||
onClick={handleDelete}
|
{input.last_seen ?
|
||||||
>
|
input.last_seen > '2021-11-14T02:01:35.415685Z' ?
|
||||||
{yousure ? 'You Sure?' : 'Delete'}
|
moment.utc(input.last_seen).tz('America/Edmonton').format('lll')
|
||||||
</Form.Button>
|
|
||||||
</Form.Group>
|
|
||||||
</Form.Group>
|
|
||||||
|
|
||||||
Notes: {input.notes || 'None'}<br />
|
|
||||||
Last Seen:{' '}
|
|
||||||
{input.last_seen ?
|
|
||||||
input.last_seen > '2021-11-14T02:01:35.415685Z' ?
|
|
||||||
moment.utc(input.last_seen).tz('America/Edmonton').format('lll')
|
|
||||||
:
|
|
||||||
moment.utc(input.last_seen).tz('America/Edmonton').format('ll')
|
|
||||||
:
|
:
|
||||||
'Unknown'
|
moment.utc(input.last_seen).tz('America/Edmonton').format('ll')
|
||||||
}
|
:
|
||||||
</Form>
|
'Unknown'
|
||||||
</Segment>
|
}
|
||||||
:
|
</Form>
|
||||||
<Segment raised color='black'>
|
</Segment>
|
||||||
Deleted card: {card.card_number}
|
|
||||||
</Segment>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user