Skip to content

Commit

Permalink
made changes according to comment + rubber ducking
Browse files Browse the repository at this point in the history
  • Loading branch information
hams7504 committed Nov 30, 2023
1 parent aa1e56b commit cf5bf4d
Showing 1 changed file with 49 additions and 40 deletions.
89 changes: 49 additions & 40 deletions src/pages/user_profile/RequestForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,55 @@ export default function SupportRequestsPage(props) {
marginBottom: '1rem'
};

const possibleRoleRequests = [
{
key: 'checkRegisterDataset',
label: 'Register a dataset'
},
{
key: 'checkSOPermissions',
label: `I am a Signing Official and I want to issue permissions to my institution's users`
},
{
key: 'checkJoinDac',
label: 'I am looking to join a DAC'
}
];

const possibleLCRequests = [
{
key: 'requestNewLC',
label: 'Request a new library card',
isDefaultOption: true,
}
];

const possibleSupportRequests = props.isRequestRolePage ? possibleRoleRequests : (props.isRequestLCPage ? possibleLCRequests : []);

const [hasSupportRequests, setHasSupportRequests] = useState(props.isRequestLCPage);

const roleSupportRequests = {
checkRegisterDataset: false,
checkRequestDataAccess: false,
checkSOPermissions: false,
checkJoinDac: false,
extraRequest: undefined
};

const lcSupportRequests = {
requestNewLC: true,
};

const [supportRequests, setSupportRequests] = useState(props.isRequestRolePage ? roleSupportRequests : (props.isRequestLCPage ? lcSupportRequests : {}));
var possibleSupportRequests;
var hasSupportRequestsCond;
var supportRequestsCond;

if (props.isRequestRolePage) {
possibleSupportRequests = [
{
key: 'checkRegisterDataset',
label: 'Register a dataset'
},
{
key: 'checkSOPermissions',
label: `I am a Signing Official and I want to issue permissions to my institution's users`
},
{
key: 'checkJoinDac',
label: 'I am looking to join a DAC'
}
];
hasSupportRequestsCond = false;
supportRequestsCond = {
checkRegisterDataset: false,
checkRequestDataAccess: false,
checkSOPermissions: false,
checkJoinDac: false,
extraRequest: undefined
};
}
else if (props.isRequestLCPage) {
possibleSupportRequests = [
{
key: 'requestNewLC',
label: 'Request a new library card',
isDefaultOption: true,
}
];
hasSupportRequestsCond = true;
supportRequestsCond = {
requestNewLC: true,
};
}
else {
possibleSupportRequests = [];
hasSupportRequestsCond = false;
supportRequestsCond = {};
}

const [hasSupportRequests, setHasSupportRequests] = useState(hasSupportRequestsCond);
const [supportRequests, setSupportRequests] = useState(supportRequestsCond);

const goToPrevPage = async (event) => {
event.preventDefault();
Expand Down

0 comments on commit cf5bf4d

Please sign in to comment.